Mark: fix python 3 compatibility

This commit is contained in:
Ronny Pfannschmidt 2016-09-08 10:03:45 +02:00
parent 10094a3f09
commit 1812387bf0
2 changed files with 5 additions and 3 deletions

View File

@ -111,7 +111,7 @@ if sys.version_info[:2] == (2, 6):
if _PY3: if _PY3:
import codecs import codecs
imap = map
STRING_TYPES = bytes, str STRING_TYPES = bytes, str
def _escape_strings(val): def _escape_strings(val):
@ -145,6 +145,8 @@ if _PY3:
else: else:
STRING_TYPES = bytes, str, unicode STRING_TYPES = bytes, str, unicode
from itertools import imap
def _escape_strings(val): def _escape_strings(val):
"""In py2 bytes and str are the same type, so return if it's a bytes """In py2 bytes and str are the same type, so return if it's a bytes
object, return it unchanged if it is a full ascii string, object, return it unchanged if it is a full ascii string,
@ -213,4 +215,4 @@ def _is_unittest_unexpected_success_a_failure():
Changed in version 3.4: Returns False if there were any Changed in version 3.4: Returns False if there were any
unexpectedSuccesses from tests marked with the expectedFailure() decorator. unexpectedSuccesses from tests marked with the expectedFailure() decorator.
""" """
return sys.version_info >= (3, 4) return sys.version_info >= (3, 4)

View File

@ -2,7 +2,7 @@
import inspect import inspect
from collections import namedtuple from collections import namedtuple
from operator import attrgetter from operator import attrgetter
from itertools import imap from .compat import imap
def alias(name): def alias(name):
return property(attrgetter(name), doc='alias for ' + name) return property(attrgetter(name), doc='alias for ' + name)