Commit a83f388b authored by Tres Seaver's avatar Tres Seaver

Py3k: repr() must get a native string.

parent d492ea2e
...@@ -22,6 +22,11 @@ if sys.version_info[0] > 2: #pragma NO COVER ...@@ -22,6 +22,11 @@ if sys.version_info[0] > 2: #pragma NO COVER
def _u(s): def _u(s):
return s return s
def _native(s):
if isinstance(s, bytes):
return s.decode('unicode_escape')
return s
PYTHON3 = True PYTHON3 = True
PYTHON2 = False PYTHON2 = False
...@@ -33,5 +38,10 @@ else: #pragma NO COVER ...@@ -33,5 +38,10 @@ else: #pragma NO COVER
def _u(s): def _u(s):
return unicode(s, 'unicode_escape') return unicode(s, 'unicode_escape')
def _native(s):
if isinstance(s, unicode):
return s.encode('unicode_escape')
return s
PYTHON3 = False PYTHON3 = False
PYTHON2 = True PYTHON2 = True
...@@ -18,6 +18,7 @@ import math ...@@ -18,6 +18,7 @@ import math
import struct import struct
import sys import sys
from persistent._compat import _native
_RAWTYPE = bytes _RAWTYPE = bytes
...@@ -89,7 +90,7 @@ class pyTimeStamp(object): ...@@ -89,7 +90,7 @@ class pyTimeStamp(object):
return self._raw return self._raw
def __repr__(self): def __repr__(self):
return self._raw return _native(self._raw)
def year(self): def year(self):
return self._elements[0] return self._elements[0]
......
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