8000 Fix escaping bytearray on PY2 · pkdevboxy/PyMySQL@1cc9494 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cc9494

Browse files
committed
Fix escaping bytearray on PY2
1 parent c139119 commit 1cc9494

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pymysql/converters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def escape_string(value, mapping=None):
8181
"""
8282
if isinstance(value, unicode):
8383
return escape_unicode(value)
84-
assert isinstance(value, bytes)
84+
assert isinstance(value, (bytes, bytearray))
8585
value = value.replace('\\', '\\\\')
8686
value = value.replace('\0', '\\0')
8787
value = value.replace('\n', '\\n')
@@ -93,7 +93,7 @@ def escape_string(value, mapping=None):
9393

9494
def escape_bytes(value, mapping=None):
9595
assert isinstance(value, (bytes, bytearray))
96-
return b"_binary'%s'" % value
96+
return b"_binary'%s'" % escape_string(value)
9797
else:
9898
escape_string = _escape_unicode
9999

0 commit comments

Comments
 (0)
0