Commit c4c1fd32 authored by Benjamin Peterson's avatar Benjamin Peterson

merge heads

parents c06934bc 12d8c4d2
...@@ -411,25 +411,21 @@ SOURCE_SUFFIXES = ['.py'] # _setup() adds .pyw as needed. ...@@ -411,25 +411,21 @@ SOURCE_SUFFIXES = ['.py'] # _setup() adds .pyw as needed.
DEBUG_BYTECODE_SUFFIXES = ['.pyc'] DEBUG_BYTECODE_SUFFIXES = ['.pyc']
OPTIMIZED_BYTECODE_SUFFIXES = ['.pyo'] OPTIMIZED_BYTECODE_SUFFIXES = ['.pyo']
if __debug__:
BYTECODE_SUFFIXES = DEBUG_BYTECODE_SUFFIXES
else:
BYTECODE_SUFFIXES = OPTIMIZED_BYTECODE_SUFFIXES
def cache_from_source(path, debug_override=None): def cache_from_source(path, debug_override=None):
"""Given the path to a .py file, return the path to its .pyc/.pyo file. """Given the path to a .py file, return the path to its .pyc/.pyo file.
The .py file does not need to exist; this simply returns the path to the The .py file does not need to exist; this simply returns the path to the
.pyc/.pyo file calculated as if the .py file were imported. The extension .pyc/.pyo file calculated as if the .py file were imported. The extension
will be .pyc unless __debug__ is not defined, then it will be .pyo. will be .pyc unless sys.flags.optimize is non-zero, then it will be .pyo.
If debug_override is not None, then it must be a boolean and is taken as If debug_override is not None, then it must be a boolean and is taken as
the value of __debug__ instead. the value of bool(sys.flags.optimize) instead.
If sys.implementation.cache_tag is None then NotImplementedError is raised. If sys.implementation.cache_tag is None then NotImplementedError is raised.
""" """
debug = __debug__ if debug_override is None else debug_override debug = not sys.flags.optimize if debug_override is None else debug_override
if debug: if debug:
suffixes = DEBUG_BYTECODE_SUFFIXES suffixes = DEBUG_BYTECODE_SUFFIXES
else: else:
...@@ -1688,10 +1684,15 @@ def _setup(sys_module, _imp_module): ...@@ -1688,10 +1684,15 @@ def _setup(sys_module, _imp_module):
modules, those two modules must be explicitly passed in. modules, those two modules must be explicitly passed in.
""" """
global _imp, sys global _imp, sys, BYTECODE_SUFFIXES
_imp = _imp_module _imp = _imp_module
sys = sys_module sys = sys_module
if sys.flags.optimize:
BYTECODE_SUFFIXES = OPTIMIZED_BYTECODE_SUFFIXES
else:
BYTECODE_SUFFIXES = DEBUG_BYTECODE_SUFFIXES
for module in (_imp, sys): for module in (_imp, sys):
if not hasattr(module, '__loader__'): if not hasattr(module, '__loader__'):
module.__loader__ = BuiltinImporter module.__loader__ = BuiltinImporter
......
...@@ -10,6 +10,8 @@ What's New in Python 3.3.1? ...@@ -10,6 +10,8 @@ What's New in Python 3.3.1?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #16046: Fix loading sourceless legacy pyos.
- Issue #15379: Fix passing of non-BMP characters as integers for the charmap - Issue #15379: Fix passing of non-BMP characters as integers for the charmap
decoder (already working as unicode strings). Patch by Serhiy Storchaka. decoder (already working as unicode strings). Patch by Serhiy Storchaka.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment