Allow to use easily unicode_literals
Transparently encode __name__ to utf-8 to allow usage of unicode_literals Fix PYSON to support unicode issue4294 review11601002
This commit is contained in:
1 parent
20fed6f5a2
commit
93deeeced8
2 files changed
+12
-9
No files matched your search
+4
-1
@@ -14,7 +14,10 @@ class PoolMeta(type):
|
||||
def __new__(cls, name, bases, dct):
|
||||
new = type.__new__(cls, name, bases, dct)
|
||||
if '__name__' in dct:
|
||||
new.__name__ = dct['__name__']
|
||||
try:
|
||||
new.__name__ = dct['__name__']
|
||||
except TypeError:
|
||||
new.__name__ = dct['__name__'].encode('utf-8')
|
||||
return new
|
||||
|
||||
|
||||
|
||||
+8
-8
@@ -367,9 +367,9 @@ class Get(PYSON):
|
||||
assert isinstance(obj, dict), 'obj must be a dict'
|
||||
self._obj = obj
|
||||
if isinstance(key, PYSON):
|
||||
assert key.types() == set([str]), 'key must be a string'
|
||||
assert key.types() == set([str, unicode]), 'key must be a string'
|
||||
else:
|
||||
assert type(key) == str, 'key must be a string'
|
||||
assert type(key) in [str, unicode], 'key must be a string'
|
||||
self._key = key
|
||||
self._default = default
|
||||
|
||||
@@ -397,20 +397,20 @@ class In(PYSON):
|
||||
def __init__(self, key, obj):
|
||||
super(In, self).__init__()
|
||||
if isinstance(key, PYSON):
|
||||
assert key.types().issubset(set([str, int, long])), \
|
||||
assert key.types().issubset(set([str, unicode, int, long])), \
|
||||
'key must be a string or an integer or a long'
|
||||
else:
|
||||
assert type(key) in [str, int, long], \
|
||||
assert type(key) in [str, unicode, int, long], \
|
||||
'key must be a string or an integer or a long'
|
||||
if isinstance(obj, PYSON):
|
||||
assert obj.types().issubset(set([dict, list])), \
|
||||
'obj must be a dict or a list'
|
||||
if obj.types() == set([dict]):
|
||||
assert type(key) == str, 'key must be a string'
|
||||
assert type(key) in [str, unicode], 'key must be a string'
|
||||
else:
|
||||
assert type(obj) in [dict, list]
|
||||
if type(obj) == dict:
|
||||
assert type(key) == str, 'key must be a string'
|
||||
assert type(key) in [str, unicode], 'key must be a string'
|
||||
self._key = key
|
||||
self._obj = obj
|
||||
|
||||
@@ -542,10 +542,10 @@ class Len(PYSON):
|
||||
def __init__(self, value):
|
||||
super(Len, self).__init__()
|
||||
if isinstance(value, PYSON):
|
||||
assert value.types().issubset(set([dict, list, str])), \
|
||||
assert value.types().issubset(set([dict, list, str, unicode])), \
|
||||
'value must be a dict or a list or a string'
|
||||
else:
|
||||
assert type(value) in [dict, list, str], \
|
||||
assert type(value) in [dict, list, str, unicode], \
|
||||
'value must be a dict or list or a string'
|
||||
self._value = value
|
||||
|
||||
|
||||
Reference in new issue
Block a user