@@ -1134,6 +1134,7 @@ def do_break(self, arg, temporary=False):
1134
1134
filename = None
1135
1135
lineno = None
1136
1136
cond = None
1137
+ module_globals = None
1137
1138
comma = arg .find (',' )
1138
1139
if comma > 0 :
1139
1140
# parse stuff after comma: "condition"
@@ -1179,6 +1180,7 @@ def do_break(self, arg, temporary=False):
1179
1180
funcname = code .co_name
1180
1181
lineno = find_first_executable_line (code )
1181
1182
filename = code .co_filename
1183
+ module_globals = func .__globals__
1182
1184
except :
1183
1185
# last thing to try
1184
1186
(ok , filename , ln ) = self .lineinfo (arg )
@@ -1190,8 +1192,9 @@ def do_break(self, arg, temporary=False):
1190
1192
lineno = int (ln )
1191
1193
if not filename :
1192
1194
filename = self .defaultFile ()
1195
+ filename = self .canonic (filename )
1193
1196
# Check for reasonable breakpoint
1194
- line = self .checkline (filename , lineno )
1197
+ line = self .checkline (filename , lineno , module_globals )
1195
1198
if line :
1196
1199
# now set the break point
1197
1200
err = self .set_break (filename , line , temporary , cond , funcname )
@@ -1258,7 +1261,7 @@ def lineinfo(self, identifier):
1258
1261
answer = find_function (item , self .canonic (fname ))
1259
1262
return answer or failed
1260
1263
1261
- def checkline (self , filename , lineno ):
1264
+ def checkline (self , filename , lineno , module_globals = None ):
1262
1265
"""Check whether specified line seems to be executable.
1263
1266
1264
1267
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
@@ -1267,8 +1270,9 @@ def checkline(self, filename, lineno):
1267
1270
# this method should be callable before starting debugging, so default
1268
1271
# to "no globals" if there is no current frame
1269
1272
frame = getattr (self , 'curframe' , None )
1270
- globs = frame .f_globals if frame else None
1271
- line = linecache .getline (filename , lineno , globs )
1273
+ if module_globals is None :
1274
+ module_globals = frame .f_globals if frame else None
1275
+ line = linecache .getline (filename , lineno , module_globals )
1272
1276
if not line :
1273
1277
self .message ('End of file' )
1274
1278
return 0
0 commit comments