Skip to content

Commit

Permalink
Fix PyIter_Check on older Python vers / type##Ptr unused warning
Browse files Browse the repository at this point in the history
For PyIter_Check, older versions exposed them as either macros (used in
full API), or a function (for use in limited API). A previous change
exposed PyIter_Check to the dynamic build because Python just moved it
to function-only in 3.10 anyway. Because of that, just make sure we
always grab the function in dynamic builds in earlier versions since
that's what Python eventually did anyway.
  • Loading branch information
ychin committed Feb 20, 2023
1 parent 6a35f40 commit e38af7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/if_py_both.h
Expand Up @@ -307,7 +307,7 @@ int Vim_PyRun_SimpleString(const char *str)

// Add a static type
# define PYTYPE_READY(type) \
if (PyType_Ready(&(type))) \
if (PyType_Ready(type##Ptr)) \
return -1;

#endif
Expand Down
6 changes: 3 additions & 3 deletions src/if_python3.c
Expand Up @@ -203,7 +203,7 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll
# ifndef PyMapping_Keys
# define PyMapping_Keys py3_PyMapping_Keys
# endif
# if PY_VERSION_HEX >= 0x030a00b2
# if PY_VERSION_HEX >= 0x030a0000
# define PyIter_Check py3_PyIter_Check
# endif
# define PyIter_Next py3_PyIter_Next
Expand Down Expand Up @@ -397,7 +397,7 @@ static PyObject* (*py3_PyDict_GetItemString)(PyObject *, const char *);
static int (*py3_PyDict_Next)(PyObject *, Py_ssize_t *, PyObject **, PyObject **);
static PyObject* (*py3_PyLong_FromLong)(long);
static PyObject* (*py3_PyDict_New)(void);
# if PY_VERSION_HEX >= 0x030a00b2
# if PY_VERSION_HEX >= 0x030a0000
static int (*py3_PyIter_Check)(PyObject *o);
# endif
static PyObject* (*py3_PyIter_Next)(PyObject *);
Expand Down Expand Up @@ -589,7 +589,7 @@ static struct
{"PyDict_Next", (PYTHON_PROC*)&py3_PyDict_Next},
{"PyMapping_Check", (PYTHON_PROC*)&py3_PyMapping_Check},
{"PyMapping_Keys", (PYTHON_PROC*)&py3_PyMapping_Keys},
# if PY_VERSION_HEX >= 0x030a00b2
# if PY_VERSION_HEX >= 0x030a0000
{"PyIter_Check", (PYTHON_PROC*)&py3_PyIter_Check},
# endif
{"PyIter_Next", (PYTHON_PROC*)&py3_PyIter_Next},
Expand Down

0 comments on commit e38af7c

Please sign in to comment.