Skip to content

Commit

Permalink
python 2.6.4 and lower cannot handle unicode keys passed to __init__ (M…
Browse files Browse the repository at this point in the history
  • Loading branch information
rozza committed Sep 3, 2012
1 parent f108c42 commit 0b23bc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mongoengine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from queryset import DO_NOTHING

from mongoengine import signals
from mongoengine.python_support import (PY3, PY25, txt_type,
from mongoengine.python_support import (PY3, UNICODE_KWARGS, txt_type,
to_str_keys_recursive)

import pymongo
Expand Down Expand Up @@ -1054,9 +1054,9 @@ def _from_son(cls, son):
# class if unavailable
class_name = son.get('_cls', cls._class_name)
data = dict(("%s" % key, value) for key, value in son.items())
if PY25:
# PY25 cannot handle unicode keys passed to class constructor
# example: cls(**data)
if not UNICODE_KWARGS:
# python 2.6.4 and lower cannot handle unicode keys
# passed to class constructor example: cls(**data)
to_str_keys_recursive(data)

if '_types' in data:
Expand Down
1 change: 1 addition & 0 deletions mongoengine/python_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

PY3 = sys.version_info[0] == 3
PY25 = sys.version_info[:2] == (2, 5)
UNICODE_KWARGS = int(''.join([str(x) for x in sys.version_info[:3]])) > 264

if PY3:
import codecs
Expand Down

0 comments on commit 0b23bc9

Please sign in to comment.