diff options
author | Brett Cannon <brett@python.org> | 2013-04-09 20:59:39 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-04-09 20:59:39 (GMT) |
commit | 100883f0cbccb936b928ddaa962c967296455af3 (patch) | |
tree | c4baf0d78f3d16a33849efdcdbf2d624b3db1070 /Lib/importlib/_bootstrap.py | |
parent | 0f344b6e0526245249b80219e6001616307d2b35 (diff) | |
download | cpython-100883f0cbccb936b928ddaa962c967296455af3.zip cpython-100883f0cbccb936b928ddaa962c967296455af3.tar.gz cpython-100883f0cbccb936b928ddaa962c967296455af3.tar.bz2 |
Issue #17093,17566,17567: Methods from classes in importlib.abc now raise/return
the default exception/value when called instead of raising/returning
NotimplementedError/NotImplemented (except where appropriate).
This should allow for the ABCs to act as the bottom/end of the MRO with expected
default results.
As part of this work, also make importlib.abc.Loader.module_repr()
optional instead of an abstractmethod.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index e2ac7ce..03ca79f 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -893,8 +893,10 @@ class SourceLoader(_LoaderBasics): def path_mtime(self, path): """Optional method that returns the modification time (an int) for the specified path, where path is a str. + + Raises IOError when the path cannot be handled. """ - raise NotImplementedError + raise IOError def path_stats(self, path): """Optional method returning a metadata dict for the specified path @@ -905,6 +907,7 @@ class SourceLoader(_LoaderBasics): - 'size' (optional) is the size in bytes of the source code. Implementing this method allows the loader to read bytecode files. + Raises IOError when the path cannot be handled. """ return {'mtime': self.path_mtime(path)} @@ -922,9 +925,7 @@ class SourceLoader(_LoaderBasics): """Optional method which writes data (bytes) to a file path (a str). Implementing this method allows for the writing of bytecode files. - """ - raise NotImplementedError def get_source(self, fullname): @@ -973,7 +974,7 @@ class SourceLoader(_LoaderBasics): else: try: st = self.path_stats(source_path) - except NotImplementedError: + except IOError: pass else: source_mtime = int(st['mtime']) |