]> granicus.if.org Git - python/commitdiff
Issue #24379: Revert the operator.subscript patch (dccc4e63aef5) pending resolution...
authorRaymond Hettinger <python@rcn.com>
Mon, 2 Nov 2015 05:39:56 +0000 (00:39 -0500)
committerRaymond Hettinger <python@rcn.com>
Mon, 2 Nov 2015 05:39:56 +0000 (00:39 -0500)
Doc/library/operator.rst
Doc/whatsnew/3.6.rst
Lib/operator.py
Lib/test/test_operator.py

index 06953917e78dace8e299e4e28bc96941d34c4377..c01e63b77a993382f6e820956321d4f49f997812 100644 (file)
@@ -333,21 +333,6 @@ expect a function argument.
       [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]
 
 
-.. data:: 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)``
-
-    .. versionadded:: 3.6
-
-
 .. function:: methodcaller(name[, args...])
 
    Return a callable object that calls the method *name* on its operand.  If
index b500550c22b76777184035a257c6df827f370ac8..0d387bb9bc2018f6d7ec8d2eda2f236041b48fb5 100644 (file)
@@ -104,14 +104,6 @@ directives ``%G``, ``%u`` and ``%V``.
 (Contributed by Ashley Anderson in :issue:`12006`.)
 
 
-operator
---------
-
-New object :data:`operator.subscript` makes it easier to create complex
-indexers. For example: ``subscript[0:10:2] == slice(0, 10, 2)``
-(Contributed by Joe Jevnik in :issue:`24379`.)
-
-
 pickle
 ------
 
index bc2a9478b8ba3d97bce57c851c5f65eded6eabcb..0e2e53efc69a77dca0081ad67e2deb0accb9a288 100644 (file)
@@ -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:
index 27501c246698bc41b65861aebee10f1b548ba433..54fd1f4e528402a9783206131c8b7169044e85c1 100644 (file)
@@ -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()