-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-28411: Support other mappings in PyInterpreterState.modules. #3593
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
Changes from 1 commit
8f3ecfc
9dc9ded
f2a54b1
502e138
ec8c504
a1546f6
5a5fad1
db0a247
7082b47
5082c47
bb03872
2e07296
4631163
5b154b3
33174f3
e50e258
23cf493
eed5e24
bcc72a5
8000
981dbd2
0fe1aff
d4d9219
9c39295
446acd5
540b99a
5f0735b
63beead
00f3f24
5a7bba2
3a73b52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,6 +322,7 @@ _PyImport_GetModule(PyObject *name) | |
if (PyErr_Occurred()) { | ||
PyErr_Clear(); | ||
} | ||
/* Return a borrowed reference instead of a new one. */ | ||
Py_XDECREF(mod); | ||
return mod; | ||
} | ||
|
@@ -340,6 +341,8 @@ _PyImport_GetModuleWithError(PyObject *name) | |
if (PyErr_ExceptionMatches(PyExc_KeyError)) { | ||
PyErr_Clear(); | ||
} | ||
/* Return a borrowed reference instead of a new one. */ | ||
Py_XDECREF(mod); | ||
return mod; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the Py_XDECREF to return a borrowed reference instead of a new one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gah! The docs for PyDict_GetItemWithError() before 3.7 don't mention it returning a borrowed reference. Thanks for catching that. I was looking for that refleak! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Looks like that wasn't the refleak I was looking for. :/ Back I go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just pattern matching with the code above based on the assumption that However, it now occurs to me that these access patterns are thoroughly dubious if you genuinely want to allow dict subclasses and arbitrary mappings, as those may return dynamic references (e.g. from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. I'll fix that. |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could do with a second comment saying "Return a borrowed reference instead of a new one"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.