bpo-41058: Use source file encoding in pdb.find_function(). (GH-21010)

This commit is contained in:
Serhiy Storchaka 2020-06-21 11:07:50 +03:00 committed by GitHub
parent 6c4e0bd974
commit 19fcffa927
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 14 deletions

View file

@ -79,6 +79,7 @@ import glob
import pprint
import signal
import inspect
import tokenize
import traceback
import linecache
@ -93,7 +94,7 @@ __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
def find_function(funcname, filename):
cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
try:
fp = open(filename)
fp = tokenize.open(filename)
except OSError:
return None
# consumer of this info expects the first line to be 1