Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 521e400

Browse filesBrowse files
committed
forbid dict parameter
1 parent 7f032a6 commit 521e400
Copy full SHA for 521e400

File tree

2 files changed

+6
-7
lines changed
Filter options

2 files changed

+6
-7
lines changed

‎pymysql/converters.py

Copy file name to clipboardExpand all lines: pymysql/converters.py
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ def escape_item(val, charset, mapping=None):
2727

2828

2929
def escape_dict(val, charset, mapping=None):
30-
n = {}
31-
for k, v in val.items():
32-
quoted = escape_item(v, charset, mapping)
33-
n[k] = quoted
34-
return n
30+
raise TypeError("dict can not be used as parameter")
3531

3632

3733
def escape_sequence(val, charset, mapping=None):

‎pymysql/tests/test_connection.py

Copy file name to clipboardExpand all lines: pymysql/tests/test_connection.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,15 @@ def test_escape_no_default(self):
848848

849849
self.assertRaises(TypeError, con.escape, 42, {})
850850

851-
def test_escape_dict_value(self):
851+
def test_escape_dict_raise_typeerror(self):
852+
"""con.escape(dict) should raise TypeError"""
852853
con = self.connect()
853854

854855
mapping = con.encoders.copy()
855856
mapping[Foo] = escape_foo
856-
self.assertEqual(con.escape({"foo": Foo()}, mapping), {"foo": "bar"})
857+
#self.assertEqual(con.escape({"foo": Foo()}, mapping), {"foo": "bar"})
858+
with self.assertRaises(TypeError):
859+
con.escape({"foo": Foo()})
857860

858861
def test_escape_list_item(self):
859862
con = self.connect()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.