[Python-checkins] bpo-38723: Pdb._runscript should use io.open_code() instead of open() (GH-17127)

Miss Islington (bot) webhook-mailer at python.org
Tue Nov 12 18:09:12 EST 2019


https://github.com/python/cpython/commit/0a8e7fde064c8fb6eb8e78752d4bcdab56643065
commit: 0a8e7fde064c8fb6eb8e78752d4bcdab56643065
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-11-12T15:09:03-08:00
summary:

bpo-38723: Pdb._runscript should use io.open_code() instead of open() (GH-17127)


Co-Authored-By: Brandt Bucher <brandtbucher at gmail.com>
(cherry picked from commit d593881505c1f4acfd17f41312b27cc898451816)

Co-authored-by: jsnklln <jsnklln at gmail.com>

files:
A Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst
M Lib/pdb.py

diff --git a/Lib/pdb.py b/Lib/pdb.py
index 8639204891cb0..bf503f1e73ee1 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -68,6 +68,7 @@
 # commands and is appended to __doc__ after the class has been defined.
 
 import os
+import io
 import re
 import sys
 import cmd
@@ -1565,7 +1566,7 @@ def _runscript(self, filename):
         self._wait_for_mainpyfile = True
         self.mainpyfile = self.canonic(filename)
         self._user_requested_quit = False
-        with open(filename, "rb") as fp:
+        with io.open_code(filename) as fp:
             statement = "exec(compile(%r, %r, 'exec'))" % \
                         (fp.read(), self.mainpyfile)
         self.run(statement)
diff --git a/Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst b/Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst
new file mode 100644
index 0000000000000..c84bb8589d303
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst
@@ -0,0 +1 @@
+:mod:`pdb` now uses :meth:`io.open_code` to trigger auditing events.



More information about the Python-checkins mailing list