From b22309e1ab995d7ac0cb3bda141c8968cbaa80cf Mon Sep 17 00:00:00 2001 From: Caleb Date: Sat, 22 Apr 2023 10:13:42 -0400 Subject: [PATCH] fix crash on >= python3.10 --- nvpair.pxi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nvpair.pxi b/nvpair.pxi index 14600b7..817cafa 100644 --- a/nvpair.pxi +++ b/nvpair.pxi @@ -9,6 +9,13 @@ from types cimport * from libc.stdint cimport uintptr_t from libc.stdlib cimport malloc, free +try: + from collections import Sequence +except ImportError: + # >= py3.10 moved everything into top-level "abc" module + # https://docs.python.org/3.9/library/collections.html + from collections.abc import Sequence + @cython.internal cdef class NVList(object): @@ -247,7 +254,7 @@ cdef class NVList(object): nvpair.nvlist_add_nvlist(self.handle, key, cnvlist.handle) return - if isinstance(value, collections.Sequence): + if isinstance(value, Sequence): if typeid == nvpair.DATA_TYPE_STRING_ARRAY: carray = malloc(len(value) * sizeof(char*)) for idx, i in enumerate(value):