File tree Expand file tree Collapse file tree 12 files changed +18
-47
lines changed Expand file tree Collapse file tree 12 files changed +18
-47
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
6363 - Make sure cProfile is used if profiling - SCons was expecting
6464 the Util module to monkeypatch in cProfile as profile if available,
6565 but this is no longer being done.
66+ - Some Python 2 compat dropped
6667
6768 From Simon Tegelid
6869 - Fix using TEMPFILE in multiple actions in an action list. Previously a builder, or command
Original file line number Diff line number Diff 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 ):
Original file line number Diff line number Diff 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,16 +141,13 @@ 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- """
144+ def get_contents (self ) -> bytes :
145+ """Get contents for signature calculations."""
149146 text_contents = self .get_text_contents ()
150147 try :
151148 return text_contents .encode ()
152- except UnicodeDecodeError :
153- # Already encoded as python2 str are bytes
149+ except AttributeError :
150+ # Should not happen, as get_text_contents returns str
154151 return text_contents
155152
156153 def changed_since_last_build (self , target , prev_ni ):
Original file line number Diff line number Diff line change 3636
3737import collections
3838import os
39-
40- try :
41- from StringIO import StringIO
42- except ImportError :
43- from io import StringIO
39+ from io import StringIO
4440
4541import sys
4642
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments