mirror of
https://github.com/python/cpython
synced 2026-09-29 08:25:30 +03:00
Make _load_testfile() use its encoding argument when __loader__ is defined.
This commit is contained in:
parent
5c5f1703e5
commit
e9fd23165c
2 changed files with 10 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@ Extension Modules
|
|||
- The `hotshot` profiler has been removed; use `cProfile` instead.
|
||||
|
||||
|
||||
Library
|
||||
-------
|
||||
|
||||
- When loading an external file using testfile(), the passed-in encoding
|
||||
argument was being ignored if __loader__ is defined and forcing the source to
|
||||
be UTF-8.
|
||||
|
||||
|
||||
What's New in Python 3.0a1?
|
||||
==========================
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue