File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -560,12 +560,6 @@ impl Py<PyBytes> {
560560 fn title ( & self ) -> PyBytes {
561561 self . inner . title ( ) . into ( )
562562 }
563-
564- #[ pymethod]
565- fn __getnewargs__ ( & self , vm : & VirtualMachine ) -> PyTupleRef {
566- let param: Vec < PyObjectRef > = self . elements ( ) . map ( |x| x. to_pyobject ( vm) ) . collect ( ) ;
567- PyTuple :: new_ref ( param, & vm. ctx )
568- }
569563}
570564
571565#[ pyclass]
@@ -579,6 +573,11 @@ impl PyRef<PyBytes> {
579573 }
580574 }
581575
576+ #[ pymethod]
577+ fn __getnewargs__ ( self , vm : & VirtualMachine ) -> PyTupleRef {
578+ vm. new_tuple ( ( self . result_from_slice ( self . as_bytes ( ) , vm) , ) )
579+ }
580+
582581 #[ pymethod]
583582 fn strip ( self , options : ByteInnerStripOptions , vm : & VirtualMachine ) -> Self {
584583 self . result_from_slice ( self . inner . strip ( options. bytes ) , vm)
Original file line number Diff line number Diff line change @@ -931,3 +931,13 @@ def out_of_range(fn, message):
931931out_of_range (lambda : bytearray ([256 ]), "byte must be in range(0, 256)" )
932932out_of_range (lambda : bytearray (iter ([256 ])), "byte must be in range(0, 256)" )
933933out_of_range (lambda : bytearray ().extend ([256 ]), "byte must be in range(0, 256)" )
934+
935+
936+ class NewArgsBytes (bytes ):
937+ pass
938+
939+
940+ for bytes_type in (bytes , NewArgsBytes ):
941+ newargs = bytes_type (b"a\x00 b" ).__getnewargs__ ()
942+ assert newargs == (b"a\x00 b" ,)
943+ assert type (newargs [0 ]) is bytes
You can’t perform that action at this time.
0 commit comments