diff options
author | grabner <pjg.github@ubergrabner.net> | 2014-04-16 13:51:29 -0400 |
---|---|---|
committer | grabner <pjg.github@ubergrabner.net> | 2014-04-16 13:51:29 -0400 |
commit | e8b3d11417e9adae65f6d36b2a75de9cd1116242 (patch) | |
tree | 49ea04832a0b47e3b20877e98ec80e76b81d3e9c | |
parent | 7f706596da407516815145d521890fd9e27e74c9 (diff) | |
download | iniherit-e8b3d11417e9adae65f6d36b2a75de9cd1116242.tar.gz |
corrected python 3 compatibility
-rw-r--r-- | iniherit/mixin.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/iniherit/mixin.py b/iniherit/mixin.py index d8ee0f9..d4963b0 100644 --- a/iniherit/mixin.py +++ b/iniherit/mixin.py @@ -8,13 +8,13 @@ import six from six.moves import configparser as CP -# TODO: what is the PY3 version of 'new'?... -import new -from iniherit.parser import IniheritMixin +from .parser import IniheritMixin #------------------------------------------------------------------------------ +# todo: should this perhaps use the `stub` package instead?... + attrs = [attr for attr in dir(IniheritMixin) if not attr.startswith('__')] #------------------------------------------------------------------------------ @@ -33,7 +33,11 @@ def install_globally(): '_iniherit_' + attr, getattr(CP.RawConfigParser, attr)) meth = getattr(IniheritMixin, attr) if six.callable(meth): - meth = new.instancemethod(meth.im_func, None, CP.RawConfigParser) + if six.PY2: + import new + meth = new.instancemethod(meth.__func__, None, CP.RawConfigParser) + else: + meth = meth.__get__(None, CP.RawConfigParser) setattr(CP.RawConfigParser, attr, meth) #------------------------------------------------------------------------------ |