Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r87240:6524139cfc98 Date: 2016-09-20 12:08 +0200 http://bitbucket.org/pypy/pypy/changeset/6524139cfc98/
Log: Issue #2400: Rename the interp-level module to '_operator' diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -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", "_operator", "parser", "symbol", "token", "_ast", "_random", "__pypy__", "_string", "_testing", "time" ]) diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -890,8 +890,8 @@ import runpy if 'time' not in sys.builtin_module_names: import time; del time - if 'operator' not in sys.builtin_module_names: - import operator; del operator + if '_operator' not in sys.builtin_module_names: + import _operator; del _operator # no one should change to which lists sys.argv and sys.path are bound old_argv = sys.argv diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py --- a/pypy/module/operator/__init__.py +++ b/pypy/module/operator/__init__.py @@ -2,6 +2,7 @@ class Module(MixedModule): """Operator Builtin Module. """ + applevel_name = '_operator' # HACK! override loaders to be able to access different operations # under same name. I.e., operator.eq == operator.__eq__ 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,12 +1,14 @@ # -*- coding: utf-8 -*- class AppTestOperator: + spaceconfig = dict(usemodules=['operator']) + def test_equality(self): - import operator + import _operator as operator assert operator.eq == operator.__eq__ def test_getters_are_not_regular_functions(self): - import operator + import _operator as operator class A(object): getx = operator.attrgetter('x') get3 = operator.itemgetter(3) @@ -21,7 +23,7 @@ assert l == ["x"] def test_getter_multiple_gest(self): - import operator + import _operator as operator class A(object): pass @@ -40,11 +42,11 @@ raises(TypeError, operator.itemgetter(2, 'x', 5), data) def test_attrgetter(self): - import operator + import _operator as operator raises(TypeError, operator.attrgetter, 2) def test_dotted_attrgetter(self): - from operator import attrgetter + from _operator import attrgetter class A: pass a = A() @@ -56,7 +58,7 @@ assert attrgetter("child.name", "child.foo")(a) == ("world", "bar") def test_attrgetter_type(self): - from operator import attrgetter + from _operator import attrgetter assert type(attrgetter("child.name")) is attrgetter def test_concat(self): @@ -88,7 +90,7 @@ def __rmul__(self, other): return other * self.lst - import operator + import _operator as operator raises(TypeError, operator.concat) raises(TypeError, operator.concat, None, None) @@ -127,7 +129,7 @@ def __rmul__(self, other): return other * self.lst - import operator + import _operator as operator a = list(range(3)) raises(TypeError, operator.mul) @@ -153,14 +155,14 @@ assert operator.mul(a, 0) == [] def test_iadd(self): - import operator + import _operator as operator list = [] assert operator.iadd(list, [1, 2]) is list assert list == [1, 2] def test_imul(self): - import operator + import _operator as operator class X(object): def __index__(self): @@ -176,7 +178,7 @@ assert a == [0, 1, 2, 0, 1, 2] def test_methodcaller(self): - from operator import methodcaller + from _operator import methodcaller class X(object): def method(self, arg1=2, arg2=3): return arg1, arg2 @@ -187,7 +189,7 @@ assert methodcaller("method", 4, arg2=42)(x) == (4, 42) def test_index(self): - import operator + import _operator as operator assert operator.index(42) == 42 assert operator.__index__(42) == 42 raises(TypeError, operator.index, "abc") @@ -195,14 +197,14 @@ assert str(exc.value) == "'str' object cannot be interpreted as an integer" def test_indexOf(self): - import operator + import _operator as operator raises(TypeError, operator.indexOf) raises(TypeError, operator.indexOf, None, None) assert operator.indexOf([4, 3, 2, 1], 3) == 1 raises(ValueError, operator.indexOf, [4, 3, 2, 1], 0) def test_compare_digest(self): - import operator + import _operator as operator # Testing input type exception handling a, b = 100, 200 @@ -309,7 +311,7 @@ assert not operator._compare_digest(a, b) def test_compare_digest_unicode(self): - import operator + import _operator as operator assert operator._compare_digest(u'asd', u'asd') assert not operator._compare_digest(u'asd', u'qwe') raises(TypeError, operator._compare_digest, u'asd', b'qwe') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit