fix Python deprecation warnings about PY_SSIZE_T_CLEAN

Summary:
Update pywatchman/bser.c to define `PY_SSIZE_T_CLEAN` before including
`Python.h` and then receive parsed string lenghts as `Py_ssize_t` rather than
`int`.  This eliminates some runtime Python warnings about the old `int`
behavior being deprecated.

Reviewed By: chadaustin

Differential Revision: D25294778

fbshipit-source-id: 7db678ed918db3bf4745ba716585ed6475d1c910
This commit is contained in:
Adam Simpkins 2020-12-03 10:55:51 -08:00 committed by Facebook GitHub Bot
parent dceab3479b
commit dea831d5ec

View File

@ -28,6 +28,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#define PY_SSIZE_T_CLEAN
#include <Python.h> #include <Python.h>
#include <bytesobject.h> #include <bytesobject.h>
#ifdef _MSC_VER #ifdef _MSC_VER
@ -1045,7 +1046,7 @@ static int pdu_info_helper(
int64_t* total_len_out) { int64_t* total_len_out) {
const char* start = NULL; const char* start = NULL;
const char* data = NULL; const char* data = NULL;
int datalen = 0; Py_ssize_t datalen = 0;
const char* end; const char* end;
int64_t expected_len; int64_t expected_len;
off_t position; off_t position;
@ -1096,7 +1097,7 @@ static PyObject* bser_pdu_len(PyObject* self, PyObject* args) {
static PyObject* bser_loads(PyObject* self, PyObject* args, PyObject* kw) { static PyObject* bser_loads(PyObject* self, PyObject* args, PyObject* kw) {
const char* data = NULL; const char* data = NULL;
int datalen = 0; Py_ssize_t datalen = 0;
const char* start; const char* start;
const char* end; const char* end;
int64_t expected_len; int64_t expected_len;