This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author shreyanavigyan
Recipients Anthony Sottile, Mark.Shannon, domdfcoding, gvanrossum, pablogsal, shreyanavigyan, vstinner
Date 2021-06-23.08:59:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624438752.3.0.2378449001.issue44297@roundup.psfhosted.org>
In-reply-to
Content
Oh it is also occurring when running from script (I ran it from IDLE and it always results in correct lineno). I wrote example similar to how unittests work and the frame with -1 lineno is also occurring there. Here is the code -

```
class A:
    def __enter__(self):
        return self
    def __exit__(self, *args, **kwargs):
        raise Exception("Frame is -1 if program is run from command line")

with A():
    raise Exception("Normal Error")
```

Also, unsurprisingly, pdb fails with a "TypeError: '>=' not supported between instances of 'NoneType' and 'int'". Full pdb log -

Traceback (most recent call last):
  File "C:\Users\shrey\Desktop\line_negative_one.py", line -1, in <module>
  File "C:\github\cpython\lib\bdb.py", line 96, in trace_dispatch
    return self.dispatch_exception(frame, arg)
  File "C:\github\cpython\lib\bdb.py", line 169, in dispatch_exception
    if self.stop_here(frame):
  File "C:\github\cpython\lib\bdb.py", line 212, in stop_here
    return frame.f_lineno >= self.stoplineno
TypeError: '>=' not supported between instances of 'NoneType' and 'int'
History
Date User Action Args
2021-06-23 08:59:12shreyanavigyansetrecipients: + shreyanavigyan, gvanrossum, vstinner, Mark.Shannon, Anthony Sottile, pablogsal, domdfcoding
2021-06-23 08:59:12shreyanavigyansetmessageid: <1624438752.3.0.2378449001.issue44297@roundup.psfhosted.org>
2021-06-23 08:59:12shreyanavigyanlinkissue44297 messages
2021-06-23 08:59:12shreyanavigyancreate