Skip to content

Commit b3e775a

Browse files
authored
fix Cursor.executemany created many circular references (#375)
1 parent 23addef commit b3e775a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

MySQLdb/cursors.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ def ensure_bytes(x):
110110
return x
111111

112112
if isinstance(args, (tuple, list)):
113-
return tuple(literal(ensure_bytes(arg)) for arg in args)
113+
ret = tuple(literal(ensure_bytes(arg)) for arg in args)
114114
elif isinstance(args, dict):
115-
return {ensure_bytes(key): literal(ensure_bytes(val))
116-
for (key, val) in args.items()}
115+
ret = {ensure_bytes(key): literal(ensure_bytes(val))
116+
for (key, val) in args.items()}
117117
else:
118118
# If it's not a dictionary let's try escaping it anyways.
119119
# Worst case it will throw a Value error
120-
return literal(ensure_bytes(args))
120+
ret = literal(ensure_bytes(args))
121+
122+
ensure_bytes = None # break circular reference
123+
return ret
121124

122125
def _check_executed(self):
123126
if not self._executed:

0 commit comments

Comments
 (0)