bpo-37316: mmap.mmap() passes the wrong variable to PySys_Audit() (GH-14152)
Also, add a missing call to va_end() in PySys_Audit().
This commit is contained in:
parent
43615485f1
commit
6c7947713a
|
@ -261,6 +261,13 @@ def test_cantrace():
|
||||||
assertSequenceEqual(["call"] * 4, traced)
|
assertSequenceEqual(["call"] * 4, traced)
|
||||||
|
|
||||||
|
|
||||||
|
def test_mmap():
|
||||||
|
import mmap
|
||||||
|
with TestHook() as hook:
|
||||||
|
mmap.mmap(-1, 8)
|
||||||
|
assertEqual(hook.seen[0][1][:2], (-1, 8))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from test.libregrtest.setup import suppress_msvcrt_asserts
|
from test.libregrtest.setup import suppress_msvcrt_asserts
|
||||||
suppress_msvcrt_asserts(False)
|
suppress_msvcrt_asserts(False)
|
||||||
|
|
|
@ -74,6 +74,9 @@ class AuditTest(unittest.TestCase):
|
||||||
def test_cantrace(self):
|
def test_cantrace(self):
|
||||||
self.do_test("test_cantrace")
|
self.do_test("test_cantrace")
|
||||||
|
|
||||||
|
def test_mmap(self):
|
||||||
|
self.do_test("test_mmap")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix the :c:func:`PySys_Audit` call in :class:`mmap.mmap`.
|
|
@ -1154,7 +1154,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PySys_Audit("mmap.__new__", "ini" _Py_PARSE_OFF_T,
|
if (PySys_Audit("mmap.__new__", "ini" _Py_PARSE_OFF_T,
|
||||||
fileno, map_size, access, offset) < 0) {
|
fd, map_size, access, offset) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ PySys_Audit(const char *event, const char *argFormat, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, argFormat);
|
va_start(args, argFormat);
|
||||||
eventArgs = Py_VaBuildValue(argFormat, args);
|
eventArgs = Py_VaBuildValue(argFormat, args);
|
||||||
|
va_end(args);
|
||||||
if (eventArgs && !PyTuple_Check(eventArgs)) {
|
if (eventArgs && !PyTuple_Check(eventArgs)) {
|
||||||
PyObject *argTuple = PyTuple_Pack(1, eventArgs);
|
PyObject *argTuple = PyTuple_Pack(1, eventArgs);
|
||||||
Py_DECREF(eventArgs);
|
Py_DECREF(eventArgs);
|
||||||
|
|
Loading…
Reference in New Issue