@@ -4,7 +4,8 @@ pub(crate) use _csv::make_module;
44mod _csv {
55 use crate :: common:: lock:: PyMutex ;
66 use crate :: vm:: {
7- AsObject , Py , PyObjectRef , PyPayload , PyRef , PyResult , TryFromObject , VirtualMachine ,
7+ AsObject , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult , TryFromObject ,
8+ VirtualMachine ,
89 builtins:: { PyBaseExceptionRef , PyInt , PyNone , PyStr , PyType , PyTypeRef } ,
910 function:: { ArgIterable , ArgumentError , FromArgs , FuncArgs , OptionalArg } ,
1011 protocol:: { PyIter , PyIterReturn } ,
@@ -130,11 +131,11 @@ mod _csv {
130131 ///
131132 /// * If the 'delimiter' attribute is not a single-character string, a type error is returned.
132133 /// * If the 'obj' is not of string type and does not have a 'delimiter' attribute, a type error is returned.
133- fn parse_delimiter_from_obj ( vm : & VirtualMachine , obj : & PyObjectRef ) -> PyResult < u8 > {
134+ fn parse_delimiter_from_obj ( vm : & VirtualMachine , obj : & PyObject ) -> PyResult < u8 > {
134135 if let Ok ( attr) = obj. get_attr ( "delimiter" , vm) {
135136 parse_delimiter_from_obj ( vm, & attr)
136137 } else {
137- match_class ! ( match obj. clone ( ) {
138+ match_class ! ( match obj. to_owned ( ) {
138139 s @ PyStr => {
139140 Ok ( s. as_str( ) . bytes( ) . exactly_one( ) . map_err( |_| {
140141 let msg = r#""delimiter" must be a 1-character string"# ;
@@ -148,7 +149,7 @@ mod _csv {
148149 } )
149150 }
150151 }
151- fn parse_quotechar_from_obj ( vm : & VirtualMachine , obj : & PyObjectRef ) -> PyResult < Option < u8 > > {
152+ fn parse_quotechar_from_obj ( vm : & VirtualMachine , obj : & PyObject ) -> PyResult < Option < u8 > > {
152153 match_class ! ( match obj. get_attr( "quotechar" , vm) ? {
153154 s @ PyStr => {
154155 Ok ( Some ( s. as_str( ) . bytes( ) . exactly_one( ) . map_err( |_| {
@@ -169,7 +170,7 @@ mod _csv {
169170 }
170171 } )
171172 }
172- fn parse_escapechar_from_obj ( vm : & VirtualMachine , obj : & PyObjectRef ) -> PyResult < Option < u8 > > {
173+ fn parse_escapechar_from_obj ( vm : & VirtualMachine , obj : & PyObject ) -> PyResult < Option < u8 > > {
173174 match_class ! ( match obj. get_attr( "escapechar" , vm) ? {
174175 s @ PyStr => {
175176 Ok ( Some ( s. as_str( ) . bytes( ) . exactly_one( ) . map_err( |_| {
@@ -191,10 +192,7 @@ mod _csv {
191192 }
192193 } )
193194 }
194- fn prase_lineterminator_from_obj (
195- vm : & VirtualMachine ,
196- obj : & PyObjectRef ,
197- ) -> PyResult < Terminator > {
195+ fn prase_lineterminator_from_obj ( vm : & VirtualMachine , obj : & PyObject ) -> PyResult < Terminator > {
198196 match_class ! ( match obj. get_attr( "lineterminator" , vm) ? {
199197 s @ PyStr => {
200198 Ok ( if s. as_bytes( ) . eq( b"\r \n " ) {
@@ -217,7 +215,7 @@ mod _csv {
217215 }
218216 } )
219217 }
220- fn prase_quoting_from_obj ( vm : & VirtualMachine , obj : & PyObjectRef ) -> PyResult < QuoteStyle > {
218+ fn prase_quoting_from_obj ( vm : & VirtualMachine , obj : & PyObject ) -> PyResult < QuoteStyle > {
221219 match_class ! ( match obj. get_attr( "quoting" , vm) ? {
222220 i @ PyInt => {
223221 Ok ( i. try_to_primitive:: <isize >( vm) ?. try_into( ) . map_err( |_| {
0 commit comments