Skip to content

Commit a1fc949

Browse files
committed
Issue #24379: Revert the operator.subscript patch (dccc4e63aef5) pending resolution of the related refcnt leak.
1 parent 0bdf9ea commit a1fc949

4 files changed

Lines changed: 1 addition & 83 deletions

File tree

Doc/library/operator.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,6 @@ expect a function argument.
333333
[('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]
334334

335335

336-
.. data:: subscript
337-
338-
A helper to turn subscript notation into indexing objects. This can be
339-
used to create item access patterns ahead of time to pass them into
340-
various subscriptable objects.
341-
342-
For example:
343-
344-
* ``subscript[5] == 5``
345-
* ``subscript[3:7:2] == slice(3, 7, 2)``
346-
* ``subscript[5, 8] == (5, 8)``
347-
348-
.. versionadded:: 3.6
349-
350-
351336
.. function:: methodcaller(name[, args...])
352337

353338
Return a callable object that calls the method *name* on its operand. If

Doc/whatsnew/3.6.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ directives ``%G``, ``%u`` and ``%V``.
104104
(Contributed by Ashley Anderson in :issue:`12006`.)
105105

106106

107-
operator
108-
--------
109-
110-
New object :data:`operator.subscript` makes it easier to create complex
111-
indexers. For example: ``subscript[0:10:2] == slice(0, 10, 2)``
112-
(Contributed by Joe Jevnik in :issue:`24379`.)
113-
114-
115107
pickle
116108
------
117109

Lib/operator.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'is_', 'is_not', 'isub', 'itemgetter', 'itruediv', 'ixor', 'le',
1818
'length_hint', 'lshift', 'lt', 'matmul', 'methodcaller', 'mod',
1919
'mul', 'ne', 'neg', 'not_', 'or_', 'pos', 'pow', 'rshift',
20-
'setitem', 'sub', 'subscript', 'truediv', 'truth', 'xor']
20+
'setitem', 'sub', 'truediv', 'truth', 'xor']
2121

2222
from builtins import abs as _abs
2323

@@ -408,32 +408,6 @@ def ixor(a, b):
408408
return a
409409

410410

411-
@object.__new__ # create a singleton instance
412-
class subscript:
413-
"""
414-
A helper to turn subscript notation into indexing objects. This can be
415-
used to create item access patterns ahead of time to pass them into
416-
various subscriptable objects.
417-
418-
For example:
419-
subscript[5] == 5
420-
subscript[3:7:2] == slice(3, 7, 2)
421-
subscript[5, 8] == (5, 8)
422-
"""
423-
__slots__ = ()
424-
425-
def __new__(cls):
426-
raise TypeError("cannot create '{}' instances".format(cls.__name__))
427-
428-
@staticmethod
429-
def __getitem__(key):
430-
return key
431-
432-
@staticmethod
433-
def __reduce__():
434-
return 'subscript'
435-
436-
437411
try:
438412
from _operator import *
439413
except ImportError:

Lib/test/test_operator.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -596,38 +596,5 @@ class CCOperatorPickleTestCase(OperatorPickleTestCase, unittest.TestCase):
596596
module2 = c_operator
597597

598598

599-
class SubscriptTestCase:
600-
def test_subscript(self):
601-
subscript = self.module.subscript
602-
self.assertIsNone(subscript[None])
603-
self.assertEqual(subscript[0], 0)
604-
self.assertEqual(subscript[0:1:2], slice(0, 1, 2))
605-
self.assertEqual(
606-
subscript[0, ..., :2, ...],
607-
(0, Ellipsis, slice(2), Ellipsis),
608-
)
609-
610-
def test_pickle(self):
611-
from operator import subscript
612-
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
613-
with self.subTest(proto=proto):
614-
self.assertIs(
615-
pickle.loads(pickle.dumps(subscript, proto)),
616-
subscript,
617-
)
618-
619-
def test_singleton(self):
620-
with self.assertRaises(TypeError):
621-
type(self.module.subscript)()
622-
623-
def test_immutable(self):
624-
with self.assertRaises(AttributeError):
625-
self.module.subscript.attr = None
626-
627-
628-
class PySubscriptTestCase(SubscriptTestCase, PyOperatorTestCase):
629-
pass
630-
631-
632599
if __name__ == "__main__":
633600
unittest.main()

0 commit comments

Comments
 (0)