MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_quotechar_from_obj

Function parse_quotechar_from_obj

crates/stdlib/src/csv.rs:159–179  ·  view source on GitHub ↗
(vm: &VirtualMachine, obj: &PyObject)

Source from the content-addressed store, hash-verified

157 }
158
159 fn parse_quotechar_from_obj(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Option<u8>> {
160 match_class!(match obj.get_attr("quotechar", vm)? {
161 s @ PyStr => {
162 Ok(Some(s.as_bytes().iter().copied().exactly_one().map_err(|_| {
163 new_csv_error(vm, format!(r#""quotechar" must be a unicode character or None, not a string of length {}"#, s.len()))
164 })?))
165 }
166 _n @ PyNone => {
167 Ok(None)
168 }
169 attr => {
170 Err(new_csv_error(
171 vm,
172 format!(
173 r#""quotechar" must be a unicode character or None, not {}"#,
174 attr.class()
175 ),
176 ))
177 }
178 })
179 }
180 fn parse_escapechar_from_obj(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Option<u8>> {
181 match_class!(match obj.get_attr("escapechar", vm)? {
182 s @ PyStr => {

Callers 1

try_from_objectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected