Commit fd71aabe authored by Stefan Behnel's avatar Stefan Behnel

Avoid MSVC warning in refnanny about an integer assignment that reduces the...

Avoid MSVC warning in refnanny about an integer assignment that reduces the value range (although it's probably safe to assume that C code line numbers > 2^30 will remain rare for another while).
parent 25d042da
...@@ -32,7 +32,7 @@ cdef class Context(object): ...@@ -32,7 +32,7 @@ cdef class Context(object):
self.refs = {} # id -> (count, [lineno]) self.refs = {} # id -> (count, [lineno])
self.errors = [] self.errors = []
cdef regref(self, obj, lineno, bint is_null): cdef regref(self, obj, Py_ssize_t lineno, bint is_null):
log(LOG_ALL, u'regref', u"<NULL>" if is_null else obj, lineno) log(LOG_ALL, u'regref', u"<NULL>" if is_null else obj, lineno)
if is_null: if is_null:
self.errors.append(f"NULL argument on line {lineno}") self.errors.append(f"NULL argument on line {lineno}")
...@@ -42,7 +42,7 @@ cdef class Context(object): ...@@ -42,7 +42,7 @@ cdef class Context(object):
self.refs[id_] = (count + 1, linenumbers) self.refs[id_] = (count + 1, linenumbers)
linenumbers.append(lineno) linenumbers.append(lineno)
cdef bint delref(self, obj, lineno, bint is_null) except -1: cdef bint delref(self, obj, Py_ssize_t lineno, bint is_null) except -1:
# returns whether it is ok to do the decref operation # returns whether it is ok to do the decref operation
log(LOG_ALL, u'delref', u"<NULL>" if is_null else obj, lineno) log(LOG_ALL, u'delref', u"<NULL>" if is_null else obj, lineno)
if is_null: if is_null:
...@@ -68,7 +68,7 @@ cdef class Context(object): ...@@ -68,7 +68,7 @@ cdef class Context(object):
return u"\n".join([f'REFNANNY: {error}' for error in self.errors]) if self.errors else None return u"\n".join([f'REFNANNY: {error}' for error in self.errors]) if self.errors else None
cdef void report_unraisable(filename, int lineno, object e=None): cdef void report_unraisable(filename, Py_ssize_t lineno, object e=None):
try: try:
if e is None: if e is None:
import sys import sys
...@@ -82,7 +82,7 @@ cdef void report_unraisable(filename, int lineno, object e=None): ...@@ -82,7 +82,7 @@ cdef void report_unraisable(filename, int lineno, object e=None):
# exception has been fetched, in case we are called from # exception has been fetched, in case we are called from
# exception-handling code. # exception-handling code.
cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except NULL: cdef PyObject* SetupContext(char* funcname, Py_ssize_t lineno, char* filename) except NULL:
if Context is None: if Context is None:
# Context may be None during finalize phase. # Context may be None during finalize phase.
# In that case, we don't want to be doing anything fancy # In that case, we don't want to be doing anything fancy
...@@ -100,7 +100,7 @@ cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except N ...@@ -100,7 +100,7 @@ cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except N
PyErr_Restore(type, value, tb) PyErr_Restore(type, value, tb)
return result return result
cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): cdef void GOTREF(PyObject* ctx, PyObject* p_obj, Py_ssize_t lineno):
if ctx == NULL: return if ctx == NULL: return
cdef (PyObject*) type = NULL, value = NULL, tb = NULL cdef (PyObject*) type = NULL, value = NULL, tb = NULL
PyErr_Fetch(&type, &value, &tb) PyErr_Fetch(&type, &value, &tb)
...@@ -116,7 +116,7 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): ...@@ -116,7 +116,7 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
PyErr_Restore(type, value, tb) PyErr_Restore(type, value, tb)
return # swallow any exceptions return # swallow any exceptions
cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): cdef bint GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, Py_ssize_t lineno):
if ctx == NULL: return 1 if ctx == NULL: return 1
cdef (PyObject*) type = NULL, value = NULL, tb = NULL cdef (PyObject*) type = NULL, value = NULL, tb = NULL
cdef bint decref_ok = False cdef bint decref_ok = False
...@@ -133,15 +133,15 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): ...@@ -133,15 +133,15 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno):
PyErr_Restore(type, value, tb) PyErr_Restore(type, value, tb)
return decref_ok # swallow any exceptions return decref_ok # swallow any exceptions
cdef void GIVEREF(PyObject* ctx, PyObject* p_obj, int lineno): cdef void GIVEREF(PyObject* ctx, PyObject* p_obj, Py_ssize_t lineno):
GIVEREF_and_report(ctx, p_obj, lineno) GIVEREF_and_report(ctx, p_obj, lineno)
cdef void INCREF(PyObject* ctx, PyObject* obj, int lineno): cdef void INCREF(PyObject* ctx, PyObject* obj, Py_ssize_t lineno):
Py_XINCREF(obj) Py_XINCREF(obj)
PyThreadState_Get() # Check that we hold the GIL PyThreadState_Get() # Check that we hold the GIL
GOTREF(ctx, obj, lineno) GOTREF(ctx, obj, lineno)
cdef void DECREF(PyObject* ctx, PyObject* obj, int lineno): cdef void DECREF(PyObject* ctx, PyObject* obj, Py_ssize_t lineno):
if GIVEREF_and_report(ctx, obj, lineno): if GIVEREF_and_report(ctx, obj, lineno):
Py_XDECREF(obj) Py_XDECREF(obj)
PyThreadState_Get() # Check that we hold the GIL PyThreadState_Get() # Check that we hold the GIL
...@@ -171,11 +171,11 @@ cdef void FinishContext(PyObject** ctx): ...@@ -171,11 +171,11 @@ cdef void FinishContext(PyObject** ctx):
return # swallow any exceptions return # swallow any exceptions
ctypedef struct RefNannyAPIStruct: ctypedef struct RefNannyAPIStruct:
void (*INCREF)(PyObject*, PyObject*, int) void (*INCREF)(PyObject*, PyObject*, Py_ssize_t)
void (*DECREF)(PyObject*, PyObject*, int) void (*DECREF)(PyObject*, PyObject*, Py_ssize_t)
void (*GOTREF)(PyObject*, PyObject*, int) void (*GOTREF)(PyObject*, PyObject*, Py_ssize_t)
void (*GIVEREF)(PyObject*, PyObject*, int) void (*GIVEREF)(PyObject*, PyObject*, Py_ssize_t)
PyObject* (*SetupContext)(char*, int, char*) except NULL PyObject* (*SetupContext)(char*, Py_ssize_t, char*) except NULL
void (*FinishContext)(PyObject**) void (*FinishContext)(PyObject**)
cdef RefNannyAPIStruct api cdef RefNannyAPIStruct api
......
...@@ -1388,11 +1388,11 @@ static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) ...@@ -1388,11 +1388,11 @@ static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
#if CYTHON_REFNANNY #if CYTHON_REFNANNY
typedef struct { typedef struct {
void (*INCREF)(void*, PyObject*, int); void (*INCREF)(void*, PyObject*, Py_ssize_t);
void (*DECREF)(void*, PyObject*, int); void (*DECREF)(void*, PyObject*, Py_ssize_t);
void (*GOTREF)(void*, PyObject*, int); void (*GOTREF)(void*, PyObject*, Py_ssize_t);
void (*GIVEREF)(void*, PyObject*, int); void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
void* (*SetupContext)(const char*, int, const char*); void* (*SetupContext)(const char*, Py_ssize_t, const char*);
void (*FinishContext)(void**); void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct; } __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment