Skip to content

Commit 89315f9

Browse files
committed
Check for PyExtensionType
1 parent 69b9459 commit 89315f9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/pyarrow_hotfix/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def install():
4040
# Unsupported PyArrow version?
4141
return
4242

43+
if not hasattr(pa, "PyExtensionType"):
44+
# 21.0.0 <= PyArrow
45+
return
46+
4347
if getattr(pa, "_hotfix_installed", False):
4448
return
4549

@@ -62,7 +66,7 @@ def __arrow_ext_deserialize__(cls, storage_type, serialized):
6266
)
6367

6468
if hasattr(pa, "unregister_extension_type"):
65-
# 0.15.0 <= PyArrow
69+
# 0.15.0 <= PyArrow < 21.0.0
6670
pa.unregister_extension_type("arrow.py_extension_type")
6771
pa.register_extension_type(ForbiddenExtensionType(pa.null(),
6872
"arrow.py_extension_type"))
@@ -89,11 +93,15 @@ def uninstall():
8993
# Unsupported PyArrow version?
9094
return
9195

96+
if not hasattr(pa, "PyExtensionType"):
97+
# 21.0.0 <= PyArrow
98+
return
99+
92100
if not getattr(pa, "_hotfix_installed", False):
93101
return
94102

95103
if hasattr(pa, "unregister_extension_type"):
96-
# 0.15.0 <= PyArrow
104+
# 0.15.0 <= PyArrow < 21.0.0
97105
pa.unregister_extension_type("arrow.py_extension_type")
98106
pa.lib._register_py_extension_type()
99107
elif hasattr(pa.lib, "_register_py_extension_type"):

0 commit comments

Comments
 (0)