Skip to content
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
7 changes: 4 additions & 3 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,12 @@ def _cmdloop(self):
self.message('--KeyboardInterrupt--')

def _update_file_mtime(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name seems wrong - it's not "updating" the mtime if it's already there. It only sets it if it's not there.

Also, the docstring of _validate_file_mtime is no longer correct - it's not "since last time we saw it".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to init, do you think it's better? Also changed the docstring a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "save"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "save" better than "init"? Because I think save is similar to update. In this specific case, we only care for the entries that are not intialized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init sounds to me like you are initialising the actual file_mtime, rather than saving a copy of it. How about save_initial_file_mtime?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that makes sense. I thought about it and I don't think we need to put it in the command path now. We used to do that because we want the error message on every command. Now we can do it once in setup for all the frames and leave onecmd alone.

"""update the file mtime table with the current frame's file"""
"""update the file mtime table with the current frame's file if it
hasn't been seen yet."""
try:
filename = self.curframe.f_code.co_filename
mtime = os.path.getmtime(filename)
self._file_mtime_table.setdefault(filename, mtime)
if filename not in self._file_mtime_table:
self._file_mtime_table[filename] = os.path.getmtime(filename)
except Exception:
return

Expand Down
Loading