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

Function name_to_py

crates/stdlib/src/openssl/cert.rs:168–185  ·  view source on GitHub ↗
(vm: &VirtualMachine, name: &x509::X509NameRef)

Source from the content-addressed store, hash-verified

166 }
167
168 fn name_to_py(vm: &VirtualMachine, name: &x509::X509NameRef) -> PyResult {
169 let list = name
170 .entries()
171 .map(|entry| {
172 let txt = obj2txt(entry.object(), false).to_pyobject(vm);
173 let asn1_str = entry.data();
174 let data_bytes = asn1_str.as_slice();
175 let data = match std::str::from_utf8(data_bytes) {
176 Ok(s) => vm.ctx.new_str(s.to_owned()),
177 Err(_) => vm
178 .ctx
179 .new_str(String::from_utf8_lossy(data_bytes).into_owned()),
180 };
181 Ok(vm.new_tuple(((txt, data),)).into())
182 })
183 .collect::<Result<_, _>>()?;
184 Ok(vm.ctx.new_tuple(list).into())
185 }
186
187 // Helper to convert X509 to dict (for getpeercert with binary=False)
188 fn cert_to_dict(vm: &VirtualMachine, cert: &X509Ref) -> PyResult {

Callers 1

cert_to_dictFunction · 0.70

Calls 9

obj2txtFunction · 0.85
into_ownedMethod · 0.80
mapMethod · 0.45
to_pyobjectMethod · 0.45
dataMethod · 0.45
as_sliceMethod · 0.45
new_strMethod · 0.45
to_ownedMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected