@@ -14,8 +14,8 @@ use crate::byteslike::try_bytes_like;
1414use crate :: cformat:: CFormatBytes ;
1515use crate :: function:: { OptionalArg , OptionalOption } ;
1616use crate :: pyobject:: {
17- BorrowValue , Either , IdProtocol , PyComparisonValue , PyIterable , PyObjectRef , PyRef , PyResult ,
18- PyValue , TryFromObject , TypeProtocol ,
17+ BorrowValue , Either , IdProtocol , PyComparisonValue , PyIterable , PyObjectRef , PyResult , PyValue ,
18+ TryFromObject , TypeProtocol ,
1919} ;
2020use crate :: sliceable:: PySliceableSequence ;
2121use crate :: slots:: PyComparisonOp ;
@@ -91,10 +91,10 @@ impl ByteInnerNewOptions {
9191
9292 pub fn get_bytes ( mut self , cls : PyTypeRef , vm : & VirtualMachine ) -> PyResult < PyBytesRef > {
9393 let inner = if let OptionalArg :: Present ( source) = self . source . take ( ) {
94- if source . class ( ) . is ( & PyBytes :: class ( vm ) ) && cls. is ( & PyBytes :: class ( vm) ) {
95- return self
96- . check_args ( vm)
97- . map ( |_| unsafe { PyRef :: from_obj_unchecked ( source ) } ) ;
94+ if cls. is ( & PyBytes :: class ( vm) ) {
95+ if let Ok ( source ) = source . clone ( ) . downcast_exact ( vm ) {
96+ return self . check_args ( vm) . map ( | ( ) | source ) ;
97+ }
9898 }
9999
100100 match_class ! ( match source {
0 commit comments