New issue 2612: gc.get_referrers doesn't always find instance of referrer class
https://bitbucket.org/pypy/pypy/issues/2612/gcget_referrers-doesnt-always-find
Daniel Sutcliffe:
This problem is intermittent in that in can come and go away with code
structure but when code is unchanged results are repeatable.
Reproduced using official Docker pypy container and using squeaky-pl's portable
PyPy with version 5.8.0 build for Python 2.7.13.
Actually initially found trying to get Twisted test suite passing under PyPy
where the twisted.test.test_rebuild.RebuildTests.testFileRebuild FAILs but
included is the smallest bit of code I have managed to get this to fail under.
Two files required as problem doesn't seem to occur with class in `__main__`
__BC.py__
```
#!python
class B(object):
def m(self):
return 'b1'
```
__referrers.py__
```
#!python
import BC
import gc
b = BC.B()
# Doesn't find
for r in gc.get_referrers(BC.B):
if getattr(r, '__class__', None) is BC.B:
print('get_referrers finds {0}'.format(r))
# Finds
for r in gc.get_objects():
if getattr(r, '__class__', None) is BC.B:
print('get_objects finds {0}'.format(r))
```
The last 4 lines just there to show get_objects always seems to work - used as
workaround in my Twisted fork.
As stated, I have seen `gc.get_referrers` many times return the correct result,
often just prior to including one more line of code before the call so this is
obviously something a little weird - hope the issue is not too difficult to
reproduce and find with this info, I must admit to having not looked at PyPy gc
code
Cheers
/dan
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue