Skip to content

Commit e046132

Browse files
authored
Merge branch 'master' into addmethod-clone
2 parents 7577f94 + 948e8af commit e046132

File tree

14 files changed

+72
-70
lines changed

14 files changed

+72
-70
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3333
From Adam Gross:
3434
- Fix minor bug affecting SCons.Node.FS.File.get_csig()'s usage of the MD5 chunksize.
3535
User-facing behavior does not change with this fix (GH Issue #3726).
36+
- Fix occasional test failures caused by not being able to find a file or directory fixture
37+
when running multiple tests with multiple jobs.
3638

3739
From Joachim Kuebart:
3840
- Suppress missing SConscript deprecation warning if `must_exist=False`
@@ -68,6 +70,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
6870
any Clone of that instance. Now tries to detect this and calls
6971
MethodWrapper to set up the method the same way env.AddMethod does.
7072
MethodWrapper moved to Util to avoid a circular import. Fixes #3028.
73+
- Some Python 2 compatibility code dropped
7174

7275
From Simon Tegelid
7376
- Fix using TEMPFILE in multiple actions in an action list. Previously a builder, or command

SCons/Node/FS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class EntryProxy(SCons.Util.Proxy):
434434

435435
# In PY3 if a class defines __eq__, then it must explicitly provide
436436
# __hash__. Since SCons.Util.Proxy provides __eq__ we need the following
437-
# see: https://docs.python.org/3.1/reference/datamodel.html#object.__hash__
437+
# see: https://docs.python.org/3/reference/datamodel.html#object.__hash__
438438
__hash__ = SCons.Util.Delegate('__hash__')
439439

440440
def __get_abspath(self):

SCons/Node/Python.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def read(self):
129129
self.built_value = self.value
130130
return self.built_value
131131

132-
def get_text_contents(self):
132+
def get_text_contents(self) -> str:
133133
"""By the assumption that the node.built_value is a
134134
deterministic product of the sources, the contents of a Value
135135
are the concatenation of all the contents of its sources. As
@@ -141,24 +141,16 @@ def get_text_contents(self):
141141
contents = contents + kid.get_contents().decode()
142142
return contents
143143

144-
def get_contents(self):
145-
"""
146-
Get contents for signature calculations.
147-
:return: bytes
148-
"""
149-
text_contents = self.get_text_contents()
150-
try:
151-
return text_contents.encode()
152-
except UnicodeDecodeError:
153-
# Already encoded as python2 str are bytes
154-
return text_contents
144+
def get_contents(self) -> bytes:
145+
"""Get contents for signature calculations."""
146+
return self.get_text_contents().encode()
155147

156148
def changed_since_last_build(self, target, prev_ni):
157149
cur_csig = self.get_csig()
158150
try:
159151
return cur_csig != prev_ni.csig
160152
except AttributeError:
161-
return 1
153+
return True
162154

163155
def get_csig(self, calc=None):
164156
"""Because we're a Python value node and don't have a real

SCons/Script/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@
3636

3737
import collections
3838
import os
39-
40-
try:
41-
from StringIO import StringIO
42-
except ImportError:
43-
from io import StringIO
39+
from io import StringIO
4440

4541
import sys
4642

SCons/SubstTests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,7 @@ def test_subst_syntax_errors(self):
541541
scons_subst('$foo.bar.3.0', env)
542542
except SCons.Errors.UserError as e:
543543
expect = [
544-
# Python 2.3, 2.4
545-
"SyntaxError `invalid syntax (line 1)' trying to evaluate `$foo.bar.3.0'",
546-
# Python 2.5
544+
# Python 2.5 and later
547545
"SyntaxError `invalid syntax (<string>, line 1)' trying to evaluate `$foo.bar.3.0'",
548546
]
549547
assert str(e) in expect, e

SCons/Tool/clang.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def generate(env):
8484
# clang -dumpversion is of no use
8585
with pipe.stdout:
8686
line = pipe.stdout.readline()
87-
if sys.version_info[0] > 2:
88-
line = line.decode()
87+
line = line.decode()
8988
match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line)
9089
if match:
9190
env['CCVERSION'] = match.group(1)

SCons/Tool/clangxx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ def generate(env):
9292
# clang -dumpversion is of no use
9393
with pipe.stdout:
9494
line = pipe.stdout.readline()
95-
if sys.version_info[0] > 2:
96-
line = line.decode()
95+
line = line.decode()
9796
match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line)
9897
if match:
9998
env['CXXVERSION'] = match.group(1)

SCons/Tool/textfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def _do_subst(node, subs):
7474
if 'b' in TEXTFILE_FILE_WRITE_MODE:
7575
try:
7676
contents = bytearray(contents, 'utf-8')
77-
except UnicodeDecodeError:
78-
# contents is already utf-8 encoded python 2 str i.e. a byte array
77+
except TypeError:
78+
# TODO: this should not happen, get_text_contents returns text
7979
contents = bytearray(contents)
8080

8181
return contents

SCons/UtilTests.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ def get_children(node):
193193
try:
194194
node, expect, withtags = self.tree_case_1()
195195

196-
if sys.version_info.major < 3:
197-
IOStream = io.BytesIO
198-
else:
199-
IOStream = io.StringIO
200-
196+
IOStream = io.StringIO
201197
sys.stdout = IOStream()
202198
print_tree(node, get_children)
203199
actual = sys.stdout.getvalue()
@@ -249,11 +245,6 @@ def get_children(node):
249245
def test_is_Dict(self):
250246
assert is_Dict({})
251247
assert is_Dict(UserDict())
252-
253-
# os.environ is not a dictionary in python 3
254-
if sys.version_info < (3, 0):
255-
assert is_Dict(os.environ)
256-
257248
try:
258249
class mydict(dict):
259250
pass

SCons/Utilities/sconsign.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ def default_mapper(entry, name):
9898
val = eval("entry." + name)
9999
except AttributeError:
100100
val = None
101-
if sys.version_info.major >= 3 and isinstance(val, bytes):
102-
# This is a dirty hack for py 2/3 compatibility. csig is a bytes object
103-
# in Python3 while Python2 bytes are str. Hence, we decode the csig to a
104-
# Python3 string
105-
val = val.decode()
106101
return str(val)
107102

108103

@@ -327,8 +322,8 @@ def __call__(self, fname):
327322
sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n"
328323
% (self.dbm_name, fname, e))
329324
exc_type, _, _ = sys.exc_info()
330-
if exc_type.__name__ == "ValueError" and sys.version_info < (3,0,0):
331-
sys.stderr.write("Python 2 only supports pickle protocols 0-2.\n")
325+
if exc_type.__name__ == "ValueError":
326+
sys.stderr.write("unrecognized pickle protocol.\n")
332327
return
333328

334329
if Print_Directories:

0 commit comments

Comments
 (0)