Author petr.viktorin
Recipients petr.viktorin
Date 2021-05-12.13:34:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620826451.12.0.803238632537.issue44116@roundup.psfhosted.org>
In-reply-to
Content
After `_csv.register_dialect` is called, the csv module is alive even after it's removed from sys.modules. It should be garbage-collected.
(It's not that big a deal: unloading _csv isn't something users should do. But it might be hiding a deeper issue.)

The following reproducer (for a debug build of Python) shows an increasing number of refcounts. (Importing `csv` is the easiest way to call _csv._register_dialect with a proper argument):


import sys
import gc

for i in range(10):
    import csv
    del sys.modules['_csv']
    del sys.modules['csv']
    del csv
    gc.collect()

    print(sys.gettotalrefcount())
History
Date User Action Args
2021-05-12 13:34:11petr.viktorinsetrecipients: + petr.viktorin
2021-05-12 13:34:11petr.viktorinsetmessageid: <1620826451.12.0.803238632537.issue44116@roundup.psfhosted.org>
2021-05-12 13:34:11petr.viktorinlinkissue44116 messages
2021-05-12 13:34:10petr.viktorincreate