[issue44297] Frame with -1 line number

2021-08-13 Thread Mark Shannon


Mark Shannon  added the comment:

I believe this to be fixed.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 0b6b2865187bca7ed7f1f511a02fc8bd13ee38ca by Mark Shannon in 
branch '3.10':
bpo-44297: Add a regression test for line numbers in with statements (GH-26891)
https://github.com/python/cpython/commit/0b6b2865187bca7ed7f1f511a02fc8bd13ee38ca


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-24 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25468
pull_request: https://github.com/python/cpython/pull/26891

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-24 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25467
pull_request: https://github.com/python/cpython/pull/26890

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-24 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Found the culprit - 
https://github.com/python/cpython/blob/769d7d0c66c5b86e2dd29b9ce67ac2daaab1bb38/Python/compile.c#L5268

Same goes for async with - 
https://github.com/python/cpython/blob/769d7d0c66c5b86e2dd29b9ce67ac2daaab1bb38/Python/compile.c#L5171
(Didn't test async with so I can be wrong there.)

Is this intentional? I removed these lines and the line number is coming 
correct. Can changing this affect other use cases?

Without the change:


Traceback (most recent call last):
  File "C:\Users\shrey\Desktop\line_negative_one.py", line 8, in 
raise Exception("Normal Error")
Exception: Normal Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\shrey\Desktop\line_negative_one.py", line -1, in 
  File "C:\Users\shrey\Desktop\line_negative_one.py", line 5, in __exit__
raise Exception("Frame is -1 if program is run from command line")
Exception: Frame is -1 if program is run from command line



With the change:



Traceback (most recent call last):
  File "C:\Users\shrey\Desktop\line_negative_one.py", line 8, in 
raise Exception("Normal Error")
Exception: Normal Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\shrey\Desktop\line_negative_one.py", line 7, in 
with A():
  File "C:\Users\shrey\Desktop\line_negative_one.py", line 5, in __exit__
raise Exception("Frame is -1 if program is run from command line")
Exception: Frame is not -1 anymore if program is run from command line

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-23 Thread Mark Shannon


Mark Shannon  added the comment:

Thanks for the reproducer.

--
assignee:  -> Mark.Shannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-23 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

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 
  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'

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-22 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Here presumably the error is occurring somewhere near unittest. I've tested 
this and wrote a minimal reproducible example. 

```
import unittest

class TestingError(unittest.TestCase):
def test_negative_one(self):
with self.assertRaisesRegex(AssertionError, "x"):
self.assertEqual(1, 2)
```

Running this with `unittest discover` or in any other command-line way (like 
-c) results in frame with -1 while running it from script (with unittest.main 
probably) does not.

Hope this helps.

--
nosy: +shreyanavigyan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-21 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, I can still reproduce the issue on the main branch with this patch:

diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index cee97a8302..3f66818ae1 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -4499,7 +4499,7 @@ def msg_cb(conn, direction, version, content_type, 
msg_type, data):
 # server aborts connection with an error.
 with self.assertRaisesRegex(
 ssl.SSLError,
-'(certificate required|EOF occurred)'
+'x'
 ):
 # receive CertificateRequest
 data = s.recv(1024)



$ ./python -m test test_ssl -m test_pha_required_nocert -v
(...)
FAIL: test_pha_required_nocert (test.test_ssl.TestPostHandshakeAuth)
--
(...)
Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/test_ssl.py", line -1, in 
test_pha_required_nocert
AssertionError: (...)
...


=> "line -1"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-21 Thread STINNER Victor


STINNER Victor  added the comment:

Can the issue be closed?

I'm not sure which assertion failed in test_ssl.test_pha_required_nocert(). I 
bet on this one:

with self.assertRaisesRegex(
ssl.SSLError,
'(certificate required|EOF occurred)'
):

I don't know if the commit 82e5c28af7049c4f5343c808f172cbe2e145f49b is 
supported is to fix issue or not.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 7674c83d81905d6afe989ca3f93f08b7939b057c by Mark Shannon in 
branch '3.10':
bpo-44297: Fix missing line number in generator expressions (GH-26821)
https://github.com/python/cpython/commit/7674c83d81905d6afe989ca3f93f08b7939b057c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-21 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +25402
pull_request: https://github.com/python/cpython/pull/26821

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-21 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 82e5c28af7049c4f5343c808f172cbe2e145f49b by Mark Shannon in 
branch 'main':
bpo-44297: Fix missing line number in generator expressions (GH-26801)
https://github.com/python/cpython/commit/82e5c28af7049c4f5343c808f172cbe2e145f49b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-19 Thread Mark Shannon


Change by Mark Shannon :


--
keywords: +patch
pull_requests: +25382
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26801

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-19 Thread Mark Shannon


Mark Shannon  added the comment:

Thanks Anthony, that's a big help.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-19 Thread Anthony Sottile


Anthony Sottile  added the comment:

here is a minimal reproduction:

```python
def iterboom():
raise AssertionError
yield 1

next(1 for x in iterboom())
```

python 3.9:


```
$ python3.9 t.py
Traceback (most recent call last):
  File "/tmp/rinohtype/t.py", line 5, in 
next(1 for x in iterboom())
  File "/tmp/rinohtype/t.py", line 5, in 
next(1 for x in iterboom())
  File "/tmp/rinohtype/t.py", line 2, in iterboom
raise AssertionError
AssertionError
```

```
$ python3.10 t.py
Traceback (most recent call last):
  File "/tmp/rinohtype/t.py", line 5, in 
next(1 for x in iterboom())
  File "/tmp/rinohtype/t.py", line -1, in 
  File "/tmp/rinohtype/t.py", line 2, in iterboom
raise AssertionError
AssertionError
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-18 Thread Anthony Sottile


Anthony Sottile  added the comment:

here's the traceback pytest is trying to display and crashing:

```
Traceback (most recent call last):
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/runner.py", 
line 311, in from_call
result: Optional[TResult] = func()
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/runner.py", 
line 341, in 
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/python.py", 
line 503, in collect
self._inject_setup_module_fixture()
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/python.py", 
line 516, in _inject_setup_module_fixture
self.obj, ("setUpModule", "setup_module")
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/python.py", 
line 291, in obj
self._obj = obj = self._getobj()
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/python.py", 
line 500, in _getobj
return self._importtestmodule()
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/python.py", 
line 578, in _importtestmodule
mod = import_path(self.fspath, mode=importmode)
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/pathlib.py", 
line 524, in import_path
importlib.import_module(module_name)
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/__init__.py", 
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1050, in _gcd_import
  File "", line 1027, in _find_and_load
  File "", line 1006, in _find_and_load_unlocked
  File "", line 688, in _load_unlocked
  File 
"/tmp/rinohtype/venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py",
 line 170, in exec_module
exec(co, module.__dict__)
  File "/tmp/rinohtype/tests/test_attribute.py", line 11, in 
from rinoh.attribute import Attribute, Bool
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/rinoh/__init__.py", 
line 41, in 
from . import resource
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/rinoh/resource.py", 
line 205, in 
from .template import DocumentTemplate
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/rinoh/template.py", 
line 42, in 
from .stylesheets import sphinx
  File 
"/tmp/rinohtype/venv/lib/python3.10/site-packages/rinoh/stylesheets/__init__.py",
 line 42, in 
.format(stylesheet.description, stylesheet))
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/rinoh/style.py", line 
670, in __str__
for name, entry_point in self.installed_resources:
  File "/tmp/rinohtype/venv/lib/python3.10/site-packages/rinoh/resource.py", 
line 54, in installed_resources
for entry_point in ilm.entry_points()[cls.entry_point_group]:
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/metadata/__init__.py",
 line 979, in entry_points
return SelectableGroups.load(eps).select(**params)
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/metadata/__init__.py",
 line 437, in load
ordered = sorted(eps, key=by_group)
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/metadata/__init__.py",
 line -1, in 
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/metadata/_itertools.py",
 line 16, in unique_everseen
k = key(element)
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/metadata/__init__.py",
 line 600, in _normalized_name
return Prepared.normalize(self.name)
  File 
"/home/asottile/workspace/cpython/prefix/lib/python3.10/importlib/metadata/__init__.py",
 line 841, in normalize
return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
  File "/home/asottile/workspace/cpython/prefix/lib/python3.10/re.py", line 
187, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-18 Thread Anthony Sottile


Anthony Sottile  added the comment:

this appears to have regressed in 3.10 as well according to some reports on 
pytest: https://github.com/pytest-dev/pytest/pull/8227#issuecomment-864327090

--
nosy: +Anthony Sottile, pablogsal
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-06 Thread Dominic Davis-Foster


Dominic Davis-Foster  added the comment:

Is this a re-regression of https://bugs.python.org/issue43933?

--
nosy: +domdfcoding

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44297] Frame with -1 line number

2021-06-02 Thread STINNER Victor


New submission from STINNER Victor :

While debugging https://bugs.python.org/issue43921 on Windows, I got a 
traceback with a single frame and the frame line number is -1.

It looks like a Python 3.11 regression.

Mark, Guido: can it be related to recent optimization work done in the main 
branch?

See also bpo-44288 "unittest: _is_relevant_tb_level() fails because 
tb.tb_frame.f_globals=None".

==
FAIL: test_pha_required_nocert (test.test_ssl.TestPostHandshakeAuth)
--
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2522)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\vstinner\python\main\lib\test\test_ssl.py", line -1, in 
test_pha_required_nocert
AssertionError: "certificate required" does not match "EOF occurred in 
violation of protocol (_ssl.c:2522)"

--
components: Interpreter Core
messages: 394969
nosy: Mark.Shannon, gvanrossum, vstinner
priority: normal
severity: normal
status: open
title: Frame with -1 line number
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com