Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Cleanup __del__.
Browse files Browse the repository at this point in the history
You never need an __del__ to close a file.  A file closes itself when
it is deallocated.

Don't give an object a magic __del__ attribute.  It won't work with
new-style classes, and it's obscure anyway.
  • Loading branch information
Jeremy Hylton committed Apr 8, 2003
1 parent 3f81ff5 commit 379a1ce
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Draft.py
Expand Up @@ -79,12 +79,11 @@ def __bobo_traverse__(self, REQUEST, name):
try: db=self._p_jar.db()
except:
# BoboPOS 2
jar=Globals.VersionBase[self._version].jar
jar = Globals.VersionBase[self._version].jar
else:
# ZODB 3
jar=db.open(self._version)
cleanup=Cleanup()
cleanup.__del__=jar.close
jar = db.open(self._version)
cleanup = Cleanup(jar)
REQUEST[Cleanup]=cleanup


Expand Down Expand Up @@ -159,4 +158,9 @@ def getdraft(ob, jar):
return ob


class Cleanup: pass
class Cleanup:
def __init__(self, jar):
self._jar = jar

def __del__(self):
self._jar.close()

0 comments on commit 379a1ce

Please sign in to comment.