summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-21 15:23:06 (GMT)
committerGitHub <noreply@github.com>2022-07-21 15:23:06 (GMT)
commite693f84cf79d81a10c9c63ab46cdf0fe2ebe9c10 (patch)
tree925f3315194a5fda07980a7be905dec425639255
parentd19b5d85339653ec54658e67aa55ddf40f6461c5 (diff)
downloadcpython-e693f84cf79d81a10c9c63ab46cdf0fe2ebe9c10.zip
cpython-e693f84cf79d81a10c9c63ab46cdf0fe2ebe9c10.tar.gz
cpython-e693f84cf79d81a10c9c63ab46cdf0fe2ebe9c10.tar.bz2
[3.11] GH-95060: Fix PyCode_Addr2Location when addrq < 0 (GH-95094)
(cherry picked from commit a6daaf2a132efbb1965b4502ff8a8cf3b5afed0e) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-07-21-19-19-20.gh-issue-95060.4xdT1f.rst2
-rw-r--r--Objects/codeobject.c1
2 files changed, 3 insertions, 0 deletions
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 0000000..160999e
--- /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 4859b1e..35576a2 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -969,6 +969,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;