Reproducer: ```py import math try: math.dist([1, 2], [3, 4, 5]) except ValueError: pass ``` Memory leak: ```console @kumaraditya303 ➜ /workspaces/cpython (main ✗) $ ./python -X showrefcount main.py [7 refs, 2 blocks] ``` Python Version: main at 9bdec0aa45 <!-- gh-pr-number: gh-98898 --> * PR: gh-98898 <!-- /gh-pr-number --> <!-- gh-pr-number: gh-98941 --> * PR: gh-98941 <!-- /gh-pr-number --> <!-- gh-pr-number: gh-98942 --> * PR: gh-98942 <!-- /gh-pr-number -->
Activity
vstinner commentedon Oct 31, 2022
I'm glad that
./python -X showrefcountcan now be used to detect memory leaks at exit :-) https://mail.python.org/archives/list/python-dev@python.org/thread/E4C6TDNVDPDNNP73HTGHN5W42LGAE22F/vstinner commentedon Oct 31, 2022
Do you want to propose a fix?
GH-98897: fix memory leak if `math.dist` raises exception (GH-98898)
pythonGH-98897: fix memory leak if `math.dist` raises exception (pyth…
pythonGH-98897: fix memory leak if `math.dist` raises exception (pyth…
GH-98897: fix memory leak if `math.dist` raises exception (GH-98898)
GH-98897: fix memory leak if `math.dist` raises exception (GH-98898)