8000 bpo-38723: Pdb._runscript should use io.open_code() instead of open() by jsnklln · Pull Request #17127 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
Jason Killen committed Nov 12, 2019
commit c1fceaf9827d650d90da54ac7e8dfd75e5f3fae8
3 changes: 2 additions & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
0