diff options
author | Raymond Hettinger <python@rcn.com> | 2015-11-02 05:39:56 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-11-02 05:39:56 (GMT) |
commit | a1fc949b5ab8911a803eee691e6eea55cec43eeb (patch) | |
tree | 4bed1d2e7e139b761583c5f0ce3a07d6b3dd59d7 /Lib | |
parent | 0bdf9ea136c4acca2de0fe6ab799ab35d5b09fd2 (diff) | |
download | cpython-a1fc949b5ab8911a803eee691e6eea55cec43eeb.zip cpython-a1fc949b5ab8911a803eee691e6eea55cec43eeb.tar.gz cpython-a1fc949b5ab8911a803eee691e6eea55cec43eeb.tar.bz2 |
Issue #24379: Revert the operator.subscript patch (dccc4e63aef5) pending resolution of the related refcnt leak.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/operator.py | 28 | ||||
-rw-r--r-- | Lib/test/test_operator.py | 33 |
2 files changed, 1 insertions, 60 deletions
diff --git a/Lib/operator.py b/Lib/operator.py index bc2a947..0e2e53e 100644 --- a/Lib/operator.py +++ b/Lib/operator.py @@ -17,7 +17,7 @@ __all__ = ['abs', 'add', 'and_', 'attrgetter', 'concat', 'contains', 'countOf', 'is_', 'is_not', 'isub', 'itemgetter', 'itruediv', 'ixor', 'le', 'length_hint', 'lshift', 'lt', 'matmul', 'methodcaller', 'mod', 'mul', 'ne', 'neg', 'not_', 'or_', 'pos', 'pow', 'rshift', - 'setitem', 'sub', 'subscript', 'truediv', 'truth', 'xor'] + 'setitem', 'sub', 'truediv', 'truth', 'xor'] from builtins import abs as _abs @@ -408,32 +408,6 @@ def ixor(a, b): return a -@object.__new__ # create a singleton instance -class subscript: - """ - A helper to turn subscript notation into indexing objects. This can be - used to create item access patterns ahead of time to pass them into - various subscriptable objects. - - For example: - subscript[5] == 5 - subscript[3:7:2] == slice(3, 7, 2) - subscript[5, 8] == (5, 8) - """ - __slots__ = () - - def __new__(cls): - raise TypeError("cannot create '{}' instances".format(cls.__name__)) - - @staticmethod - def __getitem__(key): - return key - - @staticmethod - def __reduce__(): - return 'subscript' - - try: from _operator import * except ImportError: diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py index 27501c2..54fd1f4 100644 --- a/Lib/test/test_operator.py +++ b/Lib/test/test_operator.py @@ -596,38 +596,5 @@ class CCOperatorPickleTestCase(OperatorPickleTestCase, unittest.TestCase): module2 = c_operator -class SubscriptTestCase: - def test_subscript(self): - subscript = self.module.subscript - self.assertIsNone(subscript[None]) - self.assertEqual(subscript[0], 0) - self.assertEqual(subscript[0:1:2], slice(0, 1, 2)) - self.assertEqual( - subscript[0, ..., :2, ...], - (0, Ellipsis, slice(2), Ellipsis), - ) - - def test_pickle(self): - from operator import subscript - for proto in range(pickle.HIGHEST_PROTOCOL + 1): - with self.subTest(proto=proto): - self.assertIs( - pickle.loads(pickle.dumps(subscript, proto)), - subscript, - ) - - def test_singleton(self): - with self.assertRaises(TypeError): - type(self.module.subscript)() - - def test_immutable(self): - with self.assertRaises(AttributeError): - self.module.subscript.attr = None - - -class PySubscriptTestCase(SubscriptTestCase, PyOperatorTestCase): - pass - - if __name__ == "__main__": unittest.main() |