GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-46920: Remove code made dead long ago with #if 0 by arhadthedev · Pull Request #31681 · python/cpython Conversation
|
| #if 0 | |
| #define PyPARSE_YIELD_IS_KEYWORD 0x0001 | |
| #endif |
Lines 15 to 19 in 8f31bf4
| #if 0 | |
| #define PyPARSE_WITH_IS_KEYWORD 0x0003 | |
| #define PyPARSE_PRINT_IS_FUNCTION 0x0004 | |
| #define PyPARSE_UNICODE_LITERALS 0x0008 | |
| #endif |
Since these constants aren't mentioned anywhere else, I think it's some initial experiment now abandoned.
added on 23 Apr 2020 by c5fc156:
Lines 40 to 49 in 8f31bf4
| #if 0 | |
| static const char * | |
| token_name(int type) | |
| { | |
| if (0 <= type && type <= N_TOKENS) { | |
| return _PyParser_TokenNames[type]; | |
| } | |
| return "<Huh?>"; | |
| } | |
| #endif |
token_name is mentioned nowhere in the CPython codebase too.
added on 20 Nov 2014 by d600951:
Lines 1843 to 1845 in 8f31bf4
| #if 0 | |
| _PyGC_CollectIfEnabled(); | |
| #endif |
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:
Lines 336 to 362 in 8f31bf4
| #if 0 /* not used in this release */ | |
| LOCAL(int) | |
| SRE(info)(SRE_STATE* state, const SRE_CODE* pattern) | |
| { | |
| /* check if an SRE_OP_INFO block matches at the current position. | |
| returns the number of SRE_CODE objects to skip if successful, 0 | |
| if no match */ | |
| const SRE_CHAR* end = (const SRE_CHAR*) state->end; | |
| const SRE_CHAR* ptr = (const SRE_CHAR*) state->ptr; | |
| Py_ssize_t i; | |
| /* check minimal length */ | |
| if (pattern[3] && end - ptr < pattern[3]) | |
| return 0; | |
| /* check known prefix */ | |
| if (pattern[2] & SRE_INFO_PREFIX && pattern[5] > 1) { | |
| /* <length> <skip> <prefix data> <overlap data> */ | |
| for (i = 0; i < pattern[5]; i++) | |
| if ((SRE_CODE) ptr[i] != pattern[7 + i]) | |
| return 0; | |
| return pattern[0] + 2 * pattern[6]; | |
| } | |
| return pattern[0]; | |
| } | |
| #endif |
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 28 Sep 2011 by d63a3b8:
cpython/Python/formatter_unicode.c
Lines 140 to 156 in 8f31bf4
| #if 0 | |
| /* Occasionally useful for debugging. Should normally be commented out. */ | |
| static void | |
| DEBUG_PRINT_FORMAT_SPEC(InternalFormatSpec *format) | |
| { | |
| printf("internal format spec: fill_char %d\n", format->fill_char); | |
| printf("internal format spec: align %d\n", format->align); | |
| printf("internal format spec: alternate %d\n", format->alternate); | |
| printf("internal format spec: sign %d\n", format->sign); | |
| printf("internal format spec: width %zd\n", format->width); | |
| printf("internal format spec: thousands_separators %d\n", | |
| format->thousands_separators); | |
| printf("internal format spec: precision %zd\n", format->precision); | |
| printf("internal format spec: type %c\n", format->type); | |
| printf("\n"); | |
| } | |
| #endif |
DEBUG_PRINT_FORMAT_SPEC is used nowhere, plus putting a debugger breakpoint onto an interesting InternalFormatSpec is more convenient.
added on (already commented out) 11 Dec 2007 by a3534a6:
Lines 519 to 533 in 8f31bf4
| /* | |
| static long | |
| instancemethod_hash(PyObject *self) | |
| { | |
| long x, y; | |
| x = (long)self; | |
| y = PyObject_Hash(PyInstanceMethod_GET_FUNCTION(self)); | |
| if (y == -1) | |
| return -1; | |
| x = x ^ y; | |
| if (x == -1) | |
| x = -2; | |
| return x; | |
| } | |
| */ |
added on 27 Aug 2007 by e226b55:
cpython/Objects/unicodeobject.c
Lines 13660 to 13666 in 8f31bf4
| #if 0 | |
| static PyObject * | |
| unicode__decimal2ascii(PyObject *self) | |
| { | |
| return PyUnicode_TransformDecimalAndSpaceToASCII(self); | |
| } | |
| #endif |
cpython/Objects/unicodeobject.c
Lines 14253 to 14256 in 8f31bf4
| #if 0 | |
| /* These methods are just used for debugging the implementation. */ | |
| {"_decimal2ascii", (PyCFunction) unicode__decimal2ascii, METH_NOARGS}, | |
| #endif |
_decimal2ascii is mentioned nowhere else in the CPython codebase.
added (already commented out) on 8 Mar 2006 by d4c9320:
cpython/Modules/_ctypes/_ctypes.c
Lines 1420 to 1463 in 8f31bf4
| /* | |
| The next three functions copied from Python's typeobject.c. | |
| They are used to attach methods, members, or getsets to a type *after* it | |
| has been created: Arrays of characters have additional getsets to treat them | |
| as strings. | |
| */ | |
| /* | |
| static int | |
| add_methods(PyTypeObject *type, PyMethodDef *meth) | |
| { | |
| PyObject *dict = type->tp_dict; | |
| for (; meth->ml_name != NULL; meth++) { | |
| PyObject *descr; | |
| descr = PyDescr_NewMethod(type, meth); | |
| if (descr == NULL) | |
| return -1; | |
| if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0) { | |
| Py_DECREF(descr); | |
| return -1; | |
| } | |
| Py_DECREF(descr); | |
| } | |
| return 0; | |
| } | |
| static int | |
| add_members(PyTypeObject *type, PyMemberDef *memb) | |
| { | |
| PyObject *dict = type->tp_dict; | |
| for (; memb->name != NULL; memb++) { | |
| PyObject *descr; | |
| descr = PyDescr_NewMember(type, memb); | |
| if (descr == NULL) | |
| return -1; | |
| if (PyDict_SetItemString(dict, memb->name, descr) < 0) { | |
| Py_DECREF(descr); | |
| return -1; | |
| } | |
| Py_DECREF(descr); | |
| } | |
| return 0; | |
| } | |
| */ |
added on 7 Dec 2005 by 8c8836b:
cpython/Modules/_elementtree.c
Lines 39 to 48 in 8f31bf4
| #if 0 | |
| static int memory = 0; | |
| #define ALLOC(size, comment)\ | |
| do { memory += size; printf("%8d - %s\n", memory, comment); } while (0) | |
| #define RELEASE(size, comment)\ | |
| do { memory -= size; printf("%8d - %s\n", memory, comment); } while (0) | |
| #else | |
| #define ALLOC(size, comment) | |
| #define RELEASE(size, comment) | |
| #endif |
In addition, ALLOC() and RELEASE() are removed as unconditional no-ops.
added on 4 Aug 2002 by 00f1e3f:
Lines 285 to 308 in 8f31bf4
| #if 0 | |
| /* Disable support for UTF-16 BOMs until a decision | |
| is made whether this needs to be supported. */ | |
| } else if (ch1 == 0xFE) { | |
| ch2 = get_char(tok); | |
| if (ch2 != 0xFF) { | |
| unget_char(ch2, tok); | |
| unget_char(ch1, tok); | |
| return 1; | |
| } | |
| if (!set_readline(tok, "utf-16-be")) | |
| return 0; | |
| tok->decoding_state = STATE_NORMAL; | |
| } else if (ch1 == 0xFF) { | |
| ch2 = get_char(tok); | |
| if (ch2 != 0xFE) { | |
| unget_char(ch2, tok); | |
| unget_char(ch1, tok); | |
| return 1; | |
| } | |
| if (!set_readline(tok, "utf-16-le")) | |
| return 0; | |
| tok->decoding_state = STATE_NORMAL; | |
| #endif |
/* 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:
Lines 7065 to 7070 in 8f31bf4
| #if 0 /* future keyword */ | |
| if (codeflags & CO_GENERATOR_ALLOWED) { | |
| result = 1; | |
| cf->cf_flags |= CO_GENERATOR_ALLOWED; | |
| } | |
| #endif |
The /* future keyword */ is quite overdue already.
added on 23 Jun 2001 by 01dfdb3:
Lines 41 to 58 in 8f31bf4
| #if 0 | |
| #include <sys/types.h> | |
| #include <sys/param.h> | |
| #include <sys/sysctl.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <arpa/inet.h> | |
| #include <arpa/nameser.h> | |
| #include <netdb.h> | |
| #include <resolv.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <stddef.h> | |
| #include <ctype.h> | |
| #include <unistd.h> | |
| #include "addrinfo.h" | |
| #endif |
Lines 37 to 49 in 8f31bf4
| #if 0 | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <arpa/inet.h> | |
| #include <arpa/nameser.h> | |
| #include <netdb.h> | |
| #include <resolv.h> | |
| #include <string.h> | |
| #include <stddef.h> | |
| #include "addrinfo.h" | |
| #endif |
added on 14 Jul 1998 by 43ff868:
Lines 3443 to 3448 in 8f31bf4
| #if 0 | |
| /* This was not a good idea; through <Destroy> bindings, | |
| Tcl_Finalize() may invoke Python code but at that point the | |
| interpreter and thread state have already been destroyed! */ | |
| Py_AtExit(Tcl_Finalize); | |
| #endif |
git grep "#if 1" gives the following:
added on 20 Nov 2014 by d600951:
Line 2427 in 8f31bf4
| #if 1 /* Disable this if you have trouble debugging bootstrap stuff */ |
After seven years, no trouble was found so this always-true guard has no use.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There is more potential dead code, though I don't know if it can be safely removed.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't think all of these should be removed. Some of them look genuinely useful for debugging, others are essentially multi-line comments. In any event, they should be individually considered. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ericvsmith I agree that the debugging share of code appeared for a reason so I'm open to evaluation and ready to exclude parts from the PR. BTW I decided to remove that potentially-not-dead share because it either requires some missing harness or looks finished to serve its time after a tested feature was stabilized long ago. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| */ | ||
| #if 0 | ||
| _PyGC_CollectIfEnabled(); | ||
| #endif |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I spent significant time to rework how the GC is called. The last call is now in interpreter_clear() of pystate.c.
See: https://pythondev.readthedocs.io/finalization.html
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I often work on the Python initialization and finalization code and I never needed to disble the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * XXX the exception and consequent unexpected failures). I've also | ||
| * XXX seen segfaults then, after adding print statements to the | ||
| * XXX Python code getting called. | ||
| */ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This comment is oudated and must be removed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mdickinson @ericvsmith: Would you mind to review again the PR? If would prefer a second approval since there was disagreement on the first reviews. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /* For debugging purposes only */ | ||
| #if 0 | ||
| static void | ||
| dump_instr(struct instr *i) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
These have been useful occasionally, so I would rather not remove them.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Restored.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Re: fastsearch.h, I'd like to keep those debugging prints. If a bug or performance curiosity ever shows up, it would be nice to flip the 0 to a 1, recompile, and then be able to tell exactly what's going on, step-by-step. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I don't have any strong opinion on any of these changes besides the vendorised code changes that were already addressed (for which thank you, @arhadthedev!). I'm personally happy for the rest of the changes to go through, but other people's concerns should be taken into account. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
No. The comment is simply wrong: it's testing the behavior of "if 0:" in Python, nothing to do with "#if 0" in C. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Except for ones that are out of date, wrong, or misleading, I don't see much need in deleting any of these. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I found three more functions disabled by commenting them out. Since they were put into a comment from the moment of being introduced, I suspect they are obsolete so removed them too:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It would be easier to review this if you opened new issues when you found other code you want removed. Ideally (for me, at least), each piece of code you want to remove would be in a separate PR, so they could be easily reviewed and merged. I'm not sure if it's worth doing that at this point, but because there are so many files that are touched in this PR, I don't think I can give it a proper review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Initially I didn't want to create a dosen of small PRs but now I see your point. I also got it that small PRs allow to get the most of pieces merged sooner without being blocked by more ambivalent ones. I'll make the split tomorrow. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ericvsmith I split this PR into smaller ones to not block merging of non-controversial pieces: GH-31811, GH-31812, GH-31813, and GH-31814. cc: @mdickinson |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@vstinner Thanks for merging all the commits. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.