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
Audit Hook doc typos and confusion #83073
Comments
Some suggestions for "Adds to the collection of active auditing hooks" Change 'Adds' to 'Add' or maybe 'Append' (see near below). PySys version: I think the 'userData' explanation should be closer to the top. Grammar: "Functions in the runtime and standard library that raise events include the details in each function’s documentation and listed in the audit events table." is not a proper sentence. Its 'skeleton' is "Functions ... include the details ... and listed ... . Either change 'include the details' to 'are detailed' and 'listed' to 'are listed' or split into two sentences: "Functions in the runtime and standard library that raise events are listed in the audit events table. Details are in each function’s documentation. Both, again: "raises a auditing event". 'a' should be 'an'. To me, this is slightly confusing because Python raises exceptions, but auditing events are not exceptions and do not normally abort execution. Perhaps "This call is a 'sys.addaudithook' event with no arguments that triggers an audit call." https://docs.python.org/3.9/c-api/sys.html#c.PySys_Audit Change 'Raises' to 'Raise'. https://docs.python.org/3.8/library/audit_events.html On pydev, Steve said "(though some won't be raised until 3.8.1... we should probably mark those, or at least update that page to warn that events may have been added over time)." |
Thanks Terry, this is great! Agree with everything apart from not liking "raise" - I think "raise an event" is totally fine usage, and certainly better than "triggers an audit call" (since it may not, if nobody's listening). Plus PEP-578 is full of "raise", and we're not going to go edit all of that :) |
I agree on consistency. I will make a PR for you to review. Do you think a minimal code example might help? Running ... import sys
def hook(name, args):
if name.startswith('compile'):
print(name, args)
sys.addaudithook(hook)
compile('a = 1', '<dummy>', 'exec') # prints compile (b'a = 1', '<dummy>') My own interest is learning about the socket connecting an IDLE GUI process and the user code run process. The following in the two startup files: def hook(name, args):
if name.startswith('socket'):
print('I', name, args) # I/R in the IDLE/run processes.
sys.addaudithook(hook) results in: I socket.gethostname () To go further, I might wrap socket.socket.send/recv with functions that call sys.audit. |
Thanks Terry! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: