Commit 12be176b authored by Mark Florisson's avatar Mark Florisson

Fix python 3 deepcopy & sorting compatiblity

parent 4dd15777
......@@ -68,8 +68,11 @@ class BaseType(object):
"""
For sorting. The sorting order should correspond to the preference of
conversion from Python types.
Override to provide something sensible. This is only implemented so that
python 3 doesn't trip
"""
return NotImplemented
return id(type(self)) < id(type(other))
def py_type_name(self):
"""
......@@ -1209,7 +1212,8 @@ class CNumericType(CType):
if other.is_numeric:
return self.rank > other.rank and self.signed >= other.signed
return NotImplemented
# Prefer numeric types over others
return True
def py_type_name(self):
if self.rank <= 4:
......
......@@ -115,6 +115,9 @@ class EncodedString(_unicode):
# otherwise
encoding = None
def __deepcopy__(self, memo):
return self
def byteencode(self):
assert self.encoding is not None
return self.encode(self.encoding)
......@@ -131,6 +134,9 @@ class BytesLiteral(_bytes):
# bytes subclass that is compatible with EncodedString
encoding = None
def __deepcopy__(self, memo):
return self
def byteencode(self):
if IS_PYTHON3:
return _bytes(self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment