Skip to content

Commit d505521

Browse files
authored
Merge pull request PyMySQL#93 from methane/cursor-connections
Cursor.connection is real reference
2 parents ae9d6f8 + 06f2b66 commit d505521

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

MySQLdb/cursors.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ class BaseCursor(object):
6060
InternalError, ProgrammingError, NotSupportedError
6161

6262
_defer_warnings = False
63+
connection = None
6364

6465
def __init__(self, connection):
65-
from weakref import ref
66-
67-
self.connection = ref(connection)
66+
self.connection = connection
6867
self.description = None
6968
self.description_flags = None
7069
self.rowcount = -1
@@ -81,7 +80,7 @@ def __init__(self, connection):
8180
def close(self):
8281
"""Close the cursor. No further queries will be possible."""
8382
try:
84-
if self.connection is None or self.connection() is None:
83+
if self.connection is None:
8584
return
8685
while self.nextset():
8786
pass
@@ -192,8 +191,6 @@ def setoutputsizes(self, *args):
192191

193192
def _get_db(self):
194193
con = self.connection
195-
if con is not None:
196-
con = con()
197194
if con is None:
198195
raise ProgrammingError("cursor closed")
199196
return con

0 commit comments

Comments
 (0)