With PyMySQL 1.2.3 any query with a bytes parameter fails.
connection.py line 20 imports escape_bytes_prefixed and line 418 calls it. In 1.2.3 that name is not a function any more:
# pymysql/converters.py
# This silly alias is needed for aiomysql compatibility for now. It is scheduled for removal in 1.3.0.
escape_dict = escape_bytes_prefixed = "DO NOT IMPORT THIS!!!"
The alias was added in 1.2.3 to unbreak the import in aiomysql/__init__.py, see PyMySQL/PyMySQL#1274. The import works again, the call doesn't.
Repro:
import asyncio
import aiomysql
async def main():
conn = await aiomysql.connect(
host="127.0.0.1", port=3306, user="scott", password="tiger", db="test"
)
async with conn.cursor() as cur:
await cur.execute("CREATE TABLE IF NOT EXISTS t (id INT, data BLOB)")
await cur.execute("INSERT INTO t VALUES (%s, %s)", (1, b"binary"))
conn.close()
asyncio.run(main())
File "aiomysql/cursors.py", line 197, in _escape_args
return tuple(conn.escape(arg) for arg in args)
File "aiomysql/connection.py", line 418, in escape
return escape_bytes_prefixed(obj)
TypeError: 'str' object is not callable
Passes with PyMySQL 1.1.3.
Environment: aiomysql 0.3.2, PyMySQL 1.2.3, MariaDB 13.0.2, Python 3.13.
One more thing: that alias is scheduled for removal in PyMySQL 1.3.0, and escape_dict in aiomysql/__init__.py goes with it. At that point aiomysql won't import at all.
Related: #1077. PR follows.
With PyMySQL 1.2.3 any query with a bytes parameter fails.
connection.pyline 20 importsescape_bytes_prefixedand line 418 calls it. In 1.2.3 that name is not a function any more:The alias was added in 1.2.3 to unbreak the import in
aiomysql/__init__.py, see PyMySQL/PyMySQL#1274. The import works again, the call doesn't.Repro:
Passes with PyMySQL 1.1.3.
Environment: aiomysql 0.3.2, PyMySQL 1.2.3, MariaDB 13.0.2, Python 3.13.
One more thing: that alias is scheduled for removal in PyMySQL 1.3.0, and
escape_dictinaiomysql/__init__.pygoes with it. At that point aiomysql won't import at all.Related: #1077. PR follows.