diff options
author | AlexSm <alex@ydb.tech> | 2024-05-06 18:27:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-06 18:27:11 +0200 |
commit | 068e8291de67631f063304b76dda3c1fd6601c12 (patch) | |
tree | f9058c69ef88f04c55ff9c92949dffa8cd6b83a5 /contrib/tools/python3/Lib/pdb.py | |
parent | 653a427438ab0fa69068180c34233b015af0d405 (diff) | |
parent | 41f0129e44731de1ba129fbae27008f8a4048fdc (diff) | |
download | ydb-068e8291de67631f063304b76dda3c1fd6601c12.tar.gz |
Merge pull request #4325 from ydb-platform/mergelibs-240506-1255
Library import 240506-1255
Diffstat (limited to 'contrib/tools/python3/Lib/pdb.py')
-rwxr-xr-x | contrib/tools/python3/Lib/pdb.py | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/contrib/tools/python3/Lib/pdb.py b/contrib/tools/python3/Lib/pdb.py index a838a26b03..225c9f253e 100755 --- a/contrib/tools/python3/Lib/pdb.py +++ b/contrib/tools/python3/Lib/pdb.py @@ -154,6 +154,7 @@ class _ScriptTarget(str): __name__='__main__', __file__=self, __builtins__=__builtins__, + __spec__=None, ) @property @@ -298,26 +299,13 @@ class Pdb(bdb.Bdb, cmd.Cmd): # cache it here to ensure that modifications are not overwritten. self.curframe_locals = self.curframe.f_locals self.set_convenience_variable(self.curframe, '_frame', self.curframe) - return self.execRcLines() - # Can be executed earlier than 'setup' if desired - def execRcLines(self): - if not self.rcLines: - return - # local copy because of recursion - rcLines = self.rcLines - rcLines.reverse() - # execute every line only once - self.rcLines = [] - while rcLines: - line = rcLines.pop().strip() - if line and line[0] != '#': - if self.onecmd(line): - # if onecmd returns True, the command wants to exit - # from the interaction, save leftover rc lines - # to execute before next interaction - self.rcLines += reversed(rcLines) - return True + if self.rcLines: + self.cmdqueue = [ + line for line in self.rcLines + if line.strip() and not line.strip().startswith("#") + ] + self.rcLines = [] # Override Bdb methods @@ -430,12 +418,10 @@ class Pdb(bdb.Bdb, cmd.Cmd): pass else: Pdb._previous_sigint_handler = None - if self.setup(frame, traceback): - # no interaction desired at this time (happens if .pdbrc contains - # a command like "continue") - self.forget() - return - self.print_stack_entry(self.stack[self.curindex]) + self.setup(frame, traceback) + # if we have more commands to process, do not show the stack entry + if not self.cmdqueue: + self.print_stack_entry(self.stack[self.curindex]) self._cmdloop() self.forget() @@ -522,7 +508,7 @@ class Pdb(bdb.Bdb, cmd.Cmd): if marker >= 0: # queue up everything after marker next = line[marker+2:].lstrip() - self.cmdqueue.append(next) + self.cmdqueue.insert(0, next) line = line[:marker].rstrip() # Replace all the convenience variables @@ -546,13 +532,12 @@ class Pdb(bdb.Bdb, cmd.Cmd): """Handles one command line during command list definition.""" cmd, arg, line = self.parseline(line) if not cmd: - return + return False if cmd == 'silent': self.commands_silent[self.commands_bnum] = True - return # continue to handle other cmd def in the cmd list + return False # continue to handle other cmd def in the cmd list elif cmd == 'end': - self.cmdqueue = [] - return 1 # end of cmd list + return True # end of cmd list cmdlist = self.commands[self.commands_bnum] if arg: cmdlist.append(cmd+' '+arg) @@ -566,9 +551,8 @@ class Pdb(bdb.Bdb, cmd.Cmd): # one of the resuming commands if func.__name__ in self.commands_resuming: self.commands_doprompt[self.commands_bnum] = False - self.cmdqueue = [] - return 1 - return + return True + return False # interface abstraction functions |