diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-13 17:52:16 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-13 17:52:16 (GMT) |
commit | 5136ac0ca21a05691978df8d0650f902c8ca3463 (patch) | |
tree | 4b5569dad3f1b36f115c673602dde6ff49eae5e0 /Lib/importlib/abc.py | |
parent | 1f918c1480a1566b774391bbc4ddf1d4153965a1 (diff) | |
download | cpython-5136ac0ca21a05691978df8d0650f902c8ca3463.zip cpython-5136ac0ca21a05691978df8d0650f902c8ca3463.tar.gz cpython-5136ac0ca21a05691978df8d0650f902c8ca3463.tar.bz2 |
Issue #13645: pyc files now contain the size of the corresponding source
code, to avoid timestamp collisions (especially on filesystems with a low
timestamp resolution) when checking for freshness of the bytecode.
Diffstat (limited to 'Lib/importlib/abc.py')
-rw-r--r-- | Lib/importlib/abc.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py index df8cd93..0d37629 100644 --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -123,7 +123,20 @@ class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader): def path_mtime(self, path): """Return the (int) modification time for the path (str).""" - raise NotImplementedError + if self.path_stats.__func__ is SourceLoader.path_stats: + raise NotImplementedError + return int(self.path_stats(path)['mtime']) + + def path_stats(self, path): + """Return a metadata dict for the source pointed to by the path (str). + Possible keys: + - 'mtime' (mandatory) is the numeric timestamp of last source + code modification; + - 'size' (optional) is the size in bytes of the source code. + """ + if self.path_mtime.__func__ is SourceLoader.path_mtime: + raise NotImplementedError + return {'mtime': self.path_mtime(path)} def set_data(self, path, data): """Write the bytes to the path (if possible). |