File tree Expand file tree Collapse file tree
crates/vm/src/stdlib/_ctypes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ jobs:
348348 openssl : true
349349
350350 - name : build rustpython
351- run : cargo build --release --verbose --features=threading,jit ${{ env.CARGO_ARGS }}
351+ run : cargo build --release --verbose --features=threading,jit,capi ${{ env.CARGO_ARGS }}
352352
353353 - name : run snippets
354354 run : python -m pip install -r requirements.txt && pytest -v
Original file line number Diff line number Diff line change @@ -1432,6 +1432,29 @@ fn convert_raw_result(
14321432
14331433 let info = stg_info. unwrap ( ) ;
14341434
1435+ // py_object: interpret return value as PyObject* and materialize it.
1436+ if let Ok ( type_attr) = restype_type
1437+ . as_object ( )
1438+ . get_attr ( vm. ctx . intern_str ( "_type_" ) , vm)
1439+ && let Some ( type_str) = type_attr. downcast_ref :: < PyStr > ( )
1440+ && type_str. to_str ( ) == Some ( "O" )
1441+ {
1442+ let ptr = match raw_result {
1443+ RawResult :: Pointer ( p) => * p,
1444+ RawResult :: Value ( v) => * v as usize ,
1445+ RawResult :: Void => 0 ,
1446+ } ;
1447+ if ptr == 0 {
1448+ return Some ( vm. ctx . none ( ) ) ;
1449+ }
1450+ unsafe {
1451+ let obj =
1452+ PyObjectRef :: from_raw ( core:: ptr:: NonNull :: new_unchecked ( ptr as * mut PyObject ) ) ;
1453+ let obj = core:: mem:: ManuallyDrop :: new ( obj) ;
1454+ return Some ( ( * obj) . clone ( ) ) ;
1455+ }
1456+ }
1457+
14351458 // 5. Simple type with getfunc → use bytes_to_pyobject (info->getfunc)
14361459 // is_simple_instance returns TRUE for c_int, c_void_p, etc.
14371460 if super :: base:: is_simple_instance ( & restype_type) {
You can’t perform that action at this time.
0 commit comments