Skip to content

Commit

Permalink
Fix python 3 compatibility to work with IronPython (fix Infinidat#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmalloc committed Mar 20, 2017
1 parent 1afd607 commit 2933685
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
25 changes: 1 addition & 24 deletions munch/python3_compat.py
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
import sys

_PY2 = (sys.version_info < (3, 0))


def identity(x):
return x

# u('string') replaces the forwards-incompatible u'string'
if _PY2:
import codecs

def u(string):
return codecs.unicode_escape_decode(string)[0]
else:
u = identity

# dict.iteritems(), dict.iterkeys() is also incompatible
if _PY2:
iteritems = dict.iteritems # pylint: disable=no-member
iterkeys = dict.iterkeys # pylint: disable=no-member
else:
iteritems = dict.items
iterkeys = dict.keys
from six import u, iteritems, iterkeys # pylint: disable=unused-import
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
url="http://github.com/Infinidat/munch",
author="Rotem Yaari",
author_email="[email protected]",
install_requires=[
'six',
],
packages=find_packages(exclude=["tests"]),
keywords=['munch', 'dict', 'mapping', 'container', 'collection'],
classifiers=[
Expand Down

0 comments on commit 2933685

Please sign in to comment.