From a62a7af1c52dc36906f23eed46dc27ec6afd92b7 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Sat, 9 Jul 2016 02:28:45 +0530 Subject: [PATCH 1/2] __builtin__: Change signature of bytearray.__delitem__. Signature of bytearray.__delitem__ is overloaded to support both int and slice as parameters. Use a union instead. This is needed to change bytearray's superclass from Sequence[int] to MutableSequence[int], because the current signature of __delitem__ is incompatible with that of MutableSequence. --- stdlib/2.7/__builtin__.pyi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 120007b73..464c1e0cf 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -431,10 +431,7 @@ class bytearray(Sequence[int]): @overload def __setitem__(self, s: slice, x: Union[Sequence[int], str]) -> None: ... def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... - @overload - def __delitem__(self, i: int) -> None: ... - @overload - def __delitem__(self, s: slice) -> None: ... + def __delitem__(self, i: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, s: str) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... From 1cccc2d1153c67192c9f870fa1b051f52dec419f Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Sat, 9 Jul 2016 01:52:44 +0530 Subject: [PATCH 2/2] __builtin__: Fix bytearray on python 2 bytearray should inherit from MutableSequence[int] instead of Sequence[int]. --- stdlib/2.7/__builtin__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 464c1e0cf..e110a1a35 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -365,7 +365,7 @@ class str(basestring, Sequence[str]): def __ge__(self, x: unicode) -> bool: ... def __mod__(self, x: Any) -> str: ... -class bytearray(Sequence[int]): +class bytearray(MutableSequence[int]): @overload def __init__(self) -> None: ... @overload