public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/xrootd] epel8: Some fixes for the python bindings
@ 2026-11-22  9:06 Mattias Ellert
  0 siblings, 0 replies; 2+ messages in thread
From: Mattias Ellert @ 2026-11-22  9:06 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/xrootd
Branch : epel8
Commit : 63600a47d13729a6947f67e54f048f962f14a19f
Author : Mattias Ellert <mattias.ellert@physics.uu.se>
Date   : 2026-10-11T13:38:06+02:00
Stats  : +262/-28 in 6 file(s)
URL    : https://src.fedoraproject.org/rpms/xrootd/c/63600a47d13729a6947f67e54f048f962f14a19f?branch=epel8

Log:
Some fixes for the python bindings

---
diff --git a/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch b/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
index 8ce4475..315e861 100644
--- a/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
+++ b/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
@@ -1,7 +1,7 @@
 From 7391572e94de33a8fd337665c5476e353dfb6bd9 Mon Sep 17 00:00:00 2001
 From: Mattias Ellert <mattias.ellert@physics.uu.se>
 Date: Sat, 3 Oct 2026 23:51:59 +0200
-Subject: [PATCH 1/3] [Python] Fix parsing of enum arguments in python bindings
+Subject: [PATCH 1/5] [Python] Fix parsing of enum arguments in python bindings
 
 The underlying type of an enum is not mandated by the C++ standard, so
 which format character to use when parsing an enum argument in the
@@ -275,5 +275,5 @@ index d3240c05d..b66f3cb7e 100644
      if ( callback && callback != Py_None ) {
        XrdCl::ResponseHandler *handler = GetHandler<XrdCl::Buffer>( callback );
 -- 
-2.55.0
+2.56.0
 

diff --git a/0002-Python-Fix-parsing-of-timeout-arguments-in-python-bi.patch b/0002-Python-Fix-parsing-of-timeout-arguments-in-python-bi.patch
index e275cf3..f111afd 100644
--- a/0002-Python-Fix-parsing-of-timeout-arguments-in-python-bi.patch
+++ b/0002-Python-Fix-parsing-of-timeout-arguments-in-python-bi.patch
@@ -1,10 +1,10 @@
-From f639b79fd3be4ee438bf6d27dad86c7a5e6832d8 Mon Sep 17 00:00:00 2001
+From a4701bf19b0c8ac657bc38f69d5ff4e7b611667a Mon Sep 17 00:00:00 2001
 From: Mattias Ellert <mattias.ellert@physics.uu.se>
 Date: Sun, 4 Oct 2026 06:52:38 +0200
-Subject: [PATCH 2/3] [Python] Fix parsing of timeout arguments in python
+Subject: [PATCH 2/5] [Python] Fix parsing of timeout arguments in python
  bindings
 
-In XrootD 6 the type for the timeout arguments was changed from
+In XRootD 6 the type for the timeout arguments was changed from
 uint16_t to time_t. In the python bindings the change was not carried
 out completely. The type of the variables were changed, but the format
 character used in the python argunemt parsing was not changed and was
@@ -736,5 +736,5 @@ index b66f3cb7e..3bd8ea6fa 100644
      if ( callback && callback != Py_None ) {
        XrdCl::ResponseHandler *handler = GetHandler<std::vector<XrdCl::XAttr>>( callback );
 -- 
-2.55.0
+2.56.0
 

diff --git a/0003-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch b/0003-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
index 401df02..1f509d5 100644
--- a/0003-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
+++ b/0003-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
@@ -1,7 +1,7 @@
-From 8a261cd0fbd48c9618ec751ed015d203bcb42ed8 Mon Sep 17 00:00:00 2001
+From 44401e089476e319fca3c66d413a976cf09dbb84 Mon Sep 17 00:00:00 2001
 From: Mattias Ellert <mattias.ellert@physics.uu.se>
 Date: Tue, 6 Oct 2026 08:13:49 +0200
-Subject: [PATCH 3/3] [Python] Fix parsing of uint64_t arguments in python
+Subject: [PATCH 3/5] [Python] Fix parsing of uint64_t arguments in python
  bindings
 
 Previously the format "k" (unsigned long) was used for parsing
@@ -11,53 +11,80 @@ long long) which is 64 bits wide on both 32 and 64 bit architectures.
 
 This fixes a test failure on 32 bit architectures such as ix86.
 ---
- python/src/Conversions.hh  | 14 +++++++-------
- python/src/PyXRootDFile.cc |  6 +++---
- 2 files changed, 10 insertions(+), 10 deletions(-)
+ python/src/Conversions.hh  | 34 ++++++++++++++++++++++------------
+ python/src/PyXRootDFile.cc | 18 +++++++-----------
+ 2 files changed, 29 insertions(+), 23 deletions(-)
 
 diff --git a/python/src/Conversions.hh b/python/src/Conversions.hh
-index a1948c01e..5f5fdec80 100644
+index a1948c01e..4b85c9c28 100644
 --- a/python/src/Conversions.hh
 +++ b/python/src/Conversions.hh
-@@ -127,13 +127,13 @@ namespace PyXRootD
+@@ -127,13 +127,18 @@ namespace PyXRootD
        {
          return Py_BuildValue("{sNsNsNsNsNsNsNsNsNsNsNsNsNsNsN}",
              "id",         Py_BuildValue("s", info->GetId().c_str()),
 -            "size",       Py_BuildValue("k", info->GetSize()),
-+            "size",       Py_BuildValue("K", info->GetSize()),
++            "size",       Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetSize())),
              "flags",      Py_BuildValue("I", info->GetFlags()),
 -            "mtime",      Py_BuildValue("k", info->GetModTime()),
 -            "modtime",    Py_BuildValue("k", info->GetModTime()),
-+            "mtime",      Py_BuildValue("K", info->GetModTime()),
-+            "modtime",    Py_BuildValue("K", info->GetModTime()),
++            "mtime",      Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetModTime())),
++            "modtime",    Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetModTime())),
              "modtimestr", Py_BuildValue("s", info->GetModTimeAsString().c_str()),
 -            "ctime",      Py_BuildValue("k", info->GetChangeTime()),
 -            "atime",      Py_BuildValue("k", info->GetAccessTime()),
