Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.5 Changeset: r87281:a014e942245e Date: 2016-09-21 17:16 +0100 http://bitbucket.org/pypy/pypy/changeset/a014e942245e/
Log: Use built-in module _operator to define built-in functions bin(), oct(), hex(). This should prevent potential bootstrapping issues caused by trying to import pure-Python stdlib modules too early. Also, mark _operator as an essential module. diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -16,7 +16,7 @@ essential_modules = set([ "exceptions", "_io", "sys", "builtins", "posix", "_warnings", - "itertools", "_frozen_importlib", + "itertools", "_frozen_importlib", "operator", ]) if sys.platform == "win32": essential_modules.add("_winreg") @@ -24,7 +24,7 @@ default_modules = essential_modules.copy() default_modules.update([ "_codecs", "atexit", "gc", "_weakref", "marshal", "errno", "imp", - "itertools", "math", "cmath", "_sre", "_pickle_support", "operator", + "itertools", "math", "cmath", "_sre", "_pickle_support", "parser", "symbol", "token", "_ast", "_random", "__pypy__", "_string", "_testing", "time" ]) diff --git a/pypy/module/__builtin__/app_operation.py b/pypy/module/__builtin__/app_operation.py --- a/pypy/module/__builtin__/app_operation.py +++ b/pypy/module/__builtin__/app_operation.py @@ -1,16 +1,16 @@ -import operator +import _operator def bin(x): """Return the binary representation of an integer.""" - value = operator.index(x) + value = _operator.index(x) return value.__format__("#b") def oct(x): """Return the octal representation of an integer.""" - x = operator.index(x) + x = _operator.index(x) return x.__format__("#o") def hex(x): """Return the hexadecimal representation of an integer.""" - x = operator.index(x) + x = _operator.index(x) return x.__format__("#x") diff --git a/pypy/module/operator/test/test_operator.py b/pypy/module/operator/test/test_operator.py --- a/pypy/module/operator/test/test_operator.py +++ b/pypy/module/operator/test/test_operator.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- class AppTestOperator: - spaceconfig = dict(usemodules=['operator']) - def test_getters_are_not_regular_functions(self): import _operator as operator class A(object): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit