[Checkins] SVN: persistent/trunk/ Py3k: repr() must get a native string.
Tres Seaver
cvs-admin at zope.org
Fri Jun 29 04:02:35 UTC 2012
Log message for revision 127177:
Py3k: repr() must get a native string.
Changed:
_U persistent/trunk/
U persistent/trunk/persistent/_compat.py
U persistent/trunk/persistent/timestamp.py
-=-
Modified: persistent/trunk/persistent/_compat.py
===================================================================
--- persistent/trunk/persistent/_compat.py 2012-06-29 04:02:27 UTC (rev 127176)
+++ persistent/trunk/persistent/_compat.py 2012-06-29 04:02:31 UTC (rev 127177)
@@ -22,6 +22,11 @@
def _u(s):
return s
+ def _native(s):
+ if isinstance(s, bytes):
+ return s.decode('unicode_escape')
+ return s
+
PYTHON3 = True
PYTHON2 = False
@@ -33,5 +38,10 @@
def _u(s):
return unicode(s, 'unicode_escape')
+ def _native(s):
+ if isinstance(s, unicode):
+ return s.encode('unicode_escape')
+ return s
+
PYTHON3 = False
PYTHON2 = True
Modified: persistent/trunk/persistent/timestamp.py
===================================================================
--- persistent/trunk/persistent/timestamp.py 2012-06-29 04:02:27 UTC (rev 127176)
+++ persistent/trunk/persistent/timestamp.py 2012-06-29 04:02:31 UTC (rev 127177)
@@ -18,6 +18,7 @@
import struct
import sys
+from persistent._compat import _native
_RAWTYPE = bytes
@@ -89,7 +90,7 @@
return self._raw
def __repr__(self):
- return self._raw
+ return _native(self._raw)
def year(self):
return self._elements[0]
More information about the checkins
mailing list