aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
authorPierre Ossman (ThinLinc team) <ossman@cendio.se>2024-02-28 02:39:08 +0100
committerGitHub <noreply@github.com>2024-02-27 17:39:08 -0800
commit5a1559d9493dd298a08c4be32b52295aa3eb89e5 (patch)
tree013e044debb168ed58b68e7c7d75aeec3a9ae626 /Lib/test/test_asyncio/test_events.py
parenta355f60b032306651ca27bc53bbb82eb5106ff71 (diff)
downloadcpython-5a1559d9493dd298a08c4be32b52295aa3eb89e5.tar.gz
cpython-5a1559d9493dd298a08c4be32b52295aa3eb89e5.zip
gh-112997: Don't log arguments in asyncio unless debugging (#115667)
Nothing else in Python generally logs the contents of variables, so this can be very unexpected for developers and could leak sensitive information in to terminals and log files.
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index c92c88bd5b2..5b9c871e1d1 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -2250,7 +2250,7 @@ class HandleTests(test_utils.TestCase):
h = asyncio.Handle(noop, (1, 2), self.loop)
filename, lineno = test_utils.get_function_source(noop)
self.assertEqual(repr(h),
- '<Handle noop(1, 2) at %s:%s>'
+ '<Handle noop() at %s:%s>'
% (filename, lineno))
# cancelled handle
@@ -2268,14 +2268,14 @@ class HandleTests(test_utils.TestCase):
# partial function
cb = functools.partial(noop, 1, 2)
h = asyncio.Handle(cb, (3,), self.loop)
- regex = (r'^<Handle noop\(1, 2\)\(3\) at %s:%s>$'
+ regex = (r'^<Handle noop\(\)\(\) at %s:%s>$'
% (re.escape(filename), lineno))
self.assertRegex(repr(h), regex)
# partial function with keyword args
cb = functools.partial(noop, x=1)
h = asyncio.Handle(cb, (2, 3), self.loop)
- regex = (r'^<Handle noop\(x=1\)\(2, 3\) at %s:%s>$'
+ regex = (r'^<Handle noop\(\)\(\) at %s:%s>$'
% (re.escape(filename), lineno))
self.assertRegex(repr(h), regex)
@@ -2316,6 +2316,24 @@ class HandleTests(test_utils.TestCase):
'<Handle cancelled noop(1, 2) at %s:%s created at %s:%s>'
% (filename, lineno, create_filename, create_lineno))
+ # partial function
+ cb = functools.partial(noop, 1, 2)
+ create_lineno = sys._getframe().f_lineno + 1
+ h = asyncio.Handle(cb, (3,), self.loop)
+ regex = (r'^<Handle noop\(1, 2\)\(3\) at %s:%s created at %s:%s>$'
+ % (re.escape(filename), lineno,
+ re.escape(create_filename), create_lineno))
+ self.assertRegex(repr(h), regex)
+
+ # partial function with keyword args
+ cb = functools.partial(noop, x=1)
+ create_lineno = sys._getframe().f_lineno + 1
+ h = asyncio.Handle(cb, (2, 3), self.loop)
+ regex = (r'^<Handle noop\(x=1\)\(2, 3\) at %s:%s created at %s:%s>$'
+ % (re.escape(filename), lineno,
+ re.escape(create_filename), create_lineno))
+ self.assertRegex(repr(h), regex)
+
def test_handle_source_traceback(self):
loop = asyncio.get_event_loop_policy().new_event_loop()
loop.set_debug(True)