diff --git a/pynih/contract/source/contract/pyclass.d b/pynih/contract/source/contract/pyclass.d index 6303f874..c4146e13 100644 --- a/pynih/contract/source/contract/pyclass.d +++ b/pynih/contract/source/contract/pyclass.d @@ -79,7 +79,7 @@ package PyObject* pyclass_string_list_struct(PyObject* self, PyObject *args) { return null; } - const length = PyUnicode_GetSize(item); + const length = PyUnicode_GetLength(item); auto ptr = PyBytes_AsString(unicode); auto str = ptr is null ? null : ptr[0 .. length]; diff --git a/pynih/contract/source/contract/udt.d b/pynih/contract/source/contract/udt.d index a3d1f625..e6bd72e5 100644 --- a/pynih/contract/source/contract/udt.d +++ b/pynih/contract/source/contract/udt.d @@ -22,10 +22,10 @@ package PyObject* simple_struct_func(PyObject* self, PyObject *args) nothrow @no // either this of PyGetSetDef static PyMemberDef[3] members; members[0].name = cast(typeof(PyMemberDef.name)) &"the_int"[0]; - members[0].type = T_INT; + members[0].type = Py_T_INT; members[0].offset = MyType.i.offsetof; members[1].name = cast(typeof(PyMemberDef.name)) &"the_double"[0]; - members[1].type = T_DOUBLE; + members[1].type = Py_T_DOUBLE; members[1].offset = MyType.d.offsetof; static PyTypeObject type; diff --git a/pynih/source/autowrap/pynih/python/conv/python_to_d.d b/pynih/source/autowrap/pynih/python/conv/python_to_d.d index c2bc48a6..dd43cb8f 100644 --- a/pynih/source/autowrap/pynih/python/conv/python_to_d.d +++ b/pynih/source/autowrap/pynih/python/conv/python_to_d.d @@ -233,11 +233,11 @@ T to(T)(PyObject* value) if(isArray!T && !isSomeString!T) T to(T)(PyObject* value) if(isSomeString!T) { - import python.c: PyUnicode_GetSize, PyUnicode_Check, + import python.c: PyUnicode_GetLength, PyUnicode_Check, PyBytes_AsString, PyUnicode_AsUTF8String, Py_ssize_t; import std.conv: to; - const length = PyUnicode_GetSize(value); + const length = PyUnicode_GetLength(value); if(length == 0) return T.init; auto str = PyUnicode_AsUTF8String(value); diff --git a/pynih/source/autowrap/pynih/python/cooked.d b/pynih/source/autowrap/pynih/python/cooked.d index 21a876e1..83ee86b4 100644 --- a/pynih/source/autowrap/pynih/python/cooked.d +++ b/pynih/source/autowrap/pynih/python/cooked.d @@ -20,7 +20,7 @@ auto createModule(Module module_, alias cfunctions, alias aggregates = Aggregate static PyModuleDef moduleDef; auto pyMethodDefs = cFunctionsToPyMethodDefs!(cfunctions); - moduleDef = pyModuleDef(module_.name.ptr, null /*doc*/, -1 /*size*/, pyMethodDefs); + moduleDef = PyModuleDef(pyModuleDefHeadInit, module_.name.ptr, null /*doc*/, -1 /*size*/, pyMethodDefs); auto module_ = PyModule_Create(&moduleDef); addModuleTypes!(aggregates.Types)(module_); @@ -73,20 +73,6 @@ private PyMethodDef* cFunctionsToPyMethodDefs(alias cfunctions)() } -/** - Helper function to get around the C syntax problem with - PyModuleDef_HEAD_INIT - it doesn't compile in D. -*/ -private auto pyModuleDef(A...)(auto ref A args) { - import std.functional: forward; - - return PyModuleDef( - // the line below is a manual D version expansion of PyModuleDef_HEAD_INIT - PyModuleDef_Base(PyObject(1 /*ref count*/, null /*type*/), null /*m_init*/, 0/*m_index*/, null/*m_copy*/), - forward!args - ); -} - /** Helper function to create PyMethodDef structs. The strings are compile-time parameters to avoid passing GC-allocated memory diff --git a/requirements.txt b/requirements.txt index f5e037ac..7b352005 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,5 @@ -attrs==21.2.0 -blessings==1.7 -bpython==0.21 -certifi==2023.7.22 -chardet==4.0.0 -curtsies==0.3.5 -cwcwidth==0.1.4 -greenlet==1.1.0 -idna==3.7 -iniconfig==1.1.1 -numpy==1.22.0 -packaging==20.9 -pluggy==0.13.1 -py==1.10.0 -Pygments==2.15.0 -pyparsing==2.4.7 -pytest==6.2.4 -pyxdg==0.27 -requests==2.32.0 -six==1.16.0 -toml==0.10.2 -urllib3==1.26.18 +iniconfig==2.0.0 +numpy==1.26.4 +packaging==24.0 +pluggy==1.5.0 +pytest==8.2.1