This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Modify test_codecs to use the new codecs.unregister() function
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pablogsal, shihai1991, vstinner
Priority: normal Keywords: patch

Created on 2020-10-03 09:37 by shihai1991, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 22513 merged shihai1991, 2020-10-03 09:39
PR 22961 closed pablogsal, 2020-10-25 06:06
PR 22973 merged shihai1991, 2020-10-25 15:49
Messages (6)
msg377863 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2020-10-03 09:37
After PR22360 merged, we can move the codecs' register operation to testcases.
msg378708 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-10-16 08:34
New changeset c9f696cb96d1c362d5cad871f61da520572d9b08 by Hai Shi in branch 'master':
bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)
https://github.com/python/cpython/commit/c9f696cb96d1c362d5cad871f61da520572d9b08
msg379565 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-10-25 06:01
Commit c9f696cb96d1c362d5cad871f61da520572d9b08 introduced a reference leak in the test suite. See https://bugs.python.org/issue42145:

c9f696cb96d1c362d5cad871f61da520572d9b08 is the first bad commit
commit c9f696cb96d1c362d5cad871f61da520572d9b08
Author: Hai Shi <shihai1992@gmail.com>
Date:   Fri Oct 16 16:34:15 2020 +0800

    bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)

Reverting the commit eliminates the problem:

rences, sum=12
test_io leaked [1, 1, 1, 1] memory blocks, sum=4
test_io failed

== Tests result: FAILURE ==

1 test failed:
    test_io

Total duration: 397 ms
Tests result: FAILURE
g
~/github/python/master master|bisect*
❯ git revert c9f696cb96d1c362d5cad871f61da520572d9b08
Auto-merging Lib/test/test_codecs.py
[master f3de7c00b4] Revert "bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)"
 7 files changed, 112 insertions(+), 16 deletions(-)

~/github/python/master master|bisect* ⇡
❯ make -j -s
 CC='gcc -pthread' LDSHARED='gcc -pthread -shared    ' OPT='-g -Og -Wall'       _TCLTK_INCLUDES='' _TCLTK_LIBS=''       ./python -E ./setup.py -q build

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd
time


~/github/python/master master|bisect* ⇡
❯ ./python -m test test_io -m test.test_io.CTextIOWrapperTest.test_read_one_by_one -R :
0:00:00 load avg: 2.57 Run tests sequentially
0:00:00 load avg: 2.57 [1/1] test_io
beginning 9 repetitions
123456789
.........

== Tests result: SUCCESS ==

1 test OK.

Total duration: 455 ms
Tests result: SUCCESS

    * Move the codecs' (un)register operation to testcases.
    * Remove _codecs._forget_codec() and _PyCodec_Forget()

 Lib/test/test_charmapcodec.py    |  7 +++++--
 Lib/test/test_codecs.py          | 25 +++----------------------
 Lib/test/test_io.py              |  7 +++----
 Lib/test/test_unicode.py         |  5 ++++-
 Modules/_codecsmodule.c          | 20 --------------------
 Modules/clinic/_codecsmodule.c.h | 39 +--------------------------------------
 Python/codecs.c                  | 25 -------------------------
 7 files changed, 16 insertions(+), 112 deletions(-)
msg379567 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-10-25 06:03
AS this is masking other issues in the build bots, we need to revert the commit unless is fixed in 24 hours per the buildbot workflow
msg379584 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2020-10-25 15:50
> AS this is masking other issues in the build bots, we need to revert the commit unless is fixed in 24 hours per the buildbot workflow

Thanks, Pablo. I checked that only test_io.py have resource leak.
I create PR-22973, pls take a look if you have free time, thanks.
msg379598 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-10-25 18:38
New changeset 14cdc215aa952d280c18626005d3aff967901d92 by Hai Shi in branch 'master':
bpo-41919: Avoid resource leak in test_io (GH-22973)
https://github.com/python/cpython/commit/14cdc215aa952d280c18626005d3aff967901d92
History
Date User Action Args
2022-04-11 14:59:36adminsetgithub: 86085
2020-10-25 18:38:56pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-10-25 18:38:37pablogsalsetmessages: + msg379598
2020-10-25 15:50:45shihai1991setmessages: + msg379584
2020-10-25 15:49:06shihai1991setpull_requests: + pull_request21888
2020-10-25 06:06:26pablogsalsetstage: resolved -> patch review
pull_requests: + pull_request21877
2020-10-25 06:03:55pablogsalsetstatus: closed -> open
resolution: fixed -> (no value)
2020-10-25 06:03:51pablogsalsetmessages: + msg379567
2020-10-25 06:01:58pablogsalsetnosy: + pablogsal
messages: + msg379565
2020-10-16 08:34:56vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-10-16 08:34:47vstinnersetmessages: + msg378708
2020-10-03 17:03:33vstinnersettitle: Move the codecs.register operation to testcases -> Modify test_codecs to use the new codecs.unregister() function
2020-10-03 09:40:12shihai1991settitle: Move the codecs' register operation to testcases -> Move the codecs.register operation to testcases
2020-10-03 09:39:36shihai1991setkeywords: + patch
stage: patch review
pull_requests: + pull_request21522
2020-10-03 09:37:07shihai1991create