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: Remove code made dead long ago with #if 0
Type: enhancement Stage: resolved
Components: Extension Modules, Interpreter Core, Unicode Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: arhadthedev, ezio.melotti, mark.dickinson, vstinner
Priority: normal Keywords: patch

Created on 2022-03-04 12:13 by arhadthedev, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31681 closed arhadthedev, 2022-03-04 12:13
PR 31811 merged arhadthedev, 2022-03-11 06:33
PR 31812 merged arhadthedev, 2022-03-11 06:37
PR 31813 merged arhadthedev, 2022-03-11 06:40
PR 31814 merged arhadthedev, 2022-03-11 06:41
Messages (8)
msg414519 - (view) Author: Oleg Iarygin (arhadthedev) * Date: 2022-03-04 12:13
`git grep "#if 0"` gives the following occurences of dead code (analyzed with `git blame`, removed by a linked pull request):

- added on 27 Apr 2020 by 2b74c83: Parser/pegen.h:9, Parser/pegen.h:15. Since these constants aren't mentioned anywhere else, I think it's some initial experiment now abandoned.

- added on 23 Apr 2020 by c5fc156: Parser/pegen.c:40. `token_name` is mentioned nowhere in the CPython codebase too.

- added on 20 Nov 2014 by d600951: Python/pylifecycle.c:1843 with the following note:

  > XXX This is disabled because it caused too many problems.  If a __del__ or weakref callback triggers here, Python code has a hard time running, because even the sys module has been cleared out (sys.stdout is gone, sys.excepthook is gone, etc).  One symptom is a sequence of information-free messages coming from threads (if a __del__ or callback is invoked, other threads can execute too, and any exception they encounter triggers a comedy of errors as subsystem after subsystem fails to find what it *expects* to find in sys to help report the exception and consequent unexpected failures).  I've also seen segfaults then, after adding print statements to the Python code getting called.

  So the call is faulty for seven years with no progress.

- added on 26 Oct 2013 by 8444ebb: Modules/sre_lib.h336. The Secret Labs' Regular Expression Engine was vendored nine years ago so `not used in this release` is permanent and can be removed.

- added on 25 Aug 2012 by 2543756: Modules/_ctypes/libffi_osx/x86/x86-ffi64.c:155

- added on 21 Mar 2012 by 1919b7e: Modules/_decimal/libmpdec/sixstep.c:120, Modules/_decimal/libmpdec/sixstep.c:157, Modules/_decimal/libmpdec/fourstep.c:189, Modules/_decimal/libmpdec/fourstep.c:220

- added on 28 Sep 2011 by d63a3b8: Python/formatter_unicode.c:140. `DEBUG_PRINT_FORMAT_SPEC` is used nowhere, plus putting a debugger breakpoint onto an interesting `InternalFormatSpec` is more convenient.

- added on 5 Mar 2008 by 7864476: Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c:40

- added on 27 Aug 2007 by e226b55: Objects/unicodeobject.c:13660, Objects/unicodeobject.c:14253. `_decimal2ascii` is mentioned nowhere else in the CPython codebase.

- added on 11 Aug 2006 by 0e3f591: Python/compile.c:7873. Neither `dump_instr` nor `dump_basicblock` are used.

- added on 7 Dec 2005 by 8c8836b: Modules/_elementtree.c:39. In addition, `ALLOC()` and `RELEASE()` are removed as unconditional no-ops.

- added on 4 Aug 2002 by 00f1e3f: Parser/tokenizer.c:285. "/* Disable support for UTF-16 BOMs until a decision is made whether this needs to be supported */" - I have every reason to believe that the decision was Never Ever.

- added on 23 Mar 2002 by c24ea08: Python/ceval.c:7065-L7070. The "/* future keyword */" is quite overdue already.

- added on 23 Jun 2001 by 01dfdb3: Modules/getaddrinfo.c:41, Modules/getnameinfo.c:37

- added on 14 Jul 1998 by 43ff868: Modules/_tkinter.c:3443
msg414520 - (view) Author: Oleg Iarygin (arhadthedev) * Date: 2022-03-04 12:19
Also forgot to add that git grep "#if 1" gives the following:

- added on 20 Nov 2014 by d600951: cpython/Python/pylifecycle.c:2427. "/* Disable this if you have trouble debugging bootstrap stuff */" - after seven years, no trouble was found so this always-true guard has no use.
msg414596 - (view) Author: Oleg Iarygin (arhadthedev) * Date: 2022-03-05 20:59
I reverted my changes in Modules/_ctypes/libffi_osx/x86/x86-ffi64.c and Modules/_decimal/libmpdec/*step.c to not disturb third-party vendored libraries.

As a result, macOS component is no longer affected along with the corresponding experts in a nosy list.
msg415153 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-03-14 16:02
New changeset e885ac3d5f2fd83617ab75a098aab269b7a446c3 by Oleg Iarygin in branch 'main':
bpo-46920: Remove code that has no explainer why it was disabled (GH-31814)
https://github.com/python/cpython/commit/e885ac3d5f2fd83617ab75a098aab269b7a446c3
msg415154 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-03-14 16:03
New changeset a52f82baf246e2fbbc58fe03ef7a51f3cc9514e1 by Oleg Iarygin in branch 'main':
 bpo-46920: Remove disabled debug code added decades ago and likely unnecessary (GH-31812)
https://github.com/python/cpython/commit/a52f82baf246e2fbbc58fe03ef7a51f3cc9514e1
msg415155 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-03-14 16:04
New changeset 13b041222399152acb555337572bd1d571734984 by Oleg Iarygin in branch 'main':
bpo-46920: Remove code that has explainers why it was disabled (GH-31813)
https://github.com/python/cpython/commit/13b041222399152acb555337572bd1d571734984
msg415156 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-03-14 16:05
Can this issue be closed? Or is there remaining dead code that you want to remove?
msg415166 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-03-14 17:03
Thanks Oleg Iarygin for the cleanup!
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 91076
2022-03-14 17:03:06vstinnersetmessages: + msg415166
2022-03-14 16:58:01arhadthedevsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-14 16:05:14vstinnersetmessages: + msg415156
2022-03-14 16:04:26vstinnersetmessages: + msg415155
2022-03-14 16:03:30vstinnersetmessages: + msg415154
2022-03-14 16:02:49vstinnersetmessages: + msg415153
2022-03-11 06:41:13arhadthedevsetpull_requests: + pull_request29912
2022-03-11 06:40:30arhadthedevsetpull_requests: + pull_request29911
2022-03-11 06:37:16arhadthedevsetpull_requests: + pull_request29910
2022-03-11 06:33:09arhadthedevsetpull_requests: + pull_request29909
2022-03-05 20:59:40arhadthedevsetnosy: - ronaldoussoren, ned.deily
messages: + msg414596
components: - macOS
2022-03-05 16:21:28mark.dickinsonsetnosy: + mark.dickinson
2022-03-04 12:19:47arhadthedevsetmessages: + msg414520
2022-03-04 12:13:43arhadthedevsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29800
2022-03-04 12:13:16arhadthedevcreate