-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-41094: Fix decoding errors with audit when open files. #21095
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
bpo-41094: Fix decoding errors with audit when open files. #21095
Conversation
I have no idea what the ossaudiodev failure relates to... that doesn't go through this code path does it? |
@@ -1274,7 +1274,12 @@ _Py_open_impl(const char *pathname, int flags, int gil_held) | |||
#endif | |||
|
|||
if (gil_held) { | |||
if (PySys_Audit("open", "sOi", pathname, Py_None, flags) < 0) { | |||
PyObject *pathname_obj = PyUnicode_DecodeFSDefault(pathname); |
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.
Would it be possible to call should_audit() here to avoid decoding the string if audit is disabled?
Something like:
if (should_audit()) {
pathname_obj = PyUnicode_DecodeFSDefault(pathname);
PySys_Audit(pathname_obj)
Py_DECREF(pathname_obj);
}
Same remark for _Py_fopen().
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 is not performance critical, and should_audit()
is not available in Python/fileutils.c
, so this needs additional work. I prefer to merge simple fix. You can add the call should_audit()
in separate PR.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
GH-21107 is a backport of this pull request to the 3.9 branch. |
GH-21108 is a backport of this pull request to the 3.8 branch. |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-21120 is a backport of this pull request to the 3.9 branch. |
GH-21121 is a backport of this pull request to the 3.8 branch. |
https://bugs.python.org/issue41094