- changed milestone to 0.8.xx
loads() sometimes broken
Issue #2698
resolved
Under Python 3.2.3 (and probably all Python 3 versions), the loads() method can choke if it ever needs to call the persistent_load(id) function.
If following the serialize tutorial at http://docs.sqlalchemy.org/en/rel_0_8/core/serializer.html, SQLAlchemy may choke if you have serialized some query objects. I think I've tracked this down... because Python 3 now differentiates between strings and binary strings, the line
m = our_ids.match(id)
can fail with a
TypeError: can't use a string pattern on a bytes-like object
since id is a binary string from pickler.
The solution seems to be simple... Change this:
...
def persistent_load(id):
m = our_ids.match(id)
if not m:
return None
else:
...
to this:
...
def persistent_load(id):
# start Py3K
id = str(id)
# end Py3K
m = our_ids.match(id)
if not m:
return None
else:
...
Comments (3)
-
repo owner -
repo owner - changed status to resolved
fixed this and a bunch of other pretty obvious problems in e3a7015f8991cea869c6e59cd537fec9836fc9bd.
-
repo owner - removed milestone
Removing milestone: 0.8.xx (automated comment)
- Log in to comment
that's handy. the serializer extension has lots of not really solvable problems though, including http://bugs.python.org/issue9269. I wouldn't rely upon it.