-+            "ctime",      Py_BuildValue("K", info->GetChangeTime()),
-+            "atime",      Py_BuildValue("K", info->GetAccessTime()),
++            "ctime",      Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetChangeTime())),
++            "atime",      Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetAccessTime())),
              "mode",       Py_BuildValue("s", info->GetModeAsString().c_str()),
              "modeoctstr", Py_BuildValue("s", info->GetModeAsOctString().c_str()),
              "owner",      Py_BuildValue("s", info->GetOwner().c_str()),
-@@ -148,7 +148,7 @@ namespace PyXRootD
+@@ -148,11 +153,15 @@ namespace PyXRootD
    {
        static PyObject* Convert( XrdCl::StatInfoVFS *info )
        {
 -        return Py_BuildValue( "{sksksksksbsb}",
+-            "nodes_rw",            info->GetNodesRW(),
+-            "nodes_staging",       info->GetNodesStaging(),
+-            "free_rw",             info->GetFreeRW(),
+-            "free_staging",        info->GetFreeStaging(),
 +        return Py_BuildValue( "{sKsKsKsKsbsb}",
-             "nodes_rw",            info->GetNodesRW(),
-             "nodes_staging",       info->GetNodesStaging(),
-             "free_rw",             info->GetFreeRW(),
-@@ -284,7 +284,7 @@ namespace PyXRootD
++            "nodes_rw",
++              static_cast<unsigned long long>(info->GetNodesRW()),
++            "nodes_staging",
++              static_cast<unsigned long long>(info->GetNodesStaging()),
++            "free_rw",
++              static_cast<unsigned long long>(info->GetFreeRW()),
++            "free_staging",
++              static_cast<unsigned long long>(info->GetFreeStaging()),
+             "utilization_rw",      info->GetUtilizationRW(),
+             "utilization_staging", info->GetUtilizationStaging() );
+       }
+@@ -284,7 +293,8 @@ namespace PyXRootD
  
            PyList_SET_ITEM( pychunks, i,
                Py_BuildValue( "{sNsNsO}",
 -                  "offset", Py_BuildValue( "k", chunk.offset ),
-+                  "offset", Py_BuildValue( "K", chunk.offset ),
++                  "offset", Py_BuildValue( "K",
++                            static_cast<unsigned long long>(chunk.offset) ),
                    "length", Py_BuildValue( "I", chunk.length ),
                    "buffer", buffer ) );
            Py_DECREF( buffer );
+@@ -332,7 +342,7 @@ namespace PyXRootD
+           key = "size";
+           if(result->HasProperty(key))
+           {
+-            uint64_t s;
++            unsigned long long s;
+             result->Get(key, s);
+             kO = Py_BuildValue("s", key);
+             vO = Py_BuildValue("K", s);
 diff --git a/python/src/PyXRootDFile.cc b/python/src/PyXRootDFile.cc
-index 70f2f9121..6ae8f6989 100644
+index 70f2f9121..379ed0000 100644
 --- a/python/src/PyXRootDFile.cc
 +++ b/python/src/PyXRootDFile.cc
 @@ -528,8 +528,8 @@ namespace PyXRootD
@@ -71,7 +98,35 @@ index 70f2f9121..6ae8f6989 100644
  
      unsigned long long tmp_offset = 0;
      unsigned int tmp_size = 0, tmp_chunksize = 0;
-@@ -615,7 +615,7 @@ namespace PyXRootD
+@@ -590,8 +590,6 @@ namespace PyXRootD
+   PyObject* File::ReadChunks( File *self, PyObject *args, PyObject *kwds )
+   {
+     static const char *kwlist[]  = { "offset", "chunksize", NULL };
+-    uint64_t           offset    = 0;
+-    uint32_t           chunksize = 0;
+     ChunkIterator     *iterator;
+     PyObject          *py_offset = NULL, *py_chunksize = NULL;
+ 
+@@ -600,22 +598,20 @@ namespace PyXRootD
+     if ( !PyArg_ParseTupleAndKeywords( args, kwds, "|OO:readchunks",
+          (char**) kwlist, &py_offset, &py_chunksize ) ) return NULL;
+ 
+-    unsigned long long tmp_offset = 0;
+-    unsigned int tmp_chunksize = 1024 * 1024 *2;  // 2 MB
++    unsigned long long offset = 0;
++    unsigned int chunksize = 1024 * 1024 *2;  // 2 MB
+ 
+-    if ( py_offset && PyObjToUllong( py_offset, &tmp_offset, "offset" ) )
++    if ( py_offset && PyObjToUllong( py_offset, &offset, "offset" ) )
+       return NULL;
+ 
+-    if ( py_chunksize && PyObjToUint( py_chunksize, &tmp_chunksize, "chunksize" ) )
++    if ( py_chunksize && PyObjToUint( py_chunksize, &chunksize, "chunksize" ) )
+       return NULL;
+ 
+-    offset = (uint64_t)tmp_offset;
+-    chunksize = (uint32_t)tmp_chunksize;
+     ChunkIteratorType.tp_new = PyType_GenericNew;
  
      if ( PyType_Ready( &ChunkIteratorType ) < 0 ) return NULL;
  
@@ -81,5 +136,5 @@ index 70f2f9121..6ae8f6989 100644
      iterator = (ChunkIterator*)
                 PyObject_CallObject( (PyObject *) &ChunkIteratorType, args );
 -- 
-2.55.0
+2.56.0
 

diff --git a/0004-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch b/0004-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch
new file mode 100644
index 0000000..8dd171a
--- /dev/null
+++ b/0004-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch
@@ -0,0 +1,27 @@
+From 00105095ecf609f676777e88d017ff37331f4685 Mon Sep 17 00:00:00 2001
+From: Mattias Ellert <mattias.ellert@physics.uu.se>
+Date: Thu, 8 Oct 2026 19:29:25 +0200
+Subject: [PATCH 4/5] [Python] Fix parsing of bool argument in python bindings
+
+Boolean values should use the "b" format. This fixes a test failure
+due to a Bus Error on Debian for the sparc64 architecture.
+---
+ python/src/PyXRootDFileSystem.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/python/src/PyXRootDFileSystem.cc b/python/src/PyXRootDFileSystem.cc
+index 3bd8ea6fa..dbbf2bea6 100644
+--- a/python/src/PyXRootDFileSystem.cc
++++ b/python/src/PyXRootDFileSystem.cc
+@@ -44,7 +44,7 @@ namespace PyXRootD
+     PyObject               *pystatus = NULL;
+     CopyProcess            *copyprocess = NULL;
+ 
+-    if ( !PyArg_ParseTupleAndKeywords( args, kwds, "ss|i:copy",
++    if ( !PyArg_ParseTupleAndKeywords( args, kwds, "ss|b:copy",
+          (char**) kwlist, &source, &target, &force ) ) return NULL;
+ 
+     CopyProcessType.tp_new = PyType_GenericNew;
+-- 
+2.56.0
+

diff --git a/0005-Python-Update-converter-helper-functions.patch b/0005-Python-Update-converter-helper-functions.patch
new file mode 100644
index 0000000..3f3827b
--- /dev/null
+++ b/0005-Python-Update-converter-helper-functions.patch
@@ -0,0 +1,145 @@
+From 908d387fdafd306ec244d7316f413dd0a9fb0af5 Mon Sep 17 00:00:00 2001
+From: Mattias Ellert <mattias.ellert@physics.uu.se>
+Date: Fri, 9 Oct 2026 10:52:31 +0200
+Subject: [PATCH 5/5] [Python] Update converter helper functions
+
+The converter for an unsigned long long passed the value through a
+temporary unsigned long, loosing range on 32 bit architectures.
+---
+ python/src/Utils.cc | 53 +++++----------------------------------------
+ python/src/Utils.hh | 15 ++-----------
+ 2 files changed, 8 insertions(+), 60 deletions(-)
+
+diff --git a/python/src/Utils.cc b/python/src/Utils.cc
+index 0d4ba52d8..9d22b3074 100644
+--- a/python/src/Utils.cc
++++ b/python/src/Utils.cc
+@@ -55,38 +55,10 @@ namespace PyXRootD
+   }
+ 
+   //----------------------------------------------------------------------------
+-  // Convert PyInt to unsigned long (uint64_t)
+-  //----------------------------------------------------------------------------
+-  int PyIntToUlong(PyObject *py_val, unsigned long *val, const char *name)
+-  {
+-    const long tmp = PyLong_AsLong(py_val);
+-
+-    if (tmp == -1 && PyErr_Occurred())
+-    {
+-      if (PyErr_ExceptionMatches(PyExc_OverflowError))
+-        PyErr_Format(PyExc_OverflowError, "%s too big for unsigned long", name);
+-      return -1;
+-    }
+-
+-    if (tmp < 0)
+-    {
+-      PyErr_Format(PyExc_OverflowError,
+-                   "negative %s cannot be converted to unsigned long", name);
+-      return -1;
+-    }
+-
+-    *val = tmp;
+-    return 0;
+-  }
+-
+-  //----------------------------------------------------------------------------
+-  // Convert Python object to unsigned long (uint64_t)
++  // Convert Python object to unsigned long
+   //----------------------------------------------------------------------------
+   int PyObjToUlong(PyObject *py_val, unsigned long *val, const char *name)
+   {
+-    if (PyLong_Check(py_val))
+-      return PyIntToUlong(py_val, val, name);
+-
+     if (!PyLong_Check(py_val))
+     {
+       PyErr_Format(PyExc_TypeError, "expected integer %s", name);
+@@ -95,7 +67,7 @@ namespace PyXRootD
+ 
+     const unsigned long tmp = PyLong_AsUnsignedLong(py_val);
+ 
+-    if (PyErr_Occurred())
++    if ((tmp == (unsigned long) -1) && PyErr_Occurred())
+     {
+       if (PyErr_ExceptionMatches(PyExc_OverflowError))
+         PyErr_Format(PyExc_OverflowError, "%s too big for unsigned long", name);
+@@ -132,9 +104,9 @@ namespace PyXRootD
+   //----------------------------------------------------------------------------
+   int PyObjToUshrt(PyObject *py_val, unsigned short int *val, const char *name)
+   {
+-    unsigned int tmp;
++    unsigned long tmp;
+ 
+-    if (PyObjToUint(py_val, &tmp, name))
++    if (PyObjToUlong(py_val, &tmp, name))
+       return -1;
+ 
+     if (tmp > USHRT_MAX)
+@@ -151,29 +123,16 @@ namespace PyXRootD
+   //----------------------------------------------------------------------------
+   // Convert Python object to unsigned long long (uint64_t)
+   //----------------------------------------------------------------------------
+-  int PyObjToUllong(PyObject *py_val, unsigned PY_LONG_LONG *val,
++  int PyObjToUllong(PyObject *py_val, unsigned long long *val,
+                     const char *name)
+   {
+-    if (PyLong_Check(py_val))
+-    {
+-      unsigned long tmp;
+-
+-      if (!PyIntToUlong(py_val, &tmp, name))
+-      {
+-        *val = tmp;
+-        return 0;
+-      }
+-
+-      return -1;
+-    }
+-
+     if (!PyLong_Check(py_val))
+     {
+       PyErr_Format(PyExc_TypeError, "integer argument expected for %s", name);
+       return -1;
+     }
+ 
+-    const unsigned PY_LONG_LONG tmp = PyLong_AsUnsignedLongLong(py_val);
++    const unsigned long long tmp = PyLong_AsUnsignedLongLong(py_val);
+ 
+     if ((tmp == (unsigned long long) -1) && PyErr_Occurred())
+     {
+diff --git a/python/src/Utils.hh b/python/src/Utils.hh
+index c8df4e055..bcf084e56 100644
+--- a/python/src/Utils.hh
++++ b/python/src/Utils.hh
+@@ -42,18 +42,7 @@ namespace PyXRootD
+   int InitTypes();
+ 
+   //----------------------------------------------------------------------------
+-  //! Convert PyInt to unsigned long (uint64_t)
+-  //!
+-  //! @param py_val python object to be converted
+-  //! @param val converted value
+-  //! @param name name of the object
+-  //!
+-  //! return 0 if successful, otherwise failed
+-  //----------------------------------------------------------------------------
+-  int PyIntToUlong(PyObject *py_val, unsigned long *val, const char *name);
+-
+-  //----------------------------------------------------------------------------
+-  //! Convert Python object to unsigned long (uint64_t)
++  //! Convert Python object to unsigned long
+   //!
+   //! @param py_val python object to be converted
+   //! @param val converted value
+@@ -94,7 +83,7 @@ namespace PyXRootD
+   //!
+   //! return 0 if successful, otherwise failed
+   //----------------------------------------------------------------------------
+-  int PyObjToUllong(PyObject *py_val, unsigned PY_LONG_LONG *val, const char *name);
++  int PyObjToUllong(PyObject *py_val, unsigned long long *val, const char *name);
+ }
+ 
+ #endif /* UTILS_HH_ */
+-- 
+2.56.0
+

diff --git a/xrootd.spec b/xrootd.spec
index 5f0f4b8..a6044f1 100644
--- a/xrootd.spec
+++ b/xrootd.spec
@@ -11,7 +11,7 @@
 Name:		xrootd
 Epoch:		1
 Version:	6.2.0
-Release:	1%{?dist}
+Release:	2%{?dist}
 Summary:	Extended ROOT file server
 License:	LGPL-3.0-or-later AND BSD-2-Clause AND BSD-3-Clause AND curl AND MIT AND Zlib AND Apache-2.0 AND MPL-2.0
 URL:		https://xrootd.web.cern.ch
@@ -30,6 +30,8 @@ Patch3:		0001-Tests-Do-not-hardcode-the-name-of-the-build-director.patch
 Patch4:		0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
 Patch5:		0002-Python-Fix-parsing-of-timeout-arguments-in-python-bi.patch
 Patch6:		0003-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
+Patch7:		0004-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch
+Patch8:		0005-Python-Update-converter-helper-functions.patch
 
 BuildRequires:	cmake
 BuildRequires:	gcc-c++
@@ -281,6 +283,8 @@ This package contains the API documentation of the xrootd libraries.
 %patch -P4 -p1
 %patch -P5 -p1
 %patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
 
 # Delete bundled dependencies
 rm src/XrdXml/tinyxml/tiny*
@@ -690,6 +694,9 @@ fi
 %doc %{_pkgdocdir}
 
 %changelog
+* Sun Oct 11 2026 Mattias Ellert <mattias.ellert@physics.uu.se> - 1:6.2.0-2
+- Some fixes for the python bindings
+
 * Tue Oct 06 2026 Mattias Ellert <mattias.ellert@physics.uu.se> - 1:6.2.0-1
 - Update to version 6.2.0
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [rpms/xrootd] epel8: Some fixes for the python bindings
@ 2026-10-11 12:04 Mattias Ellert
  0 siblings, 0 replies; 2+ messages in thread
From: Mattias Ellert @ 2026-10-11 12:04 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/xrootd
Branch : epel8
Commit : 3b44486e91fb8b8923fadffe27fb5a7020027cdc
Author : Mattias Ellert <mattias.ellert@physics.uu.se>
Date   : 2026-10-11T13:46:54+02:00
Stats  : +254/-21 in 5 file(s)
URL    : https://src.fedoraproject.org/rpms/xrootd/c/3b44486e91fb8b8923fadffe27fb5a7020027cdc?branch=epel8

Log:
Some fixes for the python bindings

---
diff --git a/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch b/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
index 2d11691..d3afd79 100644
--- a/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
+++ b/0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
@@ -1,7 +1,7 @@
 From d4005e057943ad73e831b26300151f628ec5fb51 Mon Sep 17 00:00:00 2001
 From: Mattias Ellert <mattias.ellert@physics.uu.se>
 Date: Sat, 3 Oct 2026 23:51:59 +0200
-Subject: [PATCH 1/2] [Python] Fix parsing of enum arguments in python bindings
+Subject: [PATCH 1/4] [Python] Fix parsing of enum arguments in python bindings
 
 The underlying type of an enum is not mandated by the C++ standard, so
 which format character to use when parsing an enum argument in the
@@ -239,5 +239,5 @@ index a21148328..c507e6b4e 100644
      if ( callback && callback != Py_None ) {
        XrdCl::ResponseHandler *handler = GetHandler<XrdCl::Buffer>( callback );
 -- 
-2.55.0
+2.56.0
 

diff --git a/0002-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch b/0002-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
index 5ed4da5..64cc78c 100644
--- a/0002-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
+++ b/0002-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
@@ -1,7 +1,7 @@
-From c6601f0961f6aedeb9616cc25e27553d2c21f12b Mon Sep 17 00:00:00 2001
+From 94a19d0e7bf3c378c67eb18a6fb51d4428234e82 Mon Sep 17 00:00:00 2001
 From: Mattias Ellert <mattias.ellert@physics.uu.se>
 Date: Tue, 6 Oct 2026 08:13:49 +0200
-Subject: [PATCH 2/2] [Python] Fix parsing of uint64_t arguments in python
+Subject: [PATCH 2/4] [Python] Fix parsing of uint64_t arguments in python
  bindings
 
 Previously the format "k" (unsigned long) was used for parsing
@@ -11,46 +11,70 @@ long long) which is 64 bits wide on both 32 and 64 bit architectures.
 
 This is a backport of the corresponding fix in XRootD 6.
 ---
- bindings/python/src/Conversions.hh  | 8 ++++----
- bindings/python/src/PyXRootDFile.cc | 6 +++---
- 2 files changed, 7 insertions(+), 7 deletions(-)
+ bindings/python/src/Conversions.hh  | 25 ++++++++++++++++---------
+ bindings/python/src/PyXRootDFile.cc | 18 +++++++-----------
+ 2 files changed, 23 insertions(+), 20 deletions(-)
 
 diff --git a/bindings/python/src/Conversions.hh b/bindings/python/src/Conversions.hh
-index 5c52ab28e..862fb44ad 100644
+index 5c52ab28e..629bb0a79 100644
 --- a/bindings/python/src/Conversions.hh
 +++ b/bindings/python/src/Conversions.hh
-@@ -127,9 +127,9 @@ namespace PyXRootD
+@@ -127,9 +127,11 @@ namespace PyXRootD
        {
          return Py_BuildValue("{sNsNsNsNsN}",
              "id",         Py_BuildValue("s", info->GetId().c_str()),
 -            "size",       Py_BuildValue("k", info->GetSize()),
-+            "size",       Py_BuildValue("K", info->GetSize()),
++            "size",       Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetSize())),
              "flags",      Py_BuildValue("I", info->GetFlags()),
 -            "modtime",    Py_BuildValue("k", info->GetModTime()),
-+            "modtime",    Py_BuildValue("K", info->GetModTime()),
++            "modtime",    Py_BuildValue("K",
++                          static_cast<unsigned long long>(info->GetModTime())),
              "modtimestr", Py_BuildValue("s",
                                          info->GetModTimeAsString().c_str()));
        }
-@@ -139,7 +139,7 @@ namespace PyXRootD
+@@ -139,11 +141,15 @@ namespace PyXRootD
    {
        static PyObject* Convert( XrdCl::StatInfoVFS *info )
        {
 -        return Py_BuildValue( "{sksksksksbsb}",
+-            "nodes_rw",            info->GetNodesRW(),
+-            "nodes_staging",       info->GetNodesStaging(),
+-            "free_rw",             info->GetFreeRW(),
+-            "free_staging",        info->GetFreeStaging(),
 +        return Py_BuildValue( "{sKsKsKsKsbsb}",
-             "nodes_rw",            info->GetNodesRW(),
-             "nodes_staging",       info->GetNodesStaging(),
-             "free_rw",             info->GetFreeRW(),
-@@ -275,7 +275,7 @@ namespace PyXRootD
++            "nodes_rw",
++              static_cast<unsigned long long>(info->GetNodesRW()),
++            "nodes_staging",
++              static_cast<unsigned long long>(info->GetNodesStaging()),
++            "free_rw",
++              static_cast<unsigned long long>(info->GetFreeRW()),
++            "free_staging",
++              static_cast<unsigned long long>(info->GetFreeStaging()),
+             "utilization_rw",      info->GetUtilizationRW(),
+             "utilization_staging", info->GetUtilizationStaging() );
+       }
+@@ -275,7 +281,8 @@ namespace PyXRootD
  
            PyList_SET_ITEM( pychunks, i,
                Py_BuildValue( "{sNsNsO}",
 -                  "offset", Py_BuildValue( "k", chunk.offset ),
-+                  "offset", Py_BuildValue( "K", chunk.offset ),
++                  "offset", Py_BuildValue( "K",
++                            static_cast<unsigned long long>(chunk.offset) ),
                    "length", Py_BuildValue( "I", chunk.length ),
                    "buffer", buffer ) );
            Py_DECREF( buffer );
+@@ -323,7 +330,7 @@ namespace PyXRootD
+           key = "size";
+           if(result->HasProperty(key))
+           {
+-            uint64_t s;
++            unsigned long long s;
+             result->Get(key, s);
+             kO = Py_BuildValue("s", key);
+             vO = Py_BuildValue("K", s);
 diff --git a/bindings/python/src/PyXRootDFile.cc b/bindings/python/src/PyXRootDFile.cc
-index ef0f31d1e..790491776 100644
+index ef0f31d1e..ded9edd3d 100644
 --- a/bindings/python/src/PyXRootDFile.cc
 +++ b/bindings/python/src/PyXRootDFile.cc
 @@ -325,8 +325,8 @@ namespace PyXRootD
@@ -64,7 +88,35 @@ index ef0f31d1e..790491776 100644
  
      unsigned long long tmp_offset = 0;
      unsigned int tmp_size = 0, tmp_chunksize = 0;
-@@ -412,7 +412,7 @@ namespace PyXRootD
+@@ -387,8 +387,6 @@ namespace PyXRootD
+   PyObject* File::ReadChunks( File *self, PyObject *args, PyObject *kwds )
+   {
+     static const char *kwlist[]  = { "offset", "chunksize", NULL };
+-    uint64_t           offset    = 0;
+-    uint32_t           chunksize = 0;
+     ChunkIterator     *iterator;
+     PyObject          *py_offset = NULL, *py_chunksize = NULL;
+ 
+@@ -397,22 +395,20 @@ namespace PyXRootD
+     if ( !PyArg_ParseTupleAndKeywords( args, kwds, "|OO:readchunks",
+          (char**) kwlist, &py_offset, &py_chunksize ) ) return NULL;
+ 
+-    unsigned long long tmp_offset = 0;
+-    unsigned int tmp_chunksize = 1024 * 1024 *2;  // 2 MB
++    unsigned long long offset = 0;
++    unsigned int chunksize = 1024 * 1024 *2;  // 2 MB
+ 
+-    if ( py_offset && PyObjToUllong( py_offset, &tmp_offset, "offset" ) )
++    if ( py_offset && PyObjToUllong( py_offset, &offset, "offset" ) )
+       return NULL;
+ 
+-    if ( py_chunksize && PyObjToUint( py_chunksize, &tmp_chunksize, "chunksize" ) )
++    if ( py_chunksize && PyObjToUint( py_chunksize, &chunksize, "chunksize" ) )
+       return NULL;
+ 
+-    offset = (uint64_t)tmp_offset;
+-    chunksize = (uint32_t)tmp_chunksize;
+     ChunkIteratorType.tp_new = PyType_GenericNew;
  
      if ( PyType_Ready( &ChunkIteratorType ) < 0 ) return NULL;
  
@@ -74,5 +126,5 @@ index ef0f31d1e..790491776 100644
      iterator = (ChunkIterator*)
                 PyObject_CallObject( (PyObject *) &ChunkIteratorType, args );
 -- 
-2.55.0
+2.56.0
 

diff --git a/0003-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch b/0003-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch
new file mode 100644
index 0000000..c7e8a1b
--- /dev/null
+++ b/0003-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch
@@ -0,0 +1,27 @@
+From 4afcc26be18c93c6081a7b1fb7e1fd0fd3840b0b Mon Sep 17 00:00:00 2001
+From: Mattias Ellert <mattias.ellert@physics.uu.se>
+Date: Thu, 8 Oct 2026 19:29:25 +0200
+Subject: [PATCH 3/4] [Python] Fix parsing of bool argument in python bindings
+
+Boolean values should use the "b" format. This is a backport of the
+corresponding fix in XRootD 6.
+---
+ bindings/python/src/PyXRootDFileSystem.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/bindings/python/src/PyXRootDFileSystem.cc b/bindings/python/src/PyXRootDFileSystem.cc
+index c507e6b4e..dd346de39 100644
+--- a/bindings/python/src/PyXRootDFileSystem.cc
++++ b/bindings/python/src/PyXRootDFileSystem.cc
+@@ -44,7 +44,7 @@ namespace PyXRootD
+     PyObject               *pystatus = NULL;
+     CopyProcess            *copyprocess = NULL;
+ 
+-    if ( !PyArg_ParseTupleAndKeywords( args, kwds, "ss|i:copy",
++    if ( !PyArg_ParseTupleAndKeywords( args, kwds, "ss|b:copy",
+          (char**) kwlist, &source, &target, &force ) ) return NULL;
+ 
+     CopyProcessType.tp_new = PyType_GenericNew;
+-- 
+2.56.0
+

diff --git a/0004-Python-Update-converter-helper-functions.patch b/0004-Python-Update-converter-helper-functions.patch
new file mode 100644
index 0000000..0e0e72f
--- /dev/null
+++ b/0004-Python-Update-converter-helper-functions.patch
@@ -0,0 +1,147 @@
+From 550c9bfea80abc0db8928ff8638ebad31a7e1181 Mon Sep 17 00:00:00 2001
+From: Mattias Ellert <mattias.ellert@physics.uu.se>
+Date: Fri, 9 Oct 2026 10:52:31 +0200
+Subject: [PATCH 4/4] [Python] Update converter helper functions
+
+The converter for an unsigned long long passed the value through a
+temporary unsigned long, loosing range on 32 bit architectures.
+
+This is a backport of the corresponding fix in XRootD 6.
+---
+ bindings/python/src/Utils.cc | 53 ++++--------------------------------
+ bindings/python/src/Utils.hh | 15 ++--------
+ 2 files changed, 8 insertions(+), 60 deletions(-)
+
+diff --git a/bindings/python/src/Utils.cc b/bindings/python/src/Utils.cc
+index 0d4ba52d8..9d22b3074 100644
+--- a/bindings/python/src/Utils.cc
++++ b/bindings/python/src/Utils.cc
+@@ -55,38 +55,10 @@ namespace PyXRootD
+   }
+ 
+   //----------------------------------------------------------------------------
+-  // Convert PyInt to unsigned long (uint64_t)
+-  //----------------------------------------------------------------------------
+-  int PyIntToUlong(PyObject *py_val, unsigned long *val, const char *name)
+-  {
+-    const long tmp = PyLong_AsLong(py_val);
+-
+-    if (tmp == -1 && PyErr_Occurred())
+-    {
+-      if (PyErr_ExceptionMatches(PyExc_OverflowError))
+-        PyErr_Format(PyExc_OverflowError, "%s too big for unsigned long", name);
+-      return -1;
+-    }
+-
+-    if (tmp < 0)
+-    {
+-      PyErr_Format(PyExc_OverflowError,
+-                   "negative %s cannot be converted to unsigned long", name);
+-      return -1;
+-    }
+-
+-    *val = tmp;
+-    return 0;
+-  }
+-
+-  //----------------------------------------------------------------------------
+-  // Convert Python object to unsigned long (uint64_t)
++  // Convert Python object to unsigned long
+   //----------------------------------------------------------------------------
+   int PyObjToUlong(PyObject *py_val, unsigned long *val, const char *name)
+   {
+-    if (PyLong_Check(py_val))
+-      return PyIntToUlong(py_val, val, name);
+-
+     if (!PyLong_Check(py_val))
+     {
+       PyErr_Format(PyExc_TypeError, "expected integer %s", name);
+@@ -95,7 +67,7 @@ namespace PyXRootD
+ 
+     const unsigned long tmp = PyLong_AsUnsignedLong(py_val);
+ 
+-    if (PyErr_Occurred())
++    if ((tmp == (unsigned long) -1) && PyErr_Occurred())
+     {
+       if (PyErr_ExceptionMatches(PyExc_OverflowError))
+         PyErr_Format(PyExc_OverflowError, "%s too big for unsigned long", name);
+@@ -132,9 +104,9 @@ namespace PyXRootD
+   //----------------------------------------------------------------------------
+   int PyObjToUshrt(PyObject *py_val, unsigned short int *val, const char *name)
+   {
+-    unsigned int tmp;
++    unsigned long tmp;
+ 
+-    if (PyObjToUint(py_val, &tmp, name))
++    if (PyObjToUlong(py_val, &tmp, name))
+       return -1;
+ 
+     if (tmp > USHRT_MAX)
+@@ -151,29 +123,16 @@ namespace PyXRootD
+   //----------------------------------------------------------------------------
+   // Convert Python object to unsigned long long (uint64_t)
+   //----------------------------------------------------------------------------
+-  int PyObjToUllong(PyObject *py_val, unsigned PY_LONG_LONG *val,
++  int PyObjToUllong(PyObject *py_val, unsigned long long *val,
+                     const char *name)
+   {
+-    if (PyLong_Check(py_val))
+-    {
+-      unsigned long tmp;
+-
+-      if (!PyIntToUlong(py_val, &tmp, name))
+-      {
+-        *val = tmp;
+-        return 0;
+-      }
+-
+-      return -1;
+-    }
+-
+     if (!PyLong_Check(py_val))
+     {
+       PyErr_Format(PyExc_TypeError, "integer argument expected for %s", name);
+       return -1;
+     }
+ 
+-    const unsigned PY_LONG_LONG tmp = PyLong_AsUnsignedLongLong(py_val);
++    const unsigned long long tmp = PyLong_AsUnsignedLongLong(py_val);
+ 
+     if ((tmp == (unsigned long long) -1) && PyErr_Occurred())
+     {
+diff --git a/bindings/python/src/Utils.hh b/bindings/python/src/Utils.hh
+index c8df4e055..bcf084e56 100644
+--- a/bindings/python/src/Utils.hh
++++ b/bindings/python/src/Utils.hh
+@@ -42,18 +42,7 @@ namespace PyXRootD
+   int InitTypes();
+ 
+   //----------------------------------------------------------------------------
+-  //! Convert PyInt to unsigned long (uint64_t)
+-  //!
+-  //! @param py_val python object to be converted
+-  //! @param val converted value
+-  //! @param name name of the object
+-  //!
+-  //! return 0 if successful, otherwise failed
+-  //----------------------------------------------------------------------------
+-  int PyIntToUlong(PyObject *py_val, unsigned long *val, const char *name);
+-
+-  //----------------------------------------------------------------------------
+-  //! Convert Python object to unsigned long (uint64_t)
++  //! Convert Python object to unsigned long
+   //!
+   //! @param py_val python object to be converted
+   //! @param val converted value
+@@ -94,7 +83,7 @@ namespace PyXRootD
+   //!
+   //! return 0 if successful, otherwise failed
+   //----------------------------------------------------------------------------
+-  int PyObjToUllong(PyObject *py_val, unsigned PY_LONG_LONG *val, const char *name);
++  int PyObjToUllong(PyObject *py_val, unsigned long long *val, const char *name);
+ }
+ 
+ #endif /* UTILS_HH_ */
+-- 
+2.56.0
+

diff --git a/xrootd.spec b/xrootd.spec
index e663ed9..b5166bd 100644
--- a/xrootd.spec
+++ b/xrootd.spec
@@ -14,7 +14,7 @@
 Name:		xrootd
 Epoch:		1
 Version:	5.9.8
-Release:	1%{?dist}
+Release:	2%{?dist}
 Summary:	Extended ROOT file server
 License:	LGPL-3.0-or-later AND BSD-2-Clause AND BSD-3-Clause AND curl AND MIT AND Zlib AND Apache-2.0 AND MPL-2.0
 URL:		https://xrootd.web.cern.ch
@@ -24,6 +24,8 @@ Source1:	%{name}-sysusers.conf
 #		https://github.com/xrootd/xrootd/pull/2971
 Patch0:		0001-Python-Fix-parsing-of-enum-arguments-in-python-bindi.patch
 Patch1:		0002-Python-Fix-parsing-of-uint64_t-arguments-in-python-b.patch
+Patch2:		0003-Python-Fix-parsing-of-bool-argument-in-python-bindin.patch
+Patch3:		0004-Python-Update-converter-helper-functions.patch
 
 BuildRequires:	cmake
 BuildRequires:	gcc-c++
@@ -274,6 +276,8 @@ This package contains the API documentation of the xrootd libraries.
 
 %patch -P0 -p1
 %patch -P1 -p1
+%patch -P2 -p1
+%patch -P3 -p1
 
 # Delete bundled dependencies
 rm src/XrdXml/tinyxml/tiny*
@@ -676,6 +680,9 @@ fi
 %doc %{_pkgdocdir}
 
 %changelog
+* Sun Oct 11 2026 Mattias Ellert <mattias.ellert@physics.uu.se> - 1:5.9.8-2
+- Some fixes for the python bindings
+
 * Tue Oct 06 2026 Mattias Ellert <mattias.ellert@physics.uu.se> - 1:5.9.8-1
 - Update to version 5.9.8
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-22  9:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22  9:06 [rpms/xrootd] epel8: Some fixes for the python bindings Mattias Ellert
  -- strict thread matches above, loose matches on Subject: below --
2026-10-11 12:04 Mattias Ellert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox