Merge pull request #4294 from jbicha/py310

mapnik 3.1 Scons needs updating for Python 3.10
This commit is contained in:
Artem Pavlenko 2022-02-08 14:24:42 +00:00 committed by GitHub
commit 7da9009e7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 68 deletions

View file

@ -107,6 +107,7 @@ import sys
import subprocess import subprocess
import itertools import itertools
import inspect import inspect
from collections import OrderedDict
import SCons.Debug import SCons.Debug
from SCons.Debug import logInstanceCreation from SCons.Debug import logInstanceCreation
@ -1289,7 +1290,7 @@ class ListAction(ActionBase):
return result return result
def get_varlist(self, target, source, env, executor=None): def get_varlist(self, target, source, env, executor=None):
result = SCons.Util.OrderedDict() result = OrderedDict()
for act in self.list: for act in self.list:
for var in act.get_varlist(target, source, env, executor): for var in act.get_varlist(target, source, env, executor):
result[var] = True result[var] = True

View file

@ -34,6 +34,7 @@ __revision__ = "src/engine/SCons/Tool/javac.py 74b2c53bc42290e911b334a6b44f187da
import os import os
import os.path import os.path
from collections import OrderedDict
import SCons.Action import SCons.Action
import SCons.Builder import SCons.Builder
@ -70,7 +71,7 @@ def emit_java_classes(target, source, env):
if isinstance(entry, SCons.Node.FS.File): if isinstance(entry, SCons.Node.FS.File):
slist.append(entry) slist.append(entry)
elif isinstance(entry, SCons.Node.FS.Dir): elif isinstance(entry, SCons.Node.FS.Dir):
result = SCons.Util.OrderedDict() result = OrderedDict()
dirnode = entry.rdir() dirnode = entry.rdir()
def find_java_files(arg, dirpath, filenames): def find_java_files(arg, dirpath, filenames):
java_files = sorted([n for n in filenames java_files = sorted([n for n in filenames

View file

@ -37,21 +37,18 @@ import pprint
PY3 = sys.version_info[0] == 3 PY3 = sys.version_info[0] == 3
try: try:
from collections import UserDict, UserList, UserString
except ImportError:
from UserDict import UserDict from UserDict import UserDict
except ImportError as e:
from collections import UserDict
try:
from UserList import UserList from UserList import UserList
except ImportError as e: from UserString import UserString
from collections import UserList
from collections import Iterable
try: try:
from UserString import UserString from collections.abc import Iterable
except ImportError as e: except ImportError:
from collections import UserString from collections import Iterable
from collections import OrderedDict
# Don't "from types import ..." these because we need to get at the # Don't "from types import ..." these because we need to get at the
# types module later to look for UnicodeType. # types module later to look for UnicodeType.
@ -63,7 +60,7 @@ MethodType = types.MethodType
FunctionType = types.FunctionType FunctionType = types.FunctionType
try: try:
unicode _ = type(unicode)
except NameError: except NameError:
UnicodeType = str UnicodeType = str
else: else:
@ -1034,60 +1031,6 @@ class CLVar(UserList):
def __str__(self): def __str__(self):
return ' '.join(self.data) 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): class Selector(OrderedDict):
"""A callable ordered dictionary that maps file suffixes to """A callable ordered dictionary that maps file suffixes to
dictionary values. We preserve the order in which items are added dictionary values. We preserve the order in which items are added