[Git][debian-gis-team/mapnik][master] Cherry-pick patch to stop using deprecated py3 collections import

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Mon Feb 7 17:38:32 GMT 2022



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


Commits:
94f38025 by Jeremy Bicha at 2022-02-07T11:48:32-05:00
Cherry-pick patch to stop using deprecated py3 collections import

- - - - -


2 changed files:

- + debian/patches/Stop-using-custom-OrderedDict.patch
- debian/patches/series


Changes:

=====================================
debian/patches/Stop-using-custom-OrderedDict.patch
=====================================
@@ -0,0 +1,170 @@
+From: Mats Wichmann <mats at linux.com>
+Date: Sun, 26 Aug 2018 22:54:00 -0600
+Subject: Stop using custom OrderedDict
+
+OrdredDict is in the standard library for all supported Python versions
+(2.7 and 3.5+) and has improvements over the ActiveState recipe version
+of OrderedDict we have been using. Switch to importing from collections
+instead of getting it from SCons.Util (tests already did this).
+
+At the same time, reorganize the Util.py imports - import Iterable
+from collections.abc if possible (it is deprecated to import
+it from collections, will stop working in 3.8); try getting the
+User{Dict,List,String} from collections if possible - that is, try the
+3.x way first.
+
+Signed-off-by: Mats Wichmann <mats at linux.com>
+
+https://github.com/SCons/scons/commit/3fa7141ec7b39
+---
+ scons/scons-local-3.0.1/SCons/Action.py     |  3 +-
+ scons/scons-local-3.0.1/SCons/Tool/javac.py |  3 +-
+ scons/scons-local-3.0.1/SCons/Util.py       | 75 ++++-------------------------
+ 3 files changed, 13 insertions(+), 68 deletions(-)
+
+diff --git a/scons/scons-local-3.0.1/SCons/Action.py b/scons/scons-local-3.0.1/SCons/Action.py
+index ce5471d..c8a85f8 100644
+--- a/scons/scons-local-3.0.1/SCons/Action.py
++++ b/scons/scons-local-3.0.1/SCons/Action.py
+@@ -107,6 +107,7 @@ import sys
+ import subprocess
+ import itertools
+ import inspect
++from collections import OrderedDict
+ 
+ import SCons.Debug
+ from SCons.Debug import logInstanceCreation
+@@ -1289,7 +1290,7 @@ class ListAction(ActionBase):
+         return result
+ 
+     def get_varlist(self, target, source, env, executor=None):
+-        result = SCons.Util.OrderedDict()
++        result = OrderedDict()
+         for act in self.list:
+             for var in act.get_varlist(target, source, env, executor):
+                 result[var] = True
+diff --git a/scons/scons-local-3.0.1/SCons/Tool/javac.py b/scons/scons-local-3.0.1/SCons/Tool/javac.py
+index ded1a3e..0c5056b 100644
+--- a/scons/scons-local-3.0.1/SCons/Tool/javac.py
++++ b/scons/scons-local-3.0.1/SCons/Tool/javac.py
+@@ -34,6 +34,7 @@ __revision__ = "src/engine/SCons/Tool/javac.py 74b2c53bc42290e911b334a6b44f187da
+ 
+ import os
+ import os.path
++from collections import OrderedDict
+ 
+ import SCons.Action
+ import SCons.Builder
+@@ -70,7 +71,7 @@ def emit_java_classes(target, source, env):
+         if isinstance(entry, SCons.Node.FS.File):
+             slist.append(entry)
+         elif isinstance(entry, SCons.Node.FS.Dir):
+-            result = SCons.Util.OrderedDict()
++            result = OrderedDict()
+             dirnode = entry.rdir()
+             def find_java_files(arg, dirpath, filenames):
+                 java_files = sorted([n for n in filenames
+diff --git a/scons/scons-local-3.0.1/SCons/Util.py b/scons/scons-local-3.0.1/SCons/Util.py
+index c9aa2b5..8f19f51 100644
+--- a/scons/scons-local-3.0.1/SCons/Util.py
++++ b/scons/scons-local-3.0.1/SCons/Util.py
+@@ -37,21 +37,18 @@ import pprint
+ PY3 = sys.version_info[0] == 3
+ 
+ try:
++    from collections import UserDict, UserList, UserString
++except ImportError:
+     from UserDict import UserDict
+-except ImportError as e:
+-    from collections import UserDict
+-
+-try:
+     from UserList import UserList
+-except ImportError as e:
+-    from collections import UserList
+-
+-from collections import Iterable
++    from UserString import UserString
+ 
+ try:
+-    from UserString import UserString
+-except ImportError as e:
+-    from collections import UserString
++    from collections.abc import Iterable
++except ImportError:
++    from collections import Iterable
++
++from collections import OrderedDict
+ 
+ # Don't "from types import ..." these because we need to get at the
+ # types module later to look for UnicodeType.
+@@ -63,7 +60,7 @@ MethodType      = types.MethodType
+ FunctionType    = types.FunctionType
+ 
+ try:
+-    unicode
++    _ = type(unicode)
+ except NameError:
+     UnicodeType = str
+ else:
+@@ -1034,60 +1031,6 @@ class CLVar(UserList):
+     def __str__(self):
+         return ' '.join(self.data)
+ 
+-# A dictionary that preserves the order in which items are added.
+-# Submitted by David Benjamin to ActiveState's Python Cookbook web site:
+-#     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
+-# Including fixes/enhancements from the follow-on discussions.
+-class OrderedDict(UserDict):
+-    def __init__(self, dict = None):
+-        self._keys = []
+-        UserDict.__init__(self, dict)
+-
+-    def __delitem__(self, key):
+-        UserDict.__delitem__(self, key)
+-        self._keys.remove(key)
+-
+-    def __setitem__(self, key, item):
+-        UserDict.__setitem__(self, key, item)
+-        if key not in self._keys: self._keys.append(key)
+-
+-    def clear(self):
+-        UserDict.clear(self)
+-        self._keys = []
+-
+-    def copy(self):
+-        dict = OrderedDict()
+-        dict.update(self)
+-        return dict
+-
+-    def items(self):
+-        return list(zip(self._keys, list(self.values())))
+-
+-    def keys(self):
+-        return self._keys[:]
+-
+-    def popitem(self):
+-        try:
+-            key = self._keys[-1]
+-        except IndexError:
+-            raise KeyError('dictionary is empty')
+-
+-        val = self[key]
+-        del self[key]
+-
+-        return (key, val)
+-
+-    def setdefault(self, key, failobj = None):
+-        UserDict.setdefault(self, key, failobj)
+-        if key not in self._keys: self._keys.append(key)
+-
+-    def update(self, dict):
+-        for (key, val) in dict.items():
+-            self.__setitem__(key, val)
+-
+-    def values(self):
+-        return list(map(self.get, self._keys))
+-
+ class Selector(OrderedDict):
+     """A callable ordered dictionary that maps file suffixes to
+     dictionary values.  We preserve the order in which items are added


=====================================
debian/patches/series
=====================================
@@ -1 +1,2 @@
 libxml2.patch
+Stop-using-custom-OrderedDict.patch



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

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/mapnik/-/commit/94f380259840f86c8c60ef24eda0128805f28dbf
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/20220207/57e35b60/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list