Author: Brian Kearns <bdkea...@gmail.com>
Branch: 
Changeset: r62028:b17d5445e672
Date: 2013-03-04 17:57 -0500
http://bitbucket.org/pypy/pypy/changeset/b17d5445e672/

Log:    remove unnecessary _sqlite3.Connection.closed

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -316,7 +316,6 @@
             sqlite.sqlite3_busy_timeout(self.db, timeout)
 
         self.text_factory = unicode_text_factory
-        self.closed = False
         self.statements = []
         self.statement_counter = 0
         self.row_factory = None
@@ -513,7 +512,7 @@
     def _check_closed(self):
         if self.db is None:
             raise ProgrammingError("Base Connection.__init__ not called.")
-        if getattr(self, 'closed', True):
+        if not self.db:
             raise ProgrammingError("Cannot operate on a closed database.")
 
     def __enter__(self):
@@ -531,18 +530,17 @@
 
     def close(self):
         self._check_thread()
-        if self.closed:
-            return
+
         for statement in self.statements:
             obj = statement()
             if obj is not None:
                 obj.finalize()
 
-        self.closed = True
-        ret = sqlite.sqlite3_close(self.db)
-        self._reset_cursors()
-        if ret != SQLITE_OK:
-            raise self._get_exception(ret)
+        if self.db:
+            ret = sqlite.sqlite3_close(self.db)
+            if ret != SQLITE_OK:
+                raise self._get_exception(ret)
+            self.db.value = 0
 
     def create_collation(self, name, callback):
         self._check_thread()
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to