Control: tags 1000360 + pending Dear maintainer,
I've prepared an NMU for segyio (versioned as 1.8.3-1.1) and uploaded it to DELAYED/5. Please feel free to tell me if I should delay it longer. Also filed as: https://salsa.debian.org/science-team/segyio/-/merge_requests/1 I'd really suggest a new upstream release, instead, though... Regards, SR
diff -Nru segyio-1.8.3/debian/changelog segyio-1.8.3/debian/changelog --- segyio-1.8.3/debian/changelog 2018-12-23 08:17:03.000000000 -0400 +++ segyio-1.8.3/debian/changelog 2021-11-21 22:51:13.000000000 -0400 @@ -1,3 +1,12 @@ +segyio (1.8.3-1.1) unstable; urgency=medium + + * Non-maintainer upload. + * Python 3.10 support. (Closes: #1000360) + - Patch: Import from collections.abc. + - Patch: PY_SSIZE_T_CLEAN. + + -- Stefano Rivera <[email protected]> Sun, 21 Nov 2021 22:51:13 -0400 + segyio (1.8.3-1) unstable; urgency=medium * New upstream release diff -Nru segyio-1.8.3/debian/patches/python-3.10-collections.abc.patch segyio-1.8.3/debian/patches/python-3.10-collections.abc.patch --- segyio-1.8.3/debian/patches/python-3.10-collections.abc.patch 1969-12-31 20:00:00.000000000 -0400 +++ segyio-1.8.3/debian/patches/python-3.10-collections.abc.patch 2021-11-21 22:51:13.000000000 -0400 @@ -0,0 +1,210 @@ +From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= <[email protected]> +Date: Mon, 7 Oct 2019 13:42:35 +0200 +Subject: Try-import collections.abc + +In python 3.8 [1], importing the abstract base classes from collections +will break. Protecting the import in try is both backwards- and forward +compatible, as collections.abc is not valid in python2. + +[1] DeprecationWarning: Using or importing the ABCs from 'collections' + instead of from 'collections.abc' is deprecated, and in 3.8 it will + stop working + +Origin: upstream, https://github.com/equinor/segyio/commit/b6378fb2a283c504209b55e1d1af402d4d765e11 +Bug-Debian: https://bugs.debian.org/1000360 +--- + python/segyio/depth.py | 7 ++++++- + python/segyio/field.py | 17 +++++++++++------ + python/segyio/line.py | 14 +++++++++----- + python/segyio/trace.py | 18 +++++++++++------- + 4 files changed, 37 insertions(+), 19 deletions(-) + +diff --git a/python/segyio/depth.py b/python/segyio/depth.py +index 948e1e5..7346cfa 100644 +--- a/python/segyio/depth.py ++++ b/python/segyio/depth.py +@@ -1,3 +1,8 @@ ++try: ++ from collections.abc import Sequence # noqa ++except ImportError: ++ from collections import Sequence # noqa ++ + import numpy as np + try: from future_builtins import zip + except ImportError: pass +@@ -23,7 +28,7 @@ class Depth(Sequence): + .. versionadded:: 1.1 + + .. versionchanged:: 1.6 +- common list operations (collections.Sequence) ++ common list operations (Sequence) + + .. versionchanged:: 1.7.1 + enabled for unstructured files +diff --git a/python/segyio/field.py b/python/segyio/field.py +index f6e8a46..8389935 100644 +--- a/python/segyio/field.py ++++ b/python/segyio/field.py +@@ -1,10 +1,15 @@ +-import collections ++try: ++ from collections.abc import Mapping # noqa ++ from collections.abc import MutableMapping # noqa ++except ImportError: ++ from collections import Mapping # noqa ++ from collections import MutableMapping # noqa + + import segyio + from .binfield import BinField + from .tracefield import TraceField + +-class Field(collections.MutableMapping): ++class Field(MutableMapping): + """ + The Field implements the dict interface, with a fixed set of keys. It's + used for both binary- and trace headers. Any modifications to this +@@ -22,7 +27,7 @@ class Field(collections.MutableMapping): + common dict operations (update, keys, values) + + .. versionchanged:: 1.6 +- more common dict operations (collections.MutableMapping) ++ more common dict operations (MutableMapping) + """ + _bin_keys = [x for x in BinField.enums() + if x != BinField.Unassigned1 +@@ -438,7 +443,7 @@ class Field(collections.MutableMapping): + def __eq__(self, other): + """x.__eq__(y) <==> x == y""" + +- if not isinstance(other, collections.Mapping): ++ if not isinstance(other, Mapping): + return NotImplemented + + if len(self) != len(other): +@@ -492,13 +497,13 @@ class Field(collections.MutableMapping): + + buf = bytearray(self.buf) + +- # Implementation largely borrowed from collections.mapping ++ # Implementation largely borrowed from Mapping + # If E present and has a .keys() method: for k in E: D[k] = E[k] + # If E present and lacks .keys() method: for (k, v) in E: D[k] = v + # In either case, this is followed by: for k, v in F.items(): D[k] = v + if len(args) == 1: + other = args[0] +- if isinstance(other, collections.Mapping): ++ if isinstance(other, Mapping): + for key in other: + self.putfield(buf, int(key), other[key]) + elif hasattr(other, "keys"): +diff --git a/python/segyio/line.py b/python/segyio/line.py +index 2307823..9984b47 100644 +--- a/python/segyio/line.py ++++ b/python/segyio/line.py +@@ -1,4 +1,8 @@ +-import collections ++try: ++ from collections.abc import Mapping # noqa ++except ImportError: ++ from collections import Mapping # noqa ++ + import itertools + try: from future_builtins import zip + except ImportError: pass +@@ -25,7 +29,7 @@ def sanitize_slice(s, source): + + return slice(start, stop, step) + +-class Line(collections.Mapping): ++class Line(Mapping): + """ + The Line implements the dict interface, with a fixed set of int_like keys, + the line numbers/labels. Data is read lazily from disk, so iteration does +@@ -54,7 +58,7 @@ class Line(collections.Mapping): + .. versionadded:: 1.1 + + .. versionchanged:: 1.6 +- common dict operations (collections.Mapping) ++ common dict operations (Mapping) + """ + + def __init__(self, filehandle, labels, length, stride, offsets, name): +@@ -311,7 +315,7 @@ class Line(collections.Mapping): + ) + except StopIteration: return + +- # can't rely on most collections.Mapping default implementations of ++ # can't rely on most Mapping default implementations of + # dict-like, because iter() does not yield keys for this class, it gives + # the lines themselves. that violates some assumptions (but segyio's always + # worked that way), and it's the more natural behaviour for segyio, so it's +@@ -352,7 +356,7 @@ class HeaderLine(Line): + .. versionadded:: 1.1 + + .. versionchanged:: 1.6 +- common dict operations (collections.Mapping) ++ common dict operations (Mapping) + """ + # a lot of implementation details are shared between reading data traces + # line-by-line and trace headers line-by-line, so (ab)use inheritance for +diff --git a/python/segyio/trace.py b/python/segyio/trace.py +index f6eb207..cfbc5e4 100644 +--- a/python/segyio/trace.py ++++ b/python/segyio/trace.py +@@ -1,4 +1,8 @@ +-import collections ++try: ++ from collections.abc import Sequence # noqa ++except ImportError: ++ from collections import Sequence # noqa ++ + import contextlib + import itertools + import warnings +@@ -12,7 +16,7 @@ from .line import HeaderLine + from .field import Field + from .utils import castarray + +-class Sequence(collections.Sequence): ++class Sequence(Sequence): + + # unify the common optimisations and boilerplate of Trace, RawTrace, and + # Header, which all obey the same index-oriented interface, and all share +@@ -30,8 +34,8 @@ class Sequence(collections.Sequence): + + def __iter__(self): + """x.__iter__() <==> iter(x)""" +- # __iter__ has a reasonable default implementation from +- # collections.Sequence. It's essentially this loop: ++ # __iter__ has a reasonable default implementation from Sequence. It's ++ # essentially this loop: + # for i in range(len(self)): yield self[i] + # However, in segyio that means the double-buffering, buffer reuse does + # not happen, which is *much* slower (the allocation of otherwised +@@ -69,7 +73,7 @@ class Trace(Sequence): + .. versionadded:: 1.1 + + .. versionchanged:: 1.6 +- common list operations (collections.Sequence) ++ common list operations (Sequence) + + Examples + -------- +@@ -524,7 +528,7 @@ class Header(Sequence): + .. versionadded:: 1.1 + + .. versionchanged:: 1.6 +- common list operations (collections.Sequence) ++ common list operations (Sequence) + + """ + def __init__(self, segy): +@@ -790,7 +794,7 @@ class Text(Sequence): + Notes + ----- + .. versionchanged:: 1.7 +- common list operations (collections.Sequence) ++ common list operations (Sequence) + + """ + diff -Nru segyio-1.8.3/debian/patches/python-3.10-py_ssize_t.patch segyio-1.8.3/debian/patches/python-3.10-py_ssize_t.patch --- segyio-1.8.3/debian/patches/python-3.10-py_ssize_t.patch 1969-12-31 20:00:00.000000000 -0400 +++ segyio-1.8.3/debian/patches/python-3.10-py_ssize_t.patch 2021-11-21 22:51:13.000000000 -0400 @@ -0,0 +1,61 @@ +From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= <[email protected]> +Date: Wed, 14 Oct 2020 10:40:21 +0200 +Subject: Use Py_ssize_t for type-length arguments + +The with-length argument type specifier would be either int or +Py_ssize_t, depending on the PY_SSIZE_T_CLEAN macro being defined. + +From the docs: + For all # variants of formats (s#, y#, etc.), the type of the length + argument (int or Py_ssize_t) is controlled by defining the macro + PY_SSIZE_T_CLEAN before including Python.h. If the macro was defined, + length is a Py_ssize_t rather than an int. This behavior will change + in a future Python version to only support Py_ssize_t and drop int + support. It is best to always define PY_SSIZE_T_CLEAN. + +https://docs.python.org/3/c-api/arg.html#arg-parsing + +In python3.8, using ints for lengths (i.e. not defining +PY_SSIZE_T_CLEAN) is considered deprecated, and in future versions of +python only Py_ssize_t will be legal. + +From the docs: + It is recommended to always define PY_SSIZE_T_CLEAN before including + Python.h. See Parsing arguments and building values for a description + of this macro. + +https://docs.python.org/3/c-api/intro.html + +Origin: upstream, https://github.com/equinor/segyio/commit/5c97fe741f066df0ce69ce0d0422d989ea1d0033 +Bug-Debian: https://bugs.debian.org/1000360 +--- + python/segyio/segyio.cpp | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/python/segyio/segyio.cpp b/python/segyio/segyio.cpp +index 63c1f17..38ba281 100644 +--- a/python/segyio/segyio.cpp ++++ b/python/segyio/segyio.cpp +@@ -1,3 +1,4 @@ ++#define PY_SSIZE_T_CLEAN + #if defined(_DEBUG) && defined(_MSC_VER) + # define _CRT_NOFORCE_MAINFEST 1 + # undef _DEBUG +@@ -1000,7 +1001,7 @@ PyObject* puttr( segyiofd* self, PyObject* args ) { + + int traceno; + char* buffer; +- int buflen; ++ Py_ssize_t buflen; + + if( !PyArg_ParseTuple( args, "is#", &traceno, &buffer, &buflen ) ) + return NULL; +@@ -1483,7 +1484,7 @@ PyObject* fread_trace0( PyObject* , PyObject* args ) { + int stride; + int offsets; + int* indices; +- int indiceslen; ++ Py_ssize_t indiceslen; + char* linetype; + + if( !PyArg_ParseTuple( args, "iiiis#s", &lineno, diff -Nru segyio-1.8.3/debian/patches/series segyio-1.8.3/debian/patches/series --- segyio-1.8.3/debian/patches/series 1969-12-31 20:00:00.000000000 -0400 +++ segyio-1.8.3/debian/patches/series 2021-11-21 22:51:13.000000000 -0400 @@ -0,0 +1,2 @@ +python-3.10-collections.abc.patch +python-3.10-py_ssize_t.patch

