File tree 2 files changed +7
-17
lines changed
2 files changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,7 @@ def __init__(self, connection):
21
21
Do not create an instance of a Cursor yourself. Call
22
22
connections.Connection.cursor().
23
23
'''
24
- from weakref import ref
25
- self .connection = ref (connection )
24
+ self .connection = connection
26
25
self .description = None
27
26
self .rownumber = 0
28
27
self .rowcount = - 1
@@ -44,10 +43,6 @@ def close(self):
44
43
conn = self .connection
45
44
if conn is None :
46
45
return
47
- if conn () is None :
48
- self .connection = None
49
- return
50
-
51
46
try :
52
47
while self .nextset ():
53
48
pass
@@ -56,11 +51,8 @@ def close(self):
56
51
57
52
def _get_db (self ):
58
53
if not self .connection :
59
- raise ProgrammingError ("cursor closed" )
60
- con = self .connection ()
61
- if con is None :
62
- raise ProgrammingError ("Connection closed" )
63
- return con
54
+ raise ProgrammingError ("Cursor closed" )
55
+ return self .connection
64
56
65
57
def _check_executed (self ):
66
58
if not self ._executed :
@@ -288,10 +280,6 @@ def close(self):
288
280
conn = self .connection
289
281
if conn is None :
290
282
return
291
- conn = conn ()
292
- if conn is None :
293
- self .connection = None
294
- return
295
283
296
284
if self ._result is not None and self ._result is conn ._result :
297
285
self ._result ._finish_unbuffered_query ()
@@ -304,7 +292,7 @@ def close(self):
304
292
305
293
def _query (self , q ):
306
294
conn = self ._get_db ()
307
- self .lastexecuted = q
295
+ self .lastexecuted = q
308
296
conn .query (q , unbuffered = True )
309
297
self ._do_get_result ()
310
298
return self .rowcount
Original file line number Diff line number Diff line change 13
13
14
14
@atexit .register
15
15
def report_uncollectable ():
16
- if not gc .garbage : return
16
+ if not gc .garbage :
17
+ print ("No garbages!" )
18
+ return
17
19
print ('uncollectable objects' )
18
20
for obj in gc .garbage :
19
21
print (obj )
You can’t perform that action at this time.
0 commit comments