Skip to content

Commit dd4d8b4

Browse files
authored
Fix compilation warnings on Windows (pythonGH-8627)
* Fix compilation warning in _ctypes module on Window (cherry picked from commit 20f11fe) * Fix compilation warnings on Windows 64-bit (cherry picked from commit 725e421) * Fix compiler warning in unicodeobject.c Explicitly case to Py_UNICODE to fix the warning: Objects\unicodeobject.c(4225): warning C4244: '=' : conversion from 'long' to 'Py_UNICODE', possible loss of data The downcast cannot overflow since we check that value <= 0x10ffff.
1 parent 6a6b248 commit dd4d8b4

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎Modules/_ctypes/libffi_msvc/ffi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
119119
argp += z;
120120
}
121121

122-
if (argp - stack > ecif->cif->bytes)
122+
if (argp >= stack && (unsigned)(argp - stack) > ecif->cif->bytes)
123123
{
124124
Py_FatalError("FFI BUG: not enough stack space for arguments");
125125
}

‎Modules/_sqlite/util.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ _pysqlite_long_from_int64(sqlite_int64 value)
132132
}
133133
# endif
134134
#endif
135-
return PyInt_FromLong(value);
135+
return PyInt_FromLong(Py_SAFE_DOWNCAST(value, sqlite_int64, long));
136136
}
137137

138138
sqlite_int64

‎Objects/unicodeobject.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4222,7 +4222,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s,
42224222
p = PyUnicode_AS_UNICODE(v) + oldpos;
42234223
}
42244224
value -= 0x10000;
4225-
*p++ = 0xD800 | (value >> 10);
4225+
*p++ = 0xD800 | (Py_UNICODE)(value >> 10);
42264226
*p++ = 0xDC00 | (value & 0x3FF);
42274227
extrachars -= 2;
42284228
}

0 commit comments

Comments
 (0)