@@ -1134,6 +1134,7 @@ def do_break(self, arg, temporary=False):
11341134 filename = None
11351135 lineno = None
11361136 cond = None
1137+ module_globals = None
11371138 comma = arg .find (',' )
11381139 if comma > 0 :
11391140 # parse stuff after comma: "condition"
@@ -1179,6 +1180,7 @@ def do_break(self, arg, temporary=False):
11791180 funcname = code .co_name
11801181 lineno = find_first_executable_line (code )
11811182 filename = code .co_filename
1183+ module_globals = func .__globals__
11821184 except :
11831185 # last thing to try
11841186 (ok , filename , ln ) = self .lineinfo (arg )
@@ -1190,8 +1192,9 @@ def do_break(self, arg, temporary=False):
11901192 lineno = int (ln )
11911193 if not filename :
11921194 filename = self .defaultFile ()
1195+ filename = self .canonic (filename )
11931196 # Check for reasonable breakpoint
1194- line = self .checkline (filename , lineno )
1197+ line = self .checkline (filename , lineno , module_globals )
11951198 if line :
11961199 # now set the break point
11971200 err = self .set_break (filename , line , temporary , cond , funcname )
@@ -1258,7 +1261,7 @@ def lineinfo(self, identifier):
12581261 answer = find_function (item , self .canonic (fname ))
12591262 return answer or failed
12601263
1261- def checkline (self , filename , lineno ):
1264+ def checkline (self , filename , lineno , module_globals = None ):
12621265 """Check whether specified line seems to be executable.
12631266
12641267 Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
@@ -1267,8 +1270,9 @@ def checkline(self, filename, lineno):
12671270 # this method should be callable before starting debugging, so default
12681271 # to "no globals" if there is no current frame
12691272 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 )
12721276 if not line :
12731277 self .message ('End of file' )
12741278 return 0
0 commit comments