msg386562 - (view) |
Author: Florian Bruhin (The Compiler) * |
Date: 2021-02-06 15:54 |
After upgrading to 3.10a5, calling logging.exception("test") results in:
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.10/logging/__init__.py", line 1094, in emit
msg = self.format(record)
File "/usr/lib/python3.10/logging/__init__.py", line 938, in format
return fmt.format(record)
File "/usr/lib/python3.10/logging/__init__.py", line 682, in format
record.exc_text = self.formatException(record.exc_info)
File "/usr/lib/python3.10/logging/__init__.py", line 632, in formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
File "/usr/lib/python3.10/traceback.py", line 113, in print_exception
te = TracebackException(type(value), value, tb, limit=limit, compact=True)
File "/usr/lib/python3.10/traceback.py", line 531, in __init__
need_context = cause is None and not e.__suppress_context__
AttributeError: 'NoneType' object has no attribute '__suppress_context__'
That method is documented as "This function should only be called from an exception handler.", but the same also happens when e.g. calling traceback.print_exc() (without a current exception) or traceback.print_exception(None, None, None). Both worked fine before 3.10 Alpha 5, the code seems to do None-checks in other places, and typeshed also marks those arguments as Optional.
This seems to have been introduced in https://github.com/python/cpython/pull/24179 for bpo-42877.
|
msg386563 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-06 16:02 |
Thanks, I’ll add the None check.
|
msg386568 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-06 20:17 |
There's another such issue due to PR 22610 // issue 26389:
>>> traceback.format_exception(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\src\cpython-dev\lib\traceback.py", line 128, in format_exception
value, tb = _parse_value_tb(exc, value, tb)
File "C:\Users\User\src\cpython-dev\lib\traceback.py", line 94, in _parse_value_tb
return exc, exc.__traceback__
AttributeError: 'NoneType' object has no attribute '__traceback__'
|
msg386796 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-10 17:34 |
Marking as blocker because these are 3.10 regressions.
|
msg386885 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2021-02-12 22:24 |
It seems to me that print_exception(None), etc, *should* raise something. Printing "NoneType: None\n" makes no sense to me since NoneType is not an exception. In 3.9, it raised TypeError for # of arguments.
I do note that in 3.9
>>> traceback.print_exception(None, None, None)
NoneType: None
I wonder what the rationale was. It isn't because these functions never raise.
|
msg386886 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-12 22:33 |
In 3.9 you had to give exc,val,tb. In 3.10 the shortcut was added. Issue 26389.
|
msg386917 - (view) |
Author: Miro Hrončok (hroncok) * |
Date: 2021-02-13 09:10 |
JFYI, there are 2 affected Fedora packages (that we know of):
visidata fails to build with Python 3.10: AttributeError: 'NoneType' object has no attribute '__suppress_context__'
https://bugzilla.redhat.com/show_bug.cgi?id=1928145
python-utils fails to build with Python 3.10: AttributeError: 'NoneType' object has no attribute '__suppress_context__'
https://bugzilla.redhat.com/show_bug.cgi?id=1928081
|
msg386928 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-13 20:09 |
> I wonder what the rationale was. It isn't because these functions never raise.
I think it's because sys.exc_info() can return None, None, None when there is no exceptions.
|
msg387159 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-17 14:57 |
Let's split the print_exception(None) case (new issue) from the regression. I've updated the PR to fix only the latter, which is not controversial.
I don't know what print_exception(None) should do.
|
msg387573 - (view) |
Author: Guido van Rossum (gvanrossum) * |
Date: 2021-02-23 14:59 |
New changeset 26f18b8540b49d592af66361f8df1a03953d1768 by Irit Katriel in branch 'master':
bpo-43146: fix regression in traceback.print_exception(None) (GH-24463)
https://github.com/python/cpython/commit/26f18b8540b49d592af66361f8df1a03953d1768
|
msg387574 - (view) |
Author: Guido van Rossum (gvanrossum) * |
Date: 2021-02-23 15:01 |
Are you going to create a separate PR or a new issue for the other thing? (And what exactly *is* the other thing? Please summarize.)
|
msg387575 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-23 15:26 |
The other thing is not related to the one reported here, but I found it while writing the test for this.
We have a new API in 3.10, where you can do traceback.print_exception(ex) (so you don't need to give the whole type,val,tb triplet).
But:
>>> traceback.print_exception(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\src\cpython-dev\lib\traceback.py", line 110, in print_exception
value, tb = _parse_value_tb(exc, value, tb)
File "C:\Users\User\src\cpython-dev\lib\traceback.py", line 94, in _parse_value_tb
return exc, exc.__traceback__
AttributeError: 'NoneType' object has no attribute '__traceback__'
|
msg387579 - (view) |
Author: Guido van Rossum (gvanrossum) * |
Date: 2021-02-23 16:23 |
So the PR just merged fixes that, right? Color me confused.
|
msg387580 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-23 16:29 |
The PR just merged fixes the issue that was reported by Florian (what I broke). That impacted pre-3.10 APIs so was an actual regression.
The issue with traceback.print_exception(None) is new to 3.10, and was introduced in issue 26389.
|
msg387581 - (view) |
Author: Guido van Rossum (gvanrossum) * |
Date: 2021-02-23 16:45 |
So the remaining question is what to do for print_exception(None)? Honestly
the current (new) behavior of printing `NoneType: None` seems fine.
|
msg387582 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-23 16:58 |
> So the remaining question is what to do for print_exception(None)?
Yes.
> Honestly the current (new) behavior of printing `NoneType: None` seems fine.
That's not the current behaviour - I removed that fix from the PR till we agree what to do. Currently we get the AttributeError.
|
msg387586 - (view) |
Author: Irit Katriel (iritkatriel) * |
Date: 2021-02-23 17:21 |
The new PR makes it print `NoneType: None`, which is at least consistent with what the same functions do without the Issue26389 shortcut.
|
msg387587 - (view) |
Author: Guido van Rossum (gvanrossum) * |
Date: 2021-02-23 17:43 |
New changeset b798ab06937f8bb24b444a49dd42e11fff15e654 by Irit Katriel in branch 'master':
bpo-43146: fix None-handling in single-arg traceback.print_exception(None) (GH-24629)
https://github.com/python/cpython/commit/b798ab06937f8bb24b444a49dd42e11fff15e654
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:41 | admin | set | github: 87312 |
2021-02-23 19:39:25 | iritkatriel | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
2021-02-23 17:43:27 | gvanrossum | set | messages:
+ msg387587 |
2021-02-23 17:21:40 | iritkatriel | set | messages:
+ msg387586 |
2021-02-23 17:16:33 | iritkatriel | set | pull_requests:
+ pull_request23414 |
2021-02-23 16:58:33 | iritkatriel | set | messages:
+ msg387582 |
2021-02-23 16:45:40 | gvanrossum | set | messages:
+ msg387581 |
2021-02-23 16:29:50 | iritkatriel | set | messages:
+ msg387580 |
2021-02-23 16:23:38 | gvanrossum | set | messages:
+ msg387579 |
2021-02-23 15:26:26 | iritkatriel | set | messages:
+ msg387575 |
2021-02-23 15:01:38 | gvanrossum | set | messages:
+ msg387574 |
2021-02-23 14:59:12 | gvanrossum | set | nosy:
+ gvanrossum messages:
+ msg387573
|
2021-02-17 14:57:18 | iritkatriel | set | messages:
+ msg387159 |
2021-02-15 15:13:49 | iritkatriel | set | keywords:
+ 3.10regression |
2021-02-13 20:09:49 | iritkatriel | set | messages:
+ msg386928 |
2021-02-13 09:10:02 | hroncok | set | nosy:
+ hroncok messages:
+ msg386917
|
2021-02-12 22:33:08 | iritkatriel | set | messages:
+ msg386886 |
2021-02-12 22:24:48 | terry.reedy | set | nosy:
+ terry.reedy messages:
+ msg386885
|
2021-02-10 17:34:57 | iritkatriel | set | priority: normal -> release blocker
messages:
+ msg386796 |
2021-02-06 21:12:52 | iritkatriel | set | keywords:
+ patch stage: patch review pull_requests:
+ pull_request23261 |
2021-02-06 20:35:07 | iritkatriel | set | nosy:
+ ZackerySpytz, pablogsal
|
2021-02-06 20:17:45 | iritkatriel | set | messages:
+ msg386568 |
2021-02-06 16:02:38 | iritkatriel | set | messages:
+ msg386563 |
2021-02-06 15:54:16 | The Compiler | create | |