[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2021-12-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is still reproducible if increase the depth. In 3.8-3.10 it needs 329 nested 
classes, in 3.11 -- 496.

Seems the limit is sys.getrecursionlimit()//k - 4, where k=4 in 3.7 and older, 
k=3 in 3.8-3.10, and k=2 in 3.11. It is much better than was initially, but the 
ideal is k=1.

--
resolution: out of date -> 
stage: resolved -> 
status: closed -> open
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.5, Python 
3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2021-12-11 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2021-12-05 Thread Irit Katriel


Irit Katriel  added the comment:

I am unable to reproduce this on 3.11. Is it still a problem?

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-12 Thread Jamie Bliss

Jamie Bliss added the comment:

I consider it debatable as to if this is a bug in ABC (for using recursion in a 
way that limits class tree depth) or in CPython (for accounting recursion in 
such a way you can get significantly shallower stacks).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-12 Thread Jamie Bliss

Changes by Jamie Bliss :


--
nosy: +astronouth7303

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-10 Thread Anthony Scopatz

Anthony Scopatz added the comment:

It certainly seems related. Attached is an image that displays the scaling of 
the cache example.  The full notebook that generated this image is at [1]. The 
notebook shows that it does seem to converge towards a value of 1/6th. 

1. https://gist.github.com/scopatz/29b94326ec1f10056d27e9d9434b240a

--
Added file: http://bugs.python.org/file46252/fibo.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-10 Thread Raymond Hettinger

Changes by Raymond Hettinger :


Added file: http://bugs.python.org/file46251/cache_example.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Not sure if this is related, but I have a simple Cache class that gets a 
recursion error at a depth of about 166 calls (a sixth of the expected 1000).  
I suspect that the reason is the many of the steps individually add to the 
recursion depth causing the recursion limit to be reached at some integer 
multiple faster than would be expected.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-09 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka
versions:  -Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29221] ABC Recursion Error on isinstance() with less than recursion limit class hierarchy depth

2017-01-09 Thread Anthony Scopatz

New submission from Anthony Scopatz:

Classes that have an abstract base class somewhere in their hierarchy have a 
significantly reduced depth with respect to the recursion limit. In the 
attached minimal example, the class hierarchy is only able to be 245 deep past 
the ABC before a recursion error, rather than the expected 1000. 

Also disconcerting is that this recursion error is triggered by unrelated 
objects, namely an isinstance() check. This means that the error can happen at 
any point in the interpreter simply because the offending class exists. You 
don't need to call isinstance() with the offending class.

This is likely due to the way the way that ABCMeta.__subclasscheck__(). This 
issue can be avoided by either:

1. Not having a deep-ish hierarchy, or 
2. Calling the trigger, isinstance(), each time a new class is created (inside 
of the loop).

Option (2) works because it tricks ABCMeta into putting each subclass class 
into its internal cache of subclasses. This fix is undesirable in general 
because what triggers the error, in general may not be known and can cross 
package boundaries.

Note: I only tested this on Python v3.4 and v3.5, but it presumably affects all 
currently supported versions of Python.

--
components: Library (Lib)
files: abc_rec_fail.py
messages: 285090
nosy: Anthony Scopatz
priority: normal
severity: normal
status: open
title: ABC Recursion Error on isinstance() with less than recursion limit class 
hierarchy depth
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46236/abc_rec_fail.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com