From c1fceaf9827d650d90da54ac7e8dfd75e5f3fae8 Mon Sep 17 00:00:00 2001 From: Jason Killen Date: Tue, 12 Nov 2019 09:50:13 -0500 Subject: [PATCH 1/3] bpo-38723: Pdb._runscript should use io.open_code() instead of open() From the io.open_code documentation: This function should be used when the intent is to treat the contents as executable code. --- Lib/pdb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/pdb.py b/Lib/pdb.py index 8639204891cb01..bf503f1e73ee14 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) From 743345ef59a64df7662e9a1d2628946e0c0e3f51 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2019 15:46:29 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst 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 00000000000000..e19b18ae68d7fd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst @@ -0,0 +1 @@ +pdb now uses io.open_code \ No newline at end of file From b7b630caca24431164389d1ceaaeb6f2256cb155 Mon Sep 17 00:00:00 2001 From: jsnklln Date: Tue, 12 Nov 2019 12:53:49 -0500 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst Co-Authored-By: Brandt Bucher --- .../next/Library/2019-11-12-15-46-28.bpo-38723.gcdMFn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index e19b18ae68d7fd..c84bb8589d3034 100644 --- 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 @@ -1 +1 @@ -pdb now uses io.open_code \ No newline at end of file +:mod:`pdb` now uses :meth:`io.open_code` to trigger auditing events.