mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
doctest assumed that a package's __loader__.get_data() method used universal
newlines; it doesn't. To rectify this the string returned replaces all instances of os.linesep with '\n' to fake universal newline support. Backport candidate.
This commit is contained in:
parent
901071bde5
commit
43e53f85b6
3 changed files with 24 additions and 1 deletions
|
@ -209,7 +209,10 @@ def _load_testfile(filename, package, module_relative):
|
|||
filename = _module_relative_path(package, filename)
|
||||
if hasattr(package, '__loader__'):
|
||||
if hasattr(package.__loader__, 'get_data'):
|
||||
return package.__loader__.get_data(filename), filename
|
||||
file_contents = package.__loader__.get_data(filename)
|
||||
# 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).read(), filename
|
||||
|
||||
def _indent(s, indent=4):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue