[issue28649] refleak in typing.py

Ivan Levkivskyi report at bugs.python.org
Thu Nov 10 03:43:50 EST 2016


Ivan Levkivskyi added the comment:

> BTW, if I set maxsize=100000 for typing lru_cache, test_generic_forward_ref crashes in refleak-test mode. Maybe this is another bug...

This one is also related to the mentioned in my previous message. Namely, forward references are only evaluated once. However, in refleak hunting mode tests are repeated multiple times, and every time test_generic_forward_ref is called, this code:

    class CC: ...

creates a new local class, while forward ref is still pointing to an old one.

There are two options:
* keep this behaviour and update the test to use a globally defined class;
* change this and re-evaluate forward refs every times.

However I would vote for a compromise solution: if the ``locals`` argument is not given, just use the evaluated value. But if a user gives non-None ``locals`` argument then that user most probably wants to re-evaluate the forward ref locally.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28649>
_______________________________________


More information about the Python-bugs-list mailing list