Skip to content

Python ogr.Buffer lost named kwargs. #11516

@schwehr

Description

@schwehr

What is the bug?

3632b72 / #9924 changed ogr.i triggering a change in the interface to Buffer dropping kargs.

-    def Buffer(self, *args, **kwargs):
+    def Buffer(self, *args):
         r"""
         Buffer(Geometry self, double distance, int quadsecs=30) -> Geometry
+        Buffer(Geometry self, double distance, char ** options) -> Geometry

That means that:

  1. calls like .Buffer(distance=a_value, quadsecs=another_val) no longer work.
  2. there are two conflicting first line summaries in the doc string
diff --git a/swig/include/ogr.i b/swig/include/ogr.i
index bf31e04663..a176f12fee 100644
--- a/swig/include/ogr.i
+++ b/swig/include/ogr.i
@@ -3705,13 +3705,17 @@ public:
   }
 
   %newobject Buffer;
-#ifndef SWIGJAVA
+#if !defined(SWIGJAVA) && !defined(SWIGPYTHON)
   %feature("kwargs") Buffer;
 #endif
   OGRGeometryShadow* Buffer( double distance, int quadsecs=30 ) {
     return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs );
   }
 
+  OGRGeometryShadow* Buffer( double distance, char** options ) {
+    return (OGRGeometryShadow*) OGR_G_BufferEx( self, distance, options );
+  }
+
 %apply Pointer NONNULL {OGRGeometryShadow* other};
   %newobject Intersection;
   OGRGeometryShadow* Intersection( OGRGeometryShadow* other ) {

This triggered a change in ogr.py:

--- swig/python/osgeo/ogr.py
+++ swig/python/osgeo/ogr.py
@@ -5674,9 +5674,10 @@
         r"""RemoveLowerDimensionSubGeoms(Geometry self) -> Geometry"""
         return _ogr.Geometry_RemoveLowerDimensionSubGeoms(self, *args)
 
-    def Buffer(self, *args, **kwargs):
+    def Buffer(self, *args):
         r"""
         Buffer(Geometry self, double distance, int quadsecs=30) -> Geometry
+        Buffer(Geometry self, double distance, char ** options) -> Geometry
 
         Compute buffer of geometry.
 
@@ -5690,6 +5691,9 @@
         quadsecs: int, default=30
             The number of segments used to approximate a 90 degree
             (quadrant) of curvature.
+        options: list/dict
+            An optional list of options to control the buffer output.
+            See :cpp:func:`OGR_G_BufferEx`.
 
         Returns
         --------
@@ -5697,7 +5701,7 @@
             The newly created geometry or None if an error occurs.
 
         """
-        return _ogr.Geometry_Buffer(self, *args, **kwargs)
+        return _ogr.Geometry_Buffer(self, *args)
 
     def Intersection(self, *args):
         r"""

Steps to reproduce the issue

Build the python swig bindings before and after 3632b72.

Versions and provenance

I reproduced on a Debian testing based distribution with SWIG Version 4.2.1.

Additional context

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions