diff options
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index 97bc053..eee2f51 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -209,8 +209,11 @@ def _load_testfile(filename, package, module_relative, encoding): filename = _module_relative_path(package, filename) if hasattr(package, '__loader__'): if hasattr(package.__loader__, 'get_data'): - return (package.__loader__.get_data(filename).decode(encoding), - filename) + file_contents = package.__loader__.get_data(filename) + file_contents = file_contents.decode(encoding) + # get_data() opens files as 'rb', so one must do the equivalent + # conversion as universal newlines would do. + return file_contents.replace(os.linesep, '\n'), filename return open(filename, encoding=encoding).read(), filename def _indent(s, indent=4): |