[Git][debian-gis-team/python-mapnik][master] Add upstream patch to use new buffer APIs.

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Wed Dec 6 20:57:25 GMT 2023



Bas Couwenberg pushed to branch master at Debian GIS Project / python-mapnik


Commits:
bf27b60f by Bas Couwenberg at 2023-12-06T21:49:51+01:00
Add upstream patch to use new buffer APIs.

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/buffer-apis.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+python-mapnik (1:0.0~20200224-7da019cf9-6) UNRELEASED; urgency=medium
+
+  * Add upstream patch to use new buffer APIs.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Wed, 06 Dec 2023 21:49:28 +0100
+
 python-mapnik (1:0.0~20200224-7da019cf9-5) unstable; urgency=medium
 
   * Bump Standards-Version to 4.6.2, no changes.


=====================================
debian/patches/buffer-apis.patch
=====================================
@@ -0,0 +1,50 @@
+Description: upgrade to new  buffer APIs
+Author: Artem Pavlenko <artem at mapnik.org>
+Origin: https://github.com/mapnik/python-mapnik/commit/708290aff1ecbc2de080cab5588019caea1a02e1
+Forwarded: not-needed
+
+--- a/src/mapnik_image.cpp
++++ b/src/mapnik_image.cpp
+@@ -250,22 +250,36 @@ std::shared_ptr<image_any> fromstring(st
+     {
+         return std::make_shared<image_any>(reader->read(0,0,reader->width(), reader->height()));
+     }
+-    throw mapnik::image_reader_exception("Failed to load image from buffer" );
++    throw mapnik::image_reader_exception("Failed to load image from String" );
++}
++
++namespace {
++struct view_release
++{
++    view_release(Py_buffer & view)
++        : view_(view) {}
++    ~view_release()
++    {
++        PyBuffer_Release(&view_);
++    }
++    Py_buffer & view_;
++};
+ }
+ 
+ std::shared_ptr<image_any> frombuffer(PyObject * obj)
+ {
+-    void const* buffer=0;
+-    Py_ssize_t buffer_len;
+-    if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0)
++    Py_buffer view;
++    view_release helper(view);
++    if (obj != nullptr && PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) == 0)
+     {
+-        std::unique_ptr<image_reader> reader(get_image_reader(reinterpret_cast<char const*>(buffer),buffer_len));
++        std::unique_ptr<image_reader> reader
++            (get_image_reader(reinterpret_cast<char const*>(view.buf), view.len));
+         if (reader.get())
+         {
+             return std::make_shared<image_any>(reader->read(0,0,reader->width(),reader->height()));
+         }
+     }
+-    throw mapnik::image_reader_exception("Failed to load image from buffer" );
++    throw mapnik::image_reader_exception("Failed to load image from Buffer" );
+ }
+ 
+ void set_grayscale_to_alpha(image_any & im)


=====================================
debian/patches/series
=====================================
@@ -4,3 +4,4 @@ proj6-apis.patch
 proj6-syntax.patch
 no-distutils.patch
 python-3.12.patch
+buffer-apis.patch



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-mapnik/-/commit/bf27b60f4a67bb6f947fadc850d8c739e0ffcdd2

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-mapnik/-/commit/bf27b60f4a67bb6f947fadc850d8c739e0ffcdd2
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20231206/ed8d01c0/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list