Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5085b3f
Implement PEP 578
zooba Mar 14, 2019
2e246b7
Move audit hooks to interpreter state
zooba May 6, 2019
1357172
Only preserve exception on Python thread
zooba May 6, 2019
445224c
Add test for subinterpreters
zooba May 6, 2019
af3dd4d
Add DTrace UDST audit hook
tiran May 7, 2019
f53004b
Add NEWS and update socket events
zooba May 7, 2019
a96e225
Fix socket events and add input event
zooba May 8, 2019
79dea7a
Add ..audit-event directive for docs
zooba May 8, 2019
f357525
Undo mismerged changes
zooba May 8, 2019
7f83da1
Fix docs and test
zooba May 8, 2019
475909e
Fix whitespace
zooba May 10, 2019
0fb5b3a
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 10, 2019
a208832
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 13, 2019
1d028ca
Fix merge issues
zooba May 13, 2019
68746dd
Ensure auditing hooks are testing
zooba May 13, 2019
00687c1
Code review feedback and fixes
zooba May 13, 2019
8a6cb1e
Format tests and add new header to various file lists
zooba May 13, 2019
3c106f7
Fix doc bug
zooba May 13, 2019
2a18358
Improve dangling thread output and fix reference leak
zooba May 13, 2019
9fa5939
Disable tracing of audit hooks
zooba May 13, 2019
89b24eb
Fix new parser interface
zooba May 13, 2019
5a5b51e
Apply review feedback
zooba May 14, 2019
ec98f69
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 14, 2019
47a911c
Avoid creating PyObject without an interpreter.
zooba May 14, 2019
b573d3a
Fix expected result for test
zooba May 14, 2019
a30f018
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 15, 2019
0d25ac7
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 15, 2019
b3c1792
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 16, 2019
b78e468
Revert save_env change and filed bpo-36949
zooba May 17, 2019
bfb52fb
Add comment about importing _io
zooba May 17, 2019
5bb335c
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 20, 2019
b36c25a
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 22, 2019
969f1cb
Merge remote-tracking branch 'cpython/master' into pep-578
zooba May 23, 2019
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
Prev Previous commit
Next Next commit
Fix socket events and add input event
  • Loading branch information
zooba committed May 8, 2019
commit a96e2259f239ebd0871aeaa1fbe7e9438ab4dcee
4 changes: 4 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ are always available. They are listed here in alphabetical order.
If the :mod:`readline` module was loaded, then :func:`input` will use it
to provide elaborate line editing and history features.

Raises an :func:`auditing event <sys.audit>` ``builtins.input`` with
argument ``prompt`` before reading input, and event ``builtins.input.result``
with the result after successfully reading input.


.. class:: int([x])
int(x, base=10)
Expand Down
21 changes: 11 additions & 10 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ The following functions all create :ref:`socket objects <socket-objects>`.
The newly created socket is :ref:`non-inheritable <fd_inheritance>`.

Creating a socket raises an :func:`auditing event <sys.audit>`
``socket.__new__`` with arguments ``family``, ``type``, ``protocol``.
``socket.__new__`` with arguments ``self``, ``family``, ``type``,
``protocol``.

.. versionchanged:: 3.3
The AF_CAN family was added.
Expand Down Expand Up @@ -1108,8 +1109,8 @@ to sockets.
Bind the socket to *address*. The socket must not already be bound. (The format
of *address* depends on the address family --- see above.)

Raises an :func:`auditing event <sys.audit>` ``socket.bind`` with argument
``address`` as provided in the call.
Raises an :func:`auditing event <sys.audit>` ``socket.bind`` with arguments
``self`` and ``address`` as provided in the call.

.. method:: socket.close()

Expand Down Expand Up @@ -1147,8 +1148,8 @@ to sockets.
:exc:`InterruptedError` exception if the connection is interrupted by a
signal (or the exception raised by the signal handler).

Raises an :func:`auditing event <sys.audit>` ``socket.connect`` with argument
``address`` as provided in the call.
Raises an :func:`auditing event <sys.audit>` ``socket.connect`` with arguments
``self`` and ``address`` as provided in the call.

.. versionchanged:: 3.5
The method now waits until the connection completes instead of raising an
Expand All @@ -1166,8 +1167,8 @@ to sockets.
:c:data:`errno` variable. This is useful to support, for example, asynchronous
connects.

Raises an :func:`auditing event <sys.audit>` ``socket.connect`` with argument
``address`` as provided in the call.
Raises an :func:`auditing event <sys.audit>` ``socket.connect`` with arguments
``self`` and ``address`` as provided in the call.

.. method:: socket.detach()

Expand Down Expand Up @@ -1509,8 +1510,8 @@ to sockets.
bytes sent. (The format of *address* depends on the address family --- see
above.)

Raises an :func:`auditing event <sys.audit>` ``socket.sendto`` with argument
``address`` as provided in the call.
Raises an :func:`auditing event <sys.audit>` ``socket.sendto`` with arguments
``self`` and ``address`` as provided in the call.

.. versionchanged:: 3.5
If the system call is interrupted and the signal handler does not raise
Expand Down Expand Up @@ -1552,7 +1553,7 @@ to sockets.
.. availability:: most Unix platforms, possibly others.

Raises an :func:`auditing event <sys.audit>` ``socket.sendmsg`` with
argument ``address`` if, and only if, it was provided in the call.
arguments ``self`` and ``address``.

.. versionadded:: 3.3

Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_xml_etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,11 @@ def test_find_through_ElementTree(self):
it = ET.ElementTree(e).findall('//tag')
self.assertEqual(summarize_list(it), ['tag'] * 3)

def test_find_attribute_with_empty_ns(self):
NS = "http://effbot.org/ns"
element = ET.fromstring(f"""<body xmlns="{NS}"><section id="1"/></body>""")
self.assertIsNotNone(element.find("t:section[@id='1']", {"":NS, "t":NS}))


class ElementIterTest(unittest.TestCase):
def _ilist(self, elem, tag=None):
Expand Down
8 changes: 6 additions & 2 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4401,6 +4401,10 @@ sock_sendmsg(PySocketSockObject *s, PyObject *args)
}
msg.msg_name = &addrbuf;
msg.msg_namelen = addrlen;
} else {
if (PySys_Audit("socket.sendmsg", "OO", s, Py_None) < 0) {
return NULL;
}
}

/* Fill in an iovec for each message part, and save the Py_buffer
Expand Down Expand Up @@ -5055,8 +5059,8 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
if (fdobj != NULL && fdobj != Py_None)
#endif
{
if (PySys_Audit("socket.__new__", "iii",
family, type, proto) < 0) {
if (PySys_Audit("socket.__new__", "Oiii",
s, family, type, proto) < 0) {
return -1;
}
}
Expand Down
3 changes: 1 addition & 2 deletions PC/layout/support/appxmanifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def public(f):
)

APPXMANIFEST_NS = {
"": "http://schemas.microsoft.com/appx/manifest/foundation/windows10",
"m": "http://schemas.microsoft.com/appx/manifest/foundation/windows10",
"uap": "http://schemas.microsoft.com/appx/manifest/uap/windows10",
"rescap": "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities",
Expand Down Expand Up @@ -330,7 +329,7 @@ def add_application(
suffix = "_d.exe" if ns.debug else ".exe"
app = ET.SubElement(
node,
ET.QName(APPXMANIFEST_NS[""], "Application"),
ET.QName(APPXMANIFEST_NS["m"], "Application"),
{
"Id": appid,
"Executable": executable + suffix,
Expand Down
15 changes: 13 additions & 2 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,

if (PyCode_GetNumFree((PyCodeObject *)source) > 0) {
PyErr_SetString(PyExc_TypeError,
"code object passed to eval() may not contain free variables");
"code object passed to eval() may not contain free variables");
return NULL;
}
return PyEval_EvalCode(source, globals, locals);
Expand Down Expand Up @@ -1217,7 +1217,7 @@ builtin_id(PyModuleDef *self, PyObject *v)
{
PyObject *id = PyLong_FromVoidPtr(v);

if (id && PySys_Audit("id", "O", id) < 0) {
if (id && PySys_Audit("builtins.id", "O", id) < 0) {
Py_DECREF(id);
return NULL;
}
Expand Down Expand Up @@ -2001,6 +2001,10 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
return NULL;
}

if (PySys_Audit("builtins.input", "O", prompt ? prompt : Py_None) < 0) {
return NULL;
}

/* First of all, flush stderr */
tmp = _PyObject_CallMethodId(ferr, &PyId_flush, NULL);
if (tmp == NULL)
Expand Down Expand Up @@ -2131,6 +2135,13 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
Py_DECREF(stdin_errors);
Py_XDECREF(po);
PyMem_FREE(s);

if (result != NULL) {
if (PySys_Audit("builtins.input.result", "O", result) < 0) {
return NULL;
}
}

return result;

_readline_errors:
Expand Down