[issue43359] Dead assignment in Py_UniversalNewlineFgets
Alex Henrie added the comment: Hi Victor, just so we're all on the same page, removing the line does not trigger a compiler warning. The comment on this line is misleading. -- ___ Python tracker <https://bugs.python.org/issue43359> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39523] Unnecessary variable assignment and initial loop check in pysqlite_cursor_executescript
Change by Alex Henrie : -- keywords: +patch pull_requests: +17682 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18305 ___ Python tracker <https://bugs.python.org/issue39523> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39523] Unnecessary variable assignment and initial loop check in pysqlite_cursor_executescript
New submission from Alex Henrie : pysqlite_cursor_executescript currently has the following while loop: /* execute statement, and ignore results of SELECT statements */ rc = SQLITE_ROW; while (rc == SQLITE_ROW) { rc = pysqlite_step(statement, self->connection); if (PyErr_Occurred()) { (void)sqlite3_finalize(statement); goto error; } } This can and should be rewritten as a do-while loop to avoid having to initialize rc to SQLITE_ROW and then check its value knowing that the value check will succeed. -- components: Library (Lib) messages: 361200 nosy: alex.henrie priority: normal severity: normal status: open title: Unnecessary variable assignment and initial loop check in pysqlite_cursor_executescript type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39523> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39496] Inelegant loops in Modules/_sqlite/cursor.c
Alex Henrie added the comment: Sorry about that, I didn't notice that GCC's -Wall option emits a warning about this. I just added the extra sets of parentheses. -- ___ Python tracker <https://bugs.python.org/issue39496> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39496] Inelegant loops in Modules/_sqlite/cursor.c
Alex Henrie added the comment: You're right, that's even better. I forgot that the equals operator also returns the variable's new value. I just updated my pull request :-) -- ___ Python tracker <https://bugs.python.org/issue39496> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39497] Unused variable script_str in pysqlite_cursor_executescript
Change by Alex Henrie : -- keywords: +patch pull_requests: +17646 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18271 ___ Python tracker <https://bugs.python.org/issue39497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39497] Unused variable script_str in pysqlite_cursor_executescript
New submission from Alex Henrie : The function pysqlite_cursor_executescript defines a variable called script_str, initializes it to NULL, and calls Py_XDECREF on it. However, this variable has been unused since August 2007: https://github.com/python/cpython/commit/6d21456137836b8acd551cf6a51999ad4ff10a91#diff-26f74db3527991715b482a5ed2603870L752 -- components: Library (Lib) messages: 361008 nosy: alex.henrie priority: normal severity: normal status: open title: Unused variable script_str in pysqlite_cursor_executescript type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39497> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39496] Inelegant loops in Modules/_sqlite/cursor.c
Change by Alex Henrie : -- keywords: +patch pull_requests: +17645 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18270 ___ Python tracker <https://bugs.python.org/issue39496> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39496] Inelegant loops in Modules/_sqlite/cursor.c
New submission from Alex Henrie : pysqlite_cursor_fetchall currently has the following bit of code: /* just make sure we enter the loop */ row = (PyObject*)Py_None; while (row) { row = pysqlite_cursor_iternext(self); if (row) { PyList_Append(list, row); Py_DECREF(row); } } This can and should be rewritten as a for loop to avoid the unnecessary initialization to Py_None and the redundant if statement inside the loop. pysqlite_cursor_fetchmany has the same problem. -- components: Library (Lib) messages: 361006 nosy: alex.henrie priority: normal severity: normal status: open title: Inelegant loops in Modules/_sqlite/cursor.c type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39496> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39494] Extra null terminators in keyword arrays in sqlite module
Change by Alex Henrie : -- keywords: +patch pull_requests: +17644 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18267 ___ Python tracker <https://bugs.python.org/issue39494> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39494] Extra null terminators in keyword arrays in sqlite module
New submission from Alex Henrie : Modules/_sqlite/cursor.c currently has the following variable declaration: static char *kwlist[] = {"size", NULL, NULL}; The second null terminator is unnecessary and detrimental in that it makes the code harder to read and understand. Modules/_sqlite/module.c has two additional kwlist variables with the same problem. -- components: Library (Lib) messages: 361001 nosy: alex.henrie priority: normal severity: normal status: open title: Extra null terminators in keyword arrays in sqlite module type: resource usage versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39494> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39307] Memory leak in parsetok
Change by Alex Henrie : -- keywords: +patch pull_requests: +17363 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17953 ___ Python tracker <https://bugs.python.org/issue39307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39307] Memory leak in parsetok
New submission from Alex Henrie : The parsetok function currently contains the following code: if (!growable_comment_array_init(_ignores, 10)) { err_ret->error = E_NOMEM; PyTokenizer_Free(tok); return NULL; } if ((ps = PyParser_New(g, start)) == NULL) { err_ret->error = E_NOMEM; PyTokenizer_Free(tok); return NULL; } If PyParser_New fails, there is a memory leak because growable_comment_array_deallocate is not called on type_ignores. -- components: Interpreter Core messages: 359821 nosy: alex.henrie priority: normal severity: normal status: open title: Memory leak in parsetok type: resource usage versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39272] Dead assignment in _ssl__SSLContext_load_verify_locations_impl
Change by Alex Henrie : -- keywords: +patch pull_requests: +17328 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17916 ___ Python tracker <https://bugs.python.org/issue39272> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39272] Dead assignment in _ssl__SSLContext_load_verify_locations_impl
New submission from Alex Henrie : The function _ssl__SSLContext_load_verify_locations_impl currently contains the following code: if (r != 1) { ok = 0; if (errno != 0) { ERR_clear_error(); PyErr_SetFromErrno(PyExc_OSError); } else { _setSSLError(NULL, 0, __FILE__, __LINE__); } goto error; } } goto end; error: ok = 0; It is unnecessary to set ok to 0 before jumping to error because the first instruction after the error label does the same thing. -- assignee: christian.heimes components: SSL messages: 359654 nosy: alex.henrie, christian.heimes priority: normal severity: normal status: open title: Dead assignment in _ssl__SSLContext_load_verify_locations_impl type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39272> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39271] Dead assignment in pattern_subx
Change by Alex Henrie : -- keywords: +patch pull_requests: +17327 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17915 ___ Python tracker <https://bugs.python.org/issue39271> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39271] Dead assignment in pattern_subx
New submission from Alex Henrie : The function pattern_subx currently sets the variable b to charsize, but that variable is reset to STATE_OFFSET(, state.start) before it is ever used. -- components: Regular Expressions messages: 359653 nosy: alex.henrie, ezio.melotti, mrabarnett priority: normal severity: normal status: open title: Dead assignment in pattern_subx type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39271> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39270] Dead assignment in config_init_module_search_paths
Change by Alex Henrie : -- keywords: +patch pull_requests: +17326 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17914 ___ Python tracker <https://bugs.python.org/issue39270> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39270] Dead assignment in config_init_module_search_paths
New submission from Alex Henrie : config_init_module_search_paths currently has the following code: const wchar_t *p = sys_path; while (1) { p = wcschr(sys_path, delim); The first assignment to p is unnecessary because it is immediately overwritten. Victor Stinner suggested moving the variable declaration into the loop itself to clarify that it does not need to be initialized elsewhere: https://github.com/python/cpython/pull/16267/files#r364216448 -- messages: 359652 nosy: alex.henrie priority: normal severity: normal status: open title: Dead assignment in config_init_module_search_paths type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39270> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39262] Unused error message in _sharedexception_bind
Change by Alex Henrie : -- keywords: +patch pull_requests: +17319 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17908 ___ Python tracker <https://bugs.python.org/issue39262> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39262] Unused error message in _sharedexception_bind
New submission from Alex Henrie : The function _sharedexception_bind currently has the following bit of code in two places: if (PyErr_ExceptionMatches(PyExc_MemoryError)) { failure = "out of memory copying exception type name"; } failure = "unable to encode and copy exception type name"; The "out of memory" message will never appear because it is immediately overwritten with a more generic message. -- messages: 359620 nosy: alex.henrie priority: normal severity: normal status: open title: Unused error message in _sharedexception_bind type: behavior versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39262> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39261] Dead assignment in pyinit_config
Change by Alex Henrie : -- type: -> performance ___ Python tracker <https://bugs.python.org/issue39261> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39261] Dead assignment in pyinit_config
Change by Alex Henrie : -- versions: +Python 3.9 ___ Python tracker <https://bugs.python.org/issue39261> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39261] Dead assignment in pyinit_config
Change by Alex Henrie : -- keywords: +patch pull_requests: +17318 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17907 ___ Python tracker <https://bugs.python.org/issue39261> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39261] Dead assignment in pyinit_config
New submission from Alex Henrie : The function pyinit_config currently contains the following line: config = >interp->config; However, the config variable is not used after that point. Victor Stinner has confirmed that this assignment is unnecessary: https://github.com/python/cpython/pull/16267/files#r364216184 -- messages: 359619 nosy: alex.henrie priority: normal severity: normal status: open title: Dead assignment in pyinit_config ___ Python tracker <https://bugs.python.org/issue39261> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39237] Redundant call to round in delta_new
Alex Henrie added the comment: Thank you! -- ___ Python tracker <https://bugs.python.org/issue39237> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39237] Redundant call to round in delta_new
Change by Alex Henrie : -- keywords: +patch pull_requests: +17293 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17877 ___ Python tracker <https://bugs.python.org/issue39237> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39237] Redundant call to round in delta_new
New submission from Alex Henrie : The delta_new function in _datetimemodule.c currently contains the following code: /* Round to nearest whole # of us, and add into x. */ double whole_us = round(leftover_us); int x_is_odd; PyObject *temp; whole_us = round(leftover_us); The second call to the round function produces the same result as the first call and can therefore be safely eliminated. -- components: Library (Lib) messages: 359465 nosy: alex.henrie priority: normal severity: normal status: open title: Redundant call to round in delta_new type: performance versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue39237> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34889] int.to_bytes and int.from_bytes should default to the system byte order like the struct module does
Change by Alex Henrie : -- keywords: +patch pull_requests: +9081 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue34889> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34889] int.to_bytes and int.from_bytes should default to the system byte order like the struct module does
New submission from Alex Henrie : When serializing a single integer, int.to_bytes and int.from_bytes are more efficient alternatives to struct.pack and struct.unpack. However, struct.pack and struct.unpack currently have the advantage that the byteorder does not have to be specified (because it defaults to sys.byteorder). It would avoid a lot of redundant code to make the byteorder argument default to sys.byteorder in int.to_bytes and int.from_bytes too. -- components: Library (Lib) messages: 327030 nosy: alex.henrie priority: normal severity: normal status: open title: int.to_bytes and int.from_bytes should default to the system byte order like the struct module does versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue34889> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com