attrs/attr/_compat.py

28 lines
575 B
Python
Raw Normal View History

from __future__ import absolute_import, division, print_function
import sys
PY3 = sys.version_info[0] == 3
2015-01-29 19:50:42 +00:00
PY2 = sys.version_info[0] == 2
2015-01-30 16:48:34 +00:00
PY26 = sys.version_info[0:2] == (2, 6)
2015-01-29 19:50:42 +00:00
if PY2:
# TYPE is used in exceptions, repr(int) is differnt on Python 2 and 3.
TYPE = "type"
def exec_(code, locals_, globals_):
exec("exec code in locals_, globals_")
2015-01-29 19:50:42 +00:00
def iteritems(d):
return d.iteritems()
else:
2015-01-29 19:50:42 +00:00
TYPE = "class"
def exec_(code, locals_, globals_):
exec(code, locals_, globals_)
2015-01-29 19:50:42 +00:00
def iteritems(d):
return d.items()