@@ -155,13 +155,17 @@ pub fn for_all_fields(input: proc_macro::TokenStream) -> proc_macro::TokenStream
155155 }
156156
157157 let pyo3_ffi_fields = get_fields_from_file ( & pyo3_ffi_struct_file) ;
158- let bindgen_fields = get_fields_from_file ( & bindgen_struct_file) ;
159158
160- if pyo3_ffi_fields. is_empty ( ) {
161- // probably an opaque type on PyO3 side, skip
159+ if pyo3_ffi_fields. len ( ) == 2
160+ && pyo3_ffi_fields. contains ( & "_data" . to_string ( ) )
161+ && pyo3_ffi_fields. contains ( & "_marker" . to_string ( ) )
162+ {
163+ // looks like an opaque type on the PyO3 side, skip
162164 return TokenStream :: new ( ) . into ( ) ;
163165 }
164166
167+ let bindgen_fields = get_fields_from_file ( & bindgen_struct_file) ;
168+
165169 let mut all_fields: HashSet < _ > = pyo3_ffi_fields. into_iter ( ) . chain ( bindgen_fields) . collect ( ) ;
166170
167171 if struct_name == "PyMemberDef" {
@@ -425,9 +429,11 @@ const MACRO_EXCLUSIONS: &[(&str, &str)] = &[
425429 ( "Py_False" , "" ) ,
426430 ( "Py_GETENV" , "not(Py_3_11)" ) ,
427431 ( "Py_INCREF" , "" ) ,
432+ ( "Py_IS_TYPE" , "not(Py_3_15)" ) , // symbol added for stable abi on 3.15
428433 ( "Py_None" , "" ) ,
429434 ( "Py_NotImplemented" , "" ) ,
430435 ( "Py_REFCNT" , "not(Py_3_14)" ) ,
436+ ( "Py_SIZE" , "not(Py_3_15)" ) , // symbol added for stable abi on 3.15
431437 ( "Py_True" , "" ) ,
432438 ( "Py_TYPE" , "not(Py_3_14)" ) ,
433439 ( "Py_UNICODE_TODECIMAL" , "" ) ,
@@ -476,9 +482,6 @@ const EXCLUDED_SYMBOLS: &[&str] = &[
476482 "PyOS_BeforeFork" ,
477483 "PyOS_AfterFork_Parent" ,
478484 "PyOS_AfterFork_Child" ,
479- // See https://github.com/python/cpython/pull/139166/changes#r3214904694
480- "Py_IS_TYPE" ,
481- "Py_SIZE" ,
482485] ;
483486
484487// Assert at compile time that `MACRO_EXCLUSIONS` and `EXCLUDED_SYMBOLS` are disjoint
@@ -718,9 +721,11 @@ fn get_function_info(
718721 static FUNCTION_DECL_REGEX : LazyLock < regex:: Regex > =
719722 LazyLock :: new ( || regex:: Regex :: new ( r"^pub\s+(.*?)\sfn\s+([^(<]*)" ) . unwrap ( ) ) ;
720723
721- let captures = FUNCTION_DECL_REGEX
722- . captures ( & text)
723- . expect ( "failed to parse function declaration with regex" ) ;
724+ let Some ( captures) = FUNCTION_DECL_REGEX . captures ( & text) else {
725+ panic ! (
726+ "failed to parse function declaration for `{function_name}` with regex, got: {text}"
727+ ) ;
728+ } ;
724729
725730 // find modifiers, e.g. `unsafe extern "C"`
726731 let modifiers = captures. get ( 1 ) . unwrap ( ) . as_str ( ) . parse ( ) . unwrap ( ) ;
0 commit comments