]> granicus.if.org Git - python/commit
bpo-30614: testInitNonExistentFile() of test_bz2 leaks references (#2033)
authorStéphane Wirtel <stephane@wirtel.be>
Sat, 10 Jun 2017 12:36:57 +0000 (14:36 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Sat, 10 Jun 2017 12:36:57 +0000 (14:36 +0200)
commit28288bebaf61269d1e26bb0795c2de6b481e1cf0
treed7ad6c9e2c4ae3c7945e5503bd821c562d8706d7
parent3c7b67bb34bc537b6c0dd9c6e1e4a07dc227b467
bpo-30614: testInitNonExistentFile() of test_bz2 leaks references (#2033)

* bpo-30614: testInitNonExistentFile() of test_bz2 leaks references

Extract the code of BZ2File_dealloc and create a new BZ2File_clear()
function. Call BZ2File_clear() in BZ2File_dealloc().

Define BZ2File_clear() as tp_clear.

Move the lock initialization before the "self->file =
PyObject_CallFunction" in BZ2File_init() and check the lock is not
created twice.

Call BZ2File_clear() in BZ2File_init() after the init of the lock

Co-Authored-By: Victor Stinner <victor.stinner@gmail.com>
* Create bz2module.c

Fix after the review of Victor Stinner
Modules/bz2module.c