diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 481de85fde3adb..b2914290520b70 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1418,49 +1418,10 @@ static PyGetSetDef WCharArray_getsets[] = { }; /* - The next three functions copied from Python's typeobject.c. + The next function 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. + Arrays of characters have 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; -} -*/ static int add_getset(PyTypeObject *type, PyGetSetDef *gsp) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index f54c28447ca8fa..1794124aa45add 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -36,17 +36,6 @@ /* -------------------------------------------------------------------- */ -#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 - /* compiler tweaks */ #if defined(_MSC_VER) #define LOCAL(type) static __inline type __fastcall @@ -301,7 +290,6 @@ create_new_element(PyObject* tag, PyObject* attrib) self->weakreflist = NULL; - ALLOC(sizeof(ElementObject), "create element"); PyObject_GC_Track(self); if (attrib != NULL && !is_empty_dict(attrib)) { @@ -676,7 +664,6 @@ element_dealloc(ElementObject* self) */ element_gc_clear(self); - RELEASE(sizeof(ElementObject), "destroy element"); Py_TYPE(self)->tp_free((PyObject *)self); Py_TRASHCAN_END } diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index cbef9ce0066db5..cd167fd81250ea 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -3440,11 +3440,5 @@ PyInit__tkinter(void) return NULL; } -#if 0 - /* This was not a good idea; through 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 return m; } diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c index 5aaa6e7c8144f7..2ccc8494cb9ebe 100644 --- a/Modules/getaddrinfo.c +++ b/Modules/getaddrinfo.c @@ -38,25 +38,6 @@ * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag. */ -#if 0 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "addrinfo.h" -#endif - #if defined(__KAME__) && defined(ENABLE_IPV6) # define FAITH #endif diff --git a/Modules/getnameinfo.c b/Modules/getnameinfo.c index f014c11ae157e4..a3f00fe74a0955 100644 --- a/Modules/getnameinfo.c +++ b/Modules/getnameinfo.c @@ -34,20 +34,6 @@ * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). */ -#if 0 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "addrinfo.h" -#endif - #define SUCCESS 0 #define YES 1 #define NO 0 diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h index 322f66fb4da6c7..32469cd161cf3b 100644 --- a/Modules/sre_lib.h +++ b/Modules/sre_lib.h @@ -333,34 +333,6 @@ SRE(count)(SRE_STATE* state, const SRE_CODE* pattern, Py_ssize_t maxcount) return ptr - (SRE_CHAR*) state->ptr; } -#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) { - /* */ - 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 macros below should be used to protect recursive SRE(match)() * calls that *failed* and do *not* return immediately (IOW, those * that will backtrack). Explaining: diff --git a/Objects/classobject.c b/Objects/classobject.c index 3b1c25394f152a..c75ba572b96245 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -516,22 +516,6 @@ instancemethod_repr(PyObject *self) return result; } -/* -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; -} -*/ - PyDoc_STRVAR(instancemethod_doc, "instancemethod(function)\n\ \n\ @@ -569,7 +553,7 @@ PyTypeObject PyInstanceMethod_Type = { 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - 0, /*(hashfunc)instancemethod_hash, tp_hash */ + 0, /* tp_hash */ instancemethod_call, /* tp_call */ 0, /* tp_str */ instancemethod_getattro, /* tp_getattro */ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 908ad514925999..2d4181a7d6d9f4 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13657,14 +13657,6 @@ unicode_zfill_impl(PyObject *self, Py_ssize_t width) return u; } -#if 0 -static PyObject * -unicode__decimal2ascii(PyObject *self) -{ - return PyUnicode_TransformDecimalAndSpaceToASCII(self); -} -#endif - PyDoc_STRVAR(startswith__doc__, "S.startswith(prefix[, start[, end]]) -> bool\n\ \n\ @@ -14250,11 +14242,6 @@ static PyMethodDef unicode_methods[] = { UNICODE___FORMAT___METHODDEF UNICODE_MAKETRANS_METHODDEF UNICODE_SIZEOF_METHODDEF -#if 0 - /* These methods are just used for debugging the implementation. */ - {"_decimal2ascii", (PyCFunction) unicode__decimal2ascii, METH_NOARGS}, -#endif - {"__getnewargs__", unicode_getnewargs, METH_NOARGS}, {NULL, NULL} }; diff --git a/Parser/pegen.c b/Parser/pegen.c index 95dc54dd6040fa..143461d44a1a4a 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -37,17 +37,6 @@ _PyPegen_byte_offset_to_character_offset(PyObject *line, Py_ssize_t col_offset) return size; } -#if 0 -static const char * -token_name(int type) -{ - if (0 <= type && type <= N_TOKENS) { - return _PyParser_TokenNames[type]; - } - return ""; -} -#endif - // Here, mark is the start of the node, while p->mark is the end. // If node==NULL, they should be the same. int diff --git a/Parser/pegen.h b/Parser/pegen.h index 77d5ca8418a97b..29acb324274d85 100644 --- a/Parser/pegen.h +++ b/Parser/pegen.h @@ -6,18 +6,8 @@ #include #include -#if 0 -#define PyPARSE_YIELD_IS_KEYWORD 0x0001 -#endif - #define PyPARSE_DONT_IMPLY_DEDENT 0x0002 -#if 0 -#define PyPARSE_WITH_IS_KEYWORD 0x0003 -#define PyPARSE_PRINT_IS_FUNCTION 0x0004 -#define PyPARSE_UNICODE_LITERALS 0x0008 -#endif - #define PyPARSE_IGNORE_COOKIE 0x0010 #define PyPARSE_BARRY_AS_BDFL 0x0020 #define PyPARSE_TYPE_COMMENTS 0x0040 diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 6698d35ea94276..90dc8a2e369714 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -282,30 +282,6 @@ check_bom(int get_char(struct tok_state *), unget_char(ch1, tok); return 1; } -#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 } else { unget_char(ch1, tok); return 1; diff --git a/Python/ceval.c b/Python/ceval.c index 915ab9313a95af..47fd5bf87e0608 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -7062,12 +7062,6 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf) result = 1; cf->cf_flags |= compilerflags; } -#if 0 /* future keyword */ - if (codeflags & CO_GENERATOR_ALLOWED) { - result = 1; - cf->cf_flags |= CO_GENERATOR_ALLOWED; - } -#endif } return result; } diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 0c21301fb9ed4b..a1e50e20c9d8c6 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -137,24 +137,6 @@ typedef struct { Py_UCS4 type; } InternalFormatSpec; -#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 - /* ptr points to the start of the format_spec, end points just past its end. diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 9228778d6bd04c..11b0f20bba72b6 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1825,25 +1825,6 @@ Py_FinalizeEx(void) status = -1; } - /* Collect final garbage. This disposes of cycles created by - * class definitions, for example. - * XXX This is disabled because it caused too many problems. If - * XXX a __del__ or weakref callback triggers here, Python code has - * XXX a hard time running, because even the sys module has been - * XXX cleared out (sys.stdout is gone, sys.excepthook is gone, etc). - * XXX One symptom is a sequence of information-free messages - * XXX coming from threads (if a __del__ or callback is invoked, - * XXX other threads can execute too, and any exception they encounter - * XXX triggers a comedy of errors as subsystem after subsystem - * XXX fails to find what it *expects* to find in sys to help report - * 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. - */ -#if 0 - _PyGC_CollectIfEnabled(); -#endif - /* Disable tracemalloc after all Python objects have been destroyed, so it is possible to use tracemalloc in objects destructor. */ _PyTraceMalloc_Fini(); @@ -2424,7 +2405,6 @@ init_sys_streams(PyThreadState *tstate) _PySys_SetAttr(&_Py_ID(stdout), std); Py_DECREF(std); -#if 1 /* Disable this if you have trouble debugging bootstrap stuff */ /* Set sys.stderr, replaces the preliminary stderr */ fd = fileno(stderr); std = create_stdio(config, iomod, fd, 1, "", @@ -2455,7 +2435,6 @@ init_sys_streams(PyThreadState *tstate) goto error; } Py_DECREF(std); -#endif goto done;