Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all 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
3 changes: 3 additions & 0 deletions 3 Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,9 @@ _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file)

mod = _PyImport_FindExtensionObject(name, path);
if (mod != NULL || PyErr_Occurred()) {
if (PyErr_Occurred()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To avoid the overhead of calling PyErr_Occurred(), could you store the result in a variable and check that?

PyErr_Clear();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've started a discussion over on the issue where if I'm right and swallowing an exception is bad then this clearing of the exception should be removed.

}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This actually won't work because since you cleared out the error but are returning NULL you will trigger a failure in the interpreter for saying there's an exception when one isn't set.

Py_DECREF(name);
Py_DECREF(path);
Py_XINCREF(mod);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.