1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
From: Adam Simpkins <simpkins@fb.com>
Date: Thu, 3 Dec 2020 10:55:51 -0800
Subject: 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
(cherry picked from commit 6813a948fee72a15acf4120262d37c9c8dc3f16b)
Origin: upstream, v2020.12.07.00
---
python/pywatchman/bser.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/python/pywatchman/bser.c b/python/pywatchman/bser.c
index 59a2e75..8162800 100644
--- a/python/pywatchman/bser.c
+++ b/python/pywatchman/bser.c
@@ -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.
*/
+#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <bytesobject.h>
#ifdef _MSC_VER
@@ -1026,7 +1027,7 @@ static int pdu_info_helper(
int64_t* total_len_out) {
const char* start = NULL;
const char* data = NULL;
- int datalen = 0;
+ Py_ssize_t datalen = 0;
const char* end;
int64_t expected_len;
off_t position;
@@ -1075,7 +1076,7 @@ static PyObject* bser_pdu_len(PyObject* self, PyObject* args) {
static PyObject* bser_loads(PyObject* self, PyObject* args, PyObject* kw) {
const char* data = NULL;
- int datalen = 0;
+ Py_ssize_t datalen = 0;
const char* start;
const char* end;
int64_t expected_len;
|