mdmintz / pdbp

pdbp (Pdb+): A drop-in replacement for pdb and pdbpp. To replace "pdb", add "import pdbp" to an "__init__.py" file.
Other
75 stars 2 forks source link

lasti2lineno is not defined #71

Closed jonashaag closed 1 week ago

jonashaag commented 1 week ago

Python 3.12

python -m pdbp my_script.py
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File ".../lib/python3.12/site-packages/pdbp.py", line 1638, in <module>
    pdbp.main()
  File ".../lib/python3.12/site-packages/pdbp.py", line 1630, in main
    pdb.interaction(None, t)
  File ".../lib/python3.12/site-packages/pdbp.py", line 272, in interaction
    ret = self.setup(frame, traceback)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File .../lib/python3.12/site-packages/pdbp.py", line 323, in setup
    ret = super().setup(frame, tb)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/pdbp.py", line 326, in setup
    lineno = lasti2lineno(tb.tb_frame.f_code, tb.tb_lasti)
             ^^^^^^^^^^^^
NameError: name 'lasti2lineno' is not defined

Any ideas how this can happen?

mdmintz commented 1 week ago

It's defined right here: https://github.com/mdmintz/pdbp/blob/227b212e38e6952e0e5d29c384e23d7dee3f9c23/src/pdbp.py#L149

Did you modify the package at all? Are you using the latest version of pdbp? Which OS are you using?

jonashaag commented 1 week ago

No modification; when I open the file I can see the function there.

I also tried calling pdb.lasti2lino instead but then it said that pdb wasn't imported.

I wonder if there is anything special about the way the setup function is called that makes these definitions unavailable?

mdmintz commented 1 week ago

Try pip install pdbp==1.5.3 (there's possibly a recent regression).

mdmintz commented 1 week ago

Upgrade to 1.6.1 - https://github.com/mdmintz/pdbp/releases/tag/v1.6.1