Branch: refs/heads/2.7 Home: https://github.com/python/cpython Commit: 28288bebaf61269d1e26bb0795c2de6b481e1cf0 https://github.com/python/cpython/commit/28288bebaf61269d1e26bb0795c2de6b481e1cf0 Author: Stéphane Wirtel <stephane at wirtel.be> Date: 2017年06月10日 (2017年6月10日) Changed paths: M Modules/bz2module.c Log Message: ----------- 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 at gmail.com> * Create bz2module.c Fix after the review of Victor Stinner