Skip to content

Commit

Permalink
Silence GCC -Wsign-conversion (GH-5421)
Browse files Browse the repository at this point in the history
* Silence GCC -Wsign-conversion when using CYTHON_LIMITED_API
* Silence GCC -W[sign-]conversion with invocations to PyUnicode_FromOrdinal
  • Loading branch information
dalcinl committed May 3, 2023
1 parent 236e705 commit df0df65
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cython/Compiler/Builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def declare_in_type(self, self_type):
#('sum', "", "", ""),
#('sorted', "", "", ""),
#('type', "O", "O", "PyObject_Type"),
BuiltinFunction('unichr', "l", "O", "PyUnicode_FromOrdinal", builtin_return_type='unicode'),
BuiltinFunction('unichr', "i", "O", "PyUnicode_FromOrdinal", builtin_return_type='unicode'),
#('unicode', "", "", ""),
#('vars', "", "", ""),
#('zip', "", "", ""),
Expand Down
4 changes: 2 additions & 2 deletions Cython/Compiler/PyrexTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ class CPyUCS4IntType(CIntType):
# is 0..1114111, which is checked when converting from an integer
# value.

to_py_function = "PyUnicode_FromOrdinal"
to_py_function = "__Pyx_PyUnicode_FromOrdinal"
from_py_function = "__Pyx_PyObject_AsPy_UCS4"

def can_coerce_to_pystring(self, env, format_spec=None):
Expand All @@ -2272,7 +2272,7 @@ class CPyUnicodeIntType(CIntType):
# Py_UNICODE is 0..1114111, which is checked when converting from
# an integer value.

to_py_function = "PyUnicode_FromOrdinal"
to_py_function = "__Pyx_PyUnicode_FromOrdinal"
from_py_function = "__Pyx_PyObject_AsPy_UNICODE"

def can_coerce_to_pystring(self, env, format_spec=None):
Expand Down
4 changes: 2 additions & 2 deletions Cython/Plex/Machines.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cimport cython
from .Actions cimport Action
from .Transitions cimport TransitionMap

cdef long maxint
cdef int maxint


@cython.final
Expand All @@ -22,7 +22,7 @@ cdef class Node:
cdef readonly Action action
cdef public dict epsilon_closure
cdef readonly Py_ssize_t number
cdef readonly long action_priority
cdef readonly int action_priority


@cython.final
Expand Down
2 changes: 1 addition & 1 deletion Cython/Plex/Machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def new_state(self, action=None):
def make_initial_state(self, name, state):
self.initial_states[name] = state

@cython.locals(code0=cython.long, code1=cython.long, maxint=cython.long, state=dict)
@cython.locals(code0=cython.int, code1=cython.int, maxint=cython.int, state=dict)
def add_transitions(self, state, event, new_state, maxint=maxint):
if type(event) is tuple:
code0, code1 = event
Expand Down
4 changes: 2 additions & 2 deletions Cython/Utility/ModuleSetupCode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GetLength(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111)
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
#define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
// __Pyx_PyUnicode_DATA() and __Pyx_PyUnicode_READ() must go together, e.g. for iteration.
#define __Pyx_PyUnicode_DATA(u) ((void*)u)
Expand Down Expand Up @@ -1063,7 +1063,7 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535U : 1114111U)
#define __Pyx_PyUnicode_KIND(u) ((int)sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
// (void)(k) => avoid unused variable warning due to macro:
Expand Down
1 change: 1 addition & 0 deletions Cython/Utility/TypeConversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
}
#endif

#define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o)
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
Expand Down

0 comments on commit df0df65

Please sign in to comment.