From 215c284eaded01e251b07e5db4cd5d04d6812601 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Sep 2015 10:30:49 +0200 Subject: [PATCH] pidl/python: also add a ndr_PyLong_FromLongLong() for symnetric reasons BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429 Signed-off-by: Stefan Metzmacher Reviewed-by: Stefan Metzmacher (cherry picked from commit e6fbeb860638ad1113914b9460a618025d950d08) --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 056ab21e9c4..180b6b20089 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -1280,7 +1280,7 @@ sub ConvertScalarToPython($$$) $ctypename = expandAlias($ctypename); if ($ctypename =~ /^(int64|dlong)$/) { - return "($cvar > LONG_MAX || $cvar < LONG_MIN) ? PyLong_FromLongLong($cvar) : PyInt_FromLong($cvar)"; + return "ndr_PyLong_FromLongLong($cvar)"; } if ($ctypename =~ /^(uint64|hyper|NTTIME_hyper|NTTIME|NTTIME_1sec|udlong|udlongr|uid_t|gid_t)$/) { @@ -1535,6 +1535,15 @@ static inline long long ndr_sizeof2intmax(size_t var_size) return 0; } +static inline PyObject *ndr_PyLong_FromLongLong(long long v) +{ + if (v > LONG_MAX || v < LONG_MIN) { + return PyLong_FromLongLong(v); + } else { + return PyInt_FromLong(v); + } +} + static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v) { if (v > LONG_MAX) {