[Python-checkins] bpo-38149: Call sys.audit() only once per call for glob.glob(). (GH-18360)

Serhiy Storchaka webhook-mailer at python.org
Thu Feb 6 03:26:42 EST 2020


https://github.com/python/cpython/commit/54b4f14712b9350f11c983f1c8ac47a3716958a7
commit: 54b4f14712b9350f11c983f1c8ac47a3716958a7
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-02-06T10:26:37+02:00
summary:

bpo-38149: Call sys.audit() only once per call for glob.glob(). (GH-18360)

files:
A Misc/NEWS.d/next/Library/2020-02-05-11-24-16.bpo-38149.GWsjHE.rst
M Lib/glob.py

diff --git a/Lib/glob.py b/Lib/glob.py
index 0b3fcc6bbb9af..0dd2f8be66109 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -31,6 +31,7 @@ def iglob(pathname, *, recursive=False):
     If recursive is true, the pattern '**' will match any files and
     zero or more directories and subdirectories.
     """
+    sys.audit("glob.glob", pathname, recursive)
     it = _iglob(pathname, recursive, False)
     if recursive and _isrecursive(pathname):
         s = next(it)  # skip empty string
@@ -38,7 +39,6 @@ def iglob(pathname, *, recursive=False):
     return it
 
 def _iglob(pathname, recursive, dironly):
-    sys.audit("glob.glob", pathname, recursive)
     dirname, basename = os.path.split(pathname)
     if not has_magic(pathname):
         assert not dironly
diff --git a/Misc/NEWS.d/next/Library/2020-02-05-11-24-16.bpo-38149.GWsjHE.rst b/Misc/NEWS.d/next/Library/2020-02-05-11-24-16.bpo-38149.GWsjHE.rst
new file mode 100644
index 0000000000000..b4ec60b2abad1
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-02-05-11-24-16.bpo-38149.GWsjHE.rst
@@ -0,0 +1,2 @@
+:func:`sys.audit` is now called only once per call of :func:`glob.glob` and
+:func:`glob.iglob`.



More information about the Python-checkins mailing list