Make _load_testfile() use its encoding argument when __loader__ is defined.

This commit is contained in:
Brett Cannon 2007-10-12 19:18:19 +00:00
parent 5c5f1703e5
commit e9fd23165c
2 changed files with 10 additions and 1 deletions

View file

@ -209,7 +209,8 @@ 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('utf-8'), filename
return (package.__loader__.get_data(filename).decode(encoding),
filename)
return open(filename, encoding=encoding).read(), filename
def _indent(s, indent=4):