summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2014-01-14 23:13:28 -0500
committerTimothy Crosley <timothy.crosley@gmail.com>2014-01-14 23:13:28 -0500
commit7529e4109be9537c99217933f6130f7b7f978c05 (patch)
treedd9e0433c37720a0e334e803aee3b5f7fe8e4ade
parentcacbfc82e80077c244632c05cabe5b6a4c31c1c9 (diff)
parent25e2f5c81f7222d6ec0900f0d2653529568db603 (diff)
downloadpies-7529e4109be9537c99217933f6130f7b7f978c05.tar.gz
Merge branch 'release/2.5.5'2.5.5
-rw-r--r--pies/__init__.py2
-rw-r--r--pies/_utils.py29
-rw-r--r--pies/overrides.py23
-rw-r--r--pies2overrides/setup.py4
-rw-r--r--setup.py4
5 files changed, 48 insertions, 14 deletions
diff --git a/pies/__init__.py b/pies/__init__.py
index 3bca9aa..d768f63 100644
--- a/pies/__init__.py
+++ b/pies/__init__.py
@@ -29,4 +29,4 @@
OTHER DEALINGS IN THE SOFTWARE.
"""
-__version__ = "2.5.4"
+__version__ = "2.5.5"
diff --git a/pies/_utils.py b/pies/_utils.py
index f64b6b6..2098ccb 100644
--- a/pies/_utils.py
+++ b/pies/_utils.py
@@ -19,6 +19,8 @@
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""
+import abc
+import sys
def with_metaclass(meta, *bases):
@@ -54,10 +56,27 @@ def unmodified_isinstance(*bases):
it allows calls against passed in built in instances to pass even if there not a subclass
"""
class UnmodifiedIsInstance(type):
- @classmethod
- def __instancecheck__(cls, instance):
- if cls.__name__ in (str(base.__name__) for base in bases):
- return isinstance(instance, bases)
- return type.__instancecheck__(cls, instance)
+ if sys.version_info[0] == 2 and sys.version_info[1] <= 6:
+
+ @classmethod
+ def __instancecheck__(cls, instance):
+ if cls.__name__ in (str(base.__name__) for base in bases):
+ return isinstance(instance, bases)
+
+ subclass = getattr(instance, '__class__', None)
+ subtype = type(instance)
+ if subtype is abc._InstanceType:
+ subtype = subclass
+ if subtype is subclass or subclass is None:
+ return cls.__subclasscheck__(subtype)
+ return (cls.__subclasscheck__(subclass) or cls.__subclasscheck__(subtype))
+ else:
+ @classmethod
+ def __instancecheck__(cls, instance):
+ if cls.__name__ in (str(base.__name__) for base in bases):
+ return isinstance(instance, bases)
+
+ return type.__instancecheck__(cls, instance)
return with_metaclass(UnmodifiedIsInstance, *bases)
+
diff --git a/pies/overrides.py b/pies/overrides.py
index 5577e59..c826897 100644
--- a/pies/overrides.py
+++ b/pies/overrides.py
@@ -21,7 +21,9 @@
"""
from __future__ import absolute_import
+import abc
import functools
+import sys
from numbers import Integral
from ._utils import unmodified_isinstance, with_metaclass
@@ -205,10 +207,23 @@ else:
dct['__str__'] = lambda self: self.__unicode__().encode('utf-8')
return type.__new__(cls, name, bases, dct)
- def __instancecheck__(cls, instance):
- if cls.__name__ == "object":
- return isinstance(instance, native_object)
- return type.__instancecheck__(cls, instance)
+ if sys.version_info[1] <= 6:
+ def __instancecheck__(cls, instance):
+ if cls.__name__ == "object":
+ return isinstance(instance, native_object)
+
+ subclass = getattr(instance, '__class__', None)
+ subtype = type(instance)
+ if subtype is abc._InstanceType:
+ subtype = subclass
+ if subtype is subclass or subclass is None:
+ return cls.__subclasscheck__(subtype)
+ return (cls.__subclasscheck__(subclass) or cls.__subclasscheck__(subtype))
+ else:
+ def __instancecheck__(cls, instance):
+ if cls.__name__ == "object":
+ return isinstance(instance, native_object)
+ return type.__instancecheck__(cls, instance)
class object(with_metaclass(FixStr, object)):
pass
diff --git a/pies2overrides/setup.py b/pies2overrides/setup.py
index d800c54..664b697 100644
--- a/pies2overrides/setup.py
+++ b/pies2overrides/setup.py
@@ -14,12 +14,12 @@ if sys.version_info[0] == 2 and sys.version_info[1] < 7:
install_requires += ['ordereddict', 'argparse']
setup(name='pies2overrides',
- version='2.5.4',
+ version='2.5.5',
description='Defines override classes that should be included with pies only if running on Python2.',
author='Timothy Crosley',
author_email='timothy.crosley@gmail.com',
url='https://github.com/timothycrosley/pies',
- download_url='https://github.com/timothycrosley/pies/blob/master/pies2overrides/dist/pies2overrides-2.5.4.tar.gz?raw=true',
+ download_url='https://github.com/timothycrosley/pies/blob/master/pies2overrides/dist/pies2overrides-2.5.5.tar.gz?raw=true',
license="MIT",
install_requires=install_requires,
requires=install_requires,
diff --git a/setup.py b/setup.py
index cbb728e..d733ddf 100644
--- a/setup.py
+++ b/setup.py
@@ -24,13 +24,13 @@ except (IOError, ImportError, OSError, RuntimeError):
readme = ''
setup(name='pies',
- version='2.5.4',
+ version='2.5.5',
description='The simplest way to write one program that runs on both Python 2 and Python 3.',
long_description=readme,
author='Timothy Crosley',
author_email='timothy.crosley@gmail.com',
url='https://github.com/timothycrosley/pies',
- download_url='https://github.com/timothycrosley/pies/blob/master/dist/pies-2.5.4.tar.gz?raw=true',
+ download_url='https://github.com/timothycrosley/pies/blob/master/dist/pies-2.5.5.tar.gz?raw=true',
license="MIT",
install_requires=install_requires,
requires=install_requires,