PyScripter debugger increases reference count

18 views
Skip to first unread message

o pals

unread,
Sep 30, 2015, 7:29:48 AM9/30/15
to PyScripter
Dear group,

the following simple script:

from __future__ import print_function
import gc
class Object:
     def __init__(self):
         self.data = True
     def __del__(self):
         print("Object.__del__ called")
test = Object()
print("get_referrers to test = ", len(gc.get_referrers(test)))
print("after break points")  # set break point here
print("get_referrers to test = ", len(gc.get_referrers(test)))
print("del test object")
del test
print("finished")


run with the external debugger of  PyScripter 2.6.0 x64 with Python 2.7.10 with no break points set, deletes test before finishing the script, as expected - as the output is:

get_referrers to test =  1
after break points
get_referrers to test =  1
del test object
Object.__del__ called
finished


However, with a break point set at the line print("after break points"), test gets deleted only upon interpreter shutdown - as the output is:

get_referrers to test =  1
after break points
get_referrers to test =  2
del test object
finished

>>> Object.__del__ called

This probably means that the PyScripter (external) debugger increases the reference count of test if a break point is set (and it thus displays globals() and locals()), without ever freeing it. Calling gc.collect() does not help. Is there any work-around that allows for deleting test before interpreter shutdown?

Thanks,
the opals team.

Reply all
Reply to author
Forward
0 new messages