is_py3k -> is_py3

This commit is contained in:
Dave Halter
2014-01-14 11:43:56 +01:00
parent a6e49f2680
commit 99882724da
7 changed files with 22 additions and 22 deletions
+8 -8
View File
@@ -10,9 +10,9 @@ try:
except ImportError:
pass
is_py3k = sys.hexversion >= 0x03000000
is_py33 = sys.hexversion >= 0x03030000
is_py26 = sys.hexversion < 0x02700000
is_py3 = sys.version_info[0] >= 3
is_py33 = is_py3 and sys.version_info.minor >= 3
is_py26 = not is_py3 and sys.version_info[1] < 7
def find_module_py33(string, path=None):
@@ -82,7 +82,7 @@ try:
except NameError:
unicode = str
if is_py3k:
if is_py3:
utf8 = lambda s: s
else:
utf8 = lambda s: s.decode('utf-8')
@@ -92,7 +92,7 @@ Decode a raw string into unicode object. Do nothing in Python 3.
"""
# exec function
if is_py3k:
if is_py3:
def exec_function(source, global_map):
exec(source, global_map)
else:
@@ -100,7 +100,7 @@ else:
exec source in global_map """, 'blub', 'exec'))
# re-raise function
if is_py3k:
if is_py3:
def reraise(exception, traceback):
raise exception.with_traceback(traceback)
else:
@@ -125,7 +125,7 @@ except ImportError:
from io import StringIO
# hasattr function used because python
if is_py3k:
if is_py3:
hasattr = hasattr
else:
def hasattr(obj, name):
@@ -168,7 +168,7 @@ def u(string):
have to cast back to a unicode (and we now that we always deal with valid
unicode, because we check that in the beginning).
"""
if is_py3k:
if is_py3:
return str(string)
elif not isinstance(string, unicode):
return unicode(str(string), 'UTF-8')