forbid dict parameter · PyMySQL/PyMySQL@521e400 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 521e400

Browse files
committed
forbid dict parameter
1 parent 7f032a6 commit 521e400

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

pymysql/converters.py

Lines 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

Lines 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)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.