The Windows build for Python 3.10 is giving us an error about ssize_t
being undefined, so this commit fixes the problem by replacing it with
Py_ssize_t, which is consistent with what we do elsewhere in the file.
The first change is to make sure we always define PY_SSIZE_T_CLEAN
before including Python.h. Starting from Python 3.10 this is required.
Otherwise we get errors like this:
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
The second change is to update reflection_test.py to account for the
fact that with Python 3.10, we get a TypeError even with the C++
implementation when trying to assign a float to a bool field. I'm not
sure why this changed with Python 3.10, but it seems like a good thing
since this is the desired behavior anyway.
The first change is to make sure we always define PY_SSIZE_T_CLEAN
before including Python.h. Starting from Python 3.10 this is required.
Otherwise we get errors like this:
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
The second change is to update reflection_test.py to account for the
fact that with Python 3.10, we get a TypeError even with the C++
implementation when trying to assign a float to a bool field. I'm not
sure why this changed with Python 3.10, but it seems like a good thing
since this is the desired behavior anyway.
assertRaisesRegexp has been deprecated in favor of the slightly
different spelling assertRaisesRegex. Let's fix this just to clean up a
bunch of deprecation warnings in the tests.
The Descriptor class now has map_key() and map_value() methods for
accessing the special key and value fields in generated map entry
messages. This commit updates all the relevant code to use these
accessors instead of the clunkier FindFieldByName("key") or
FindFieldByName("value") approach.
The PyInt_FromLong() conversion function will truncate 64 bit integer
values on 32 bit architectures. We will now use the PyLong_* functions
with the appropriate minimum size for each field.
Note that this commit also switches to the unsigned versions, since the
unknown integer fields have been declared unsigned anyway.
Fixes#6205