[Python-checkins] Fix PyCode_Addr2Location when addrq < 0 (GH-95091)

markshannon webhook-mailer at python.org
Thu Jul 21 09:50:10 EDT 2022


https://github.com/python/cpython/commit/a6daaf2a132efbb1965b4502ff8a8cf3b5afed0e
commit: a6daaf2a132efbb1965b4502ff8a8cf3b5afed0e
branch: main
author: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com>
committer: markshannon <mark at hotpy.org>
date: 2022-07-21T14:49:49+01:00
summary:

Fix PyCode_Addr2Location when addrq < 0 (GH-95091)

files:
A Misc/NEWS.d/next/Core and Builtins/2022-07-21-19-19-20.gh-issue-95060.4xdT1f.rst
M Objects/codeobject.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-21-19-19-20.gh-issue-95060.4xdT1f.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-21-19-19-20.gh-issue-95060.4xdT1f.rst
new file mode 100644
index 0000000000000..160999e82bf08
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-21-19-19-20.gh-issue-95060.4xdT1f.rst	
@@ -0,0 +1,2 @@
+Undocumented ``PyCode_Addr2Location`` function now properly returns when
+``addrq`` argument is less than zero.
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index d4fa0e38aed62..76e430ae1c501 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -971,6 +971,7 @@ PyCode_Addr2Location(PyCodeObject *co, int addrq,
     if (addrq < 0) {
         *start_line = *end_line = co->co_firstlineno;
         *start_column = *end_column = 0;
+        return 1;
     }
     assert(addrq >= 0 && addrq < _PyCode_NBYTES(co));
     PyCodeAddressRange bounds;



More information about the Python-checkins mailing list