@@ -186,13 +186,16 @@ def popbuffers(paarray, awkwardarrow_type, storage_type, buffers, generate_bitma
186186 if awkwardarrow_type is not None :
187187 paarray = paarray .storage
188188 ### Beginning of the big if-elif-elif chain!
189+ try :
190+ if isinstance (storage_type , pyarrow .lib .PyExtensionType ):
191+ raise ValueError (
192+ "Arrow arrays containing pickled Python objects can't be converted into Awkward Arrays"
193+ )
194+ except AttributeError :
195+ # PyExtensionType is deprecated in pyarrow 21.0.0.
196+ pass
189197
190- if isinstance (storage_type , pyarrow .lib .PyExtensionType ):
191- raise ValueError (
192- "Arrow arrays containing pickled Python objects can't be converted into Awkward Arrays"
193- )
194-
195- elif isinstance (storage_type , pyarrow .lib .ExtensionType ):
198+ if isinstance (storage_type , pyarrow .lib .ExtensionType ):
196199 # AwkwardArrowType should already be unwrapped; this must be some other ExtensionType.
197200 assert not isinstance (storage_type , AwkwardArrowType )
198201 # In that case, just ignore its logical type and use its storage type.
@@ -495,12 +498,16 @@ def popbuffers(paarray, awkwardarrow_type, storage_type, buffers, generate_bitma
495498def form_popbuffers (awkwardarrow_type , storage_type ):
496499 ### Beginning of the big if-elif-elif chain!
497500
498- if isinstance (storage_type , pyarrow .lib .PyExtensionType ):
499- raise ValueError (
500- "Arrow arrays containing pickled Python objects can't be converted into Awkward Arrays"
501- )
501+ try :
502+ if isinstance (storage_type , pyarrow .lib .PyExtensionType ):
503+ raise ValueError (
504+ "Arrow arrays containing pickled Python objects can't be converted into Awkward Arrays"
505+ )
506+ except AttributeError :
507+ # PyExtensionType is deprecated in pyarrow 21.0.0.
508+ pass
502509
503- elif isinstance (storage_type , pyarrow .lib .ExtensionType ):
510+ if isinstance (storage_type , pyarrow .lib .ExtensionType ):
504511 # AwkwardArrowType should already be unwrapped; this must be some other ExtensionType.
505512 assert not isinstance (storage_type , AwkwardArrowType )
506513 # In that case, just ignore its logical type and use its storage type.
0 commit comments