Skip to content

bpo-31418: Fix an assertion failure in case of an exception with a bad __module__ attribute #3539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an assertion failure in `c.PyErr_WriteUnraisable()` in case of an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is c.PyErr_WriteUnraisable()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://devguide.python.org/committing/#what-s-new-and-news-entries says:
(single backticks) in reST can be used to refer to objects in the documentation.
I thought this means that i should specify (inside single backticks) an object in the docs, according to how it appears in the docs (i.e. when pressing the Permalink to this definition button - https://docs.python.org/3.7/c-api/exceptions.html#c.PyErr_WriteUnraisable).

so it should just be PyErr_WriteUnraisable()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be without "c." prefix.

exception with a bad ``__module__`` attribute. Patch by Oren Milman.
2 changes: 1 addition & 1 deletion Python/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ PyErr_WriteUnraisable(PyObject *obj)
}

moduleName = _PyObject_GetAttrId(t, &PyId___module__);
if (moduleName == NULL) {
if (moduleName == NULL || !PyUnicode_Check(moduleName)) {
PyErr_Clear();
if (PyFile_WriteString("<unknown>", f) < 0)
goto done;
Expand Down