Issue2055
Created on 2013-05-20.09:52:20 by Arfrever, last changed 2018-03-23.22:36:14 by jeff.allen.
msg8023 (view) |
Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) |
Date: 2013-05-20.09:52:20 |
|
isinstance() and issubclass() fail with abc.ABCMeta in Jython. They work in CPython.
$ cat abc_test.py
import abc
class A(abc.ABCMeta): pass
print(isinstance(0, abc.ABCMeta))
print(issubclass(A, abc.ABCMeta))
print(issubclass(abc.ABCMeta, abc.ABCMeta))
$ python2.7 abc_test.py
False
True
True
$ jython2.7 abc_test.py
Traceback (most recent call last):
File "abc_test.py", line 3, in <module>
print(isinstance(0, abc.ABCMeta))
RuntimeError: maximum recursion depth exceeded in __instancecheck__
|
msg8024 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2013-05-20.18:08:27 |
|
It'd be helpful to know what method call inside of __instancecheck__ (I assume the message refers to ABCMeta.__instance__check__) ends up triggering the recursion
|
msg8397 (view) |
Author: Hank Gay (gthank) |
Date: 2014-05-13.19:49:42 |
|
Target beta 4.
|
msg8398 (view) |
Author: Jim Baker (zyasoft) |
Date: 2014-05-13.20:08:48 |
|
Interesting, I was reviewing test_abc.py and I see that there was a related problem in CPython earlier, as seen in the commented-out code. Of course this commented-out code actually works on both CPython and Jython now, so we have to fix Arfrever's case:
def test_isinstance_class(self):
class A:
__metaclass__ = abc.ABCMeta
class OldstyleClass:
pass
self.assertFalse(isinstance(OldstyleClass, A))
self.assertTrue(isinstance(OldstyleClass, type(OldstyleClass)))
self.assertFalse(isinstance(A, OldstyleClass))
# This raises a recursion depth error, but is low-priority:
# self.assertTrue(isinstance(A, abc.ABCMeta))
|
msg11706 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2018-02-24.23:33:24 |
|
This seems to be working now:
PS 272a1> jython
Jython 2.7.2a1+ (default:d74f8c2cd56f, Feb 24 2018, 17:18:53)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_151
Type "help", "copyright", "credits" or "license" for more information.
>>> import abc
>>> class A(abc.ABCMeta): pass
...
>>> print(isinstance(0, abc.ABCMeta))
False
>>> print(issubclass(A, abc.ABCMeta))
True
>>> print(issubclass(abc.ABCMeta, abc.ABCMeta))
True
Close?
|
msg11853 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2018-03-23.22:36:14 |
|
Now apparently fixed, but I don't know at what changeset. Given #msg8398 it was fixed by updates to the stdlib?
|
|
Date |
User |
Action |
Args |
2018-03-23 22:36:14 | jeff.allen | set | status: open -> closed resolution: accepted -> fixed messages:
+ msg11853 |
2018-02-24 23:33:24 | jeff.allen | set | nosy:
+ jeff.allen messages:
+ msg11706 |
2015-11-02 03:21:29 | zyasoft | set | milestone: Jython 2.7.2 |
2014-05-13 20:08:48 | zyasoft | set | nosy:
+ zyasoft messages:
+ msg8398 |
2014-05-13 19:49:42 | gthank | set | nosy:
+ gthank messages:
+ msg8397 |
2014-05-04 20:29:36 | zyasoft | set | resolution: accepted |
2013-05-20 18:08:27 | pjenvey | set | messages:
+ msg8024 |
2013-05-20 09:53:56 | Arfrever | set | nosy:
+ pjenvey |
2013-05-20 09:52:20 | Arfrever | create | |
|