Blob Blame History Raw
From 593faa04d96de5424c2b5163aeed4f1a562e60fd Mon Sep 17 00:00:00 2001
From: Thomas A Caswell <tcaswell@gmail.com>
Date: Mon, 1 Apr 2019 18:38:03 -0400
Subject: [PATCH] MNT: account for cpython deprecations

The # variants the PyArg formats will raise deprecation warnings in
py38.

https://bugs.python.org/issue8677
https://bugs.python.org/issue36381
https://github.com/python/cpython/pull/12473
https://github.com/python/cpython/commit/d3c72a223a5f771f964fc34557c55eb5bfa0f5a0
---
 src/_macosx.m         | 1 +
 src/_png.cpp          | 2 +-
 src/_tkagg.cpp        | 2 +-
 src/_ttconv.cpp       | 2 +-
 src/file_compat.h     | 2 +-
 src/mplutils.h        | 1 +
 src/numpy_cpp.h       | 2 +-
 src/py_adaptors.h     | 2 +-
 src/py_converters.cpp | 2 +-
 src/qhull_wrap.c      | 1 +
 10 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/_macosx.m b/src/_macosx.m
index 958ca9e675d..2c7733033f2 100644
--- a/src/_macosx.m
+++ b/src/_macosx.m
@@ -1,3 +1,4 @@
+#define PY_SSIZE_T_CLEAN
 #include <Cocoa/Cocoa.h>
 #include <ApplicationServices/ApplicationServices.h>
 #include <sys/socket.h>
diff --git a/src/_png.cpp b/src/_png.cpp
index e7e2352c88d..da8f696d7fc 100644
--- a/src/_png.cpp
+++ b/src/_png.cpp
@@ -9,7 +9,7 @@
    Undefining _POSIX_C_SOURCE and _XOPEN_SOURCE stops a couple
    of harmless warnings.
 */
-
+#define PY_SSIZE_T_CLEAN
 
 extern "C" {
 #   include <png.h>
diff --git a/src/_tkagg.cpp b/src/_tkagg.cpp
index 9c9623344b8..51e6c4d6d97 100644
--- a/src/_tkagg.cpp
+++ b/src/_tkagg.cpp
@@ -7,7 +7,7 @@
  * See LICENSE/LICENSE.PIL for details.
  *
  */
-
+#define PY_SSIZE_T_CLEAN
 #include <Python.h>
 #include <cstdlib>
 #include <cstdio>
diff --git a/src/_ttconv.cpp b/src/_ttconv.cpp
index 8639eecfbfe..6a5ceafa0d2 100644
--- a/src/_ttconv.cpp
+++ b/src/_ttconv.cpp
@@ -5,7 +5,7 @@
 
   Python wrapper for TrueType conversion library in ../ttconv.
  */
-
+#define PY_SSIZE_T_CLEAN
 #include "mplutils.h"
 
 #include <Python.h>
diff --git a/src/file_compat.h b/src/file_compat.h
index 397e50cbe84..4115d23e63f 100644
--- a/src/file_compat.h
+++ b/src/file_compat.h
@@ -1,6 +1,6 @@
 #ifndef MPL_FILE_COMPAT_H
 #define MPL_FILE_COMPAT_H
-
+#define PY_SSIZE_T_CLEAN
 #include <Python.h>
 #include <stdio.h>
 #include "numpy/npy_common.h"
diff --git a/src/mplutils.h b/src/mplutils.h
index 889570715ba..925ec32c082 100644
--- a/src/mplutils.h
+++ b/src/mplutils.h
@@ -4,6 +4,7 @@
 #if defined(_MSC_VER) && _MSC_VER <= 1600
 typedef unsigned __int8   uint8_t;
 #else
+#define PY_SSIZE_T_CLEAN
 #include <stdint.h>
 #endif
 
diff --git a/src/numpy_cpp.h b/src/numpy_cpp.h
index 31774f97618..d2bb119a21f 100644
--- a/src/numpy_cpp.h
+++ b/src/numpy_cpp.h
@@ -2,7 +2,7 @@
 
 #ifndef MPL_NUMPY_CPP_H
 #define MPL_NUMPY_CPP_H
-
+#define PY_SSIZE_T_CLEAN
 /***************************************************************************
  * This file is based on original work by Mark Wiebe, available at:
  *
diff --git a/src/py_adaptors.h b/src/py_adaptors.h
index bb11276ebee..912c93c8bf1 100644
--- a/src/py_adaptors.h
+++ b/src/py_adaptors.h
@@ -2,7 +2,7 @@
 
 #ifndef MPL_PY_ADAPTORS_H
 #define MPL_PY_ADAPTORS_H
-
+#define PY_SSIZE_T_CLEAN
 /***************************************************************************
  * This module contains a number of C++ classes that adapt Python data
  * structures to C++ and Agg-friendly interfaces.
diff --git a/src/py_converters.cpp b/src/py_converters.cpp
index bb445c0794a..7331e283be5 100644
--- a/src/py_converters.cpp
+++ b/src/py_converters.cpp
@@ -1,5 +1,5 @@
 #define NO_IMPORT_ARRAY
-
+#define PY_SSIZE_T_CLEAN
 #include "py_converters.h"
 #include "numpy_cpp.h"
 
diff --git a/src/qhull_wrap.c b/src/qhull_wrap.c
index 71077a1738a..4d76867a9b4 100644
--- a/src/qhull_wrap.c
+++ b/src/qhull_wrap.c
@@ -5,6 +5,7 @@
  * triangulation, construct an instance of the matplotlib.tri.Triangulation
  * class without specifying a triangles array.
  */
+#define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "numpy/noprefix.h"
 #include "libqhull/qhull_a.h"