2a5b6a
From f0a58d1dced6215b7caaa70db17d54834e0cd44e Mon Sep 17 00:00:00 2001
2a5b6a
From: Lubos Kardos <lkardos@redhat.com>
2a5b6a
Date: Fri, 18 Sep 2015 15:29:25 +0200
2a5b6a
Subject: [PATCH] Define PY_SSIZE_T_CLEAN
2a5b6a
2a5b6a
When PyArg_ParseTupleAndKeywords() is used with format argument "s#"
2a5b6a
that means get a string and his length then the length is returned as
2a5b6a
as a Py_ssize_t in python3 but as an int in python2, which casues
2a5b6a
a problem because rpmfd_write() that uses PyArg_ParseTupleAndKeywords()
2a5b6a
expects the length as a Py_ssize_t always. This problem affects big
2a5b6a
endian systems with python2 as default. If PY_SSIZE_T_CLEAN is defined
2a5b6a
then PyArg_ParseTupleAndKeywords() returns the length as a Py_ssize_t
2a5b6a
in both python2 and python3.
2a5b6a
---
2a5b6a
 python/rpmsystem-py.h | 1 +
2a5b6a
 1 file changed, 1 insertion(+)
2a5b6a
2a5b6a
diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h
2a5b6a
index 50e8770..c8423e3 100644
2a5b6a
--- a/python/rpmsystem-py.h
2a5b6a
+++ b/python/rpmsystem-py.h
2a5b6a
@@ -5,6 +5,7 @@
2a5b6a
 #include <sys/types.h>
2a5b6a
 #endif
2a5b6a
 
2a5b6a
+#define PY_SSIZE_T_CLEAN
2a5b6a
 #include <Python.h>
2a5b6a
 #include <structmember.h>
2a5b6a
 
2a5b6a
-- 
2a5b6a
1.9.3
2a5b6a