summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2020-01-10 00:42:20 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2020-01-10 00:42:20 (GMT)
commit3b10a27fab8a646c499c38630b1d27d64ae8b1c3 (patch)
tree6627a661686a5c6dd17db8847f489d8cf2b414ea /src/engine/SCons
parentc5531583f832b59c7d5ec0af682e33e04ef7ff4a (diff)
downloadSCons-3b10a27fab8a646c499c38630b1d27d64ae8b1c3.zip
SCons-3b10a27fab8a646c499c38630b1d27d64ae8b1c3.tar.gz
SCons-3b10a27fab8a646c499c38630b1d27d64ae8b1c3.tar.bz2
Remove if PY3 code.
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/CacheDir.py6
-rw-r--r--src/engine/SCons/CacheDirTests.py6
-rw-r--r--src/engine/SCons/Tool/suncxx.py18
-rw-r--r--src/engine/SCons/Tool/textfile.py12
-rw-r--r--src/engine/SCons/Util.py11
-rw-r--r--src/engine/SCons/UtilTests.py7
6 files changed, 17 insertions, 43 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index 10c088d..9bb7ef3 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -36,7 +36,6 @@ import sys
import SCons
import SCons.Action
import SCons.Warnings
-from SCons.Util import PY3
cache_enabled = True
cache_debug = False
@@ -160,10 +159,7 @@ class CacheDir(object):
if path is None:
return
- if PY3:
- self._readconfig3(path)
- else:
- self._readconfig2(path)
+ self._readconfig3(path)
def _readconfig3(self, path):
diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py
index 0e242c4..ff22d01 100644
--- a/src/engine/SCons/CacheDirTests.py
+++ b/src/engine/SCons/CacheDirTests.py
@@ -33,7 +33,6 @@ import stat
from TestCmd import TestCmd
import SCons.CacheDir
-from SCons.Util import PY3
built_it = None
@@ -169,10 +168,7 @@ class ExceptionTestCase(unittest.TestCase):
os.remove(old_config)
try:
- if PY3:
- self._CacheDir._readconfig3(self._CacheDir.path)
- else:
- self._CacheDir._readconfig2(self._CacheDir.path)
+ self._CacheDir._readconfig3(self._CacheDir.path)
assert False, "Should have raised exception and did not"
except SCons.Errors.SConsEnvironmentError as e:
assert str(e) == "Failed to write cache configuration for {}".format(self._CacheDir.path)
diff --git a/src/engine/SCons/Tool/suncxx.py b/src/engine/SCons/Tool/suncxx.py
index c155484..1c35612 100644
--- a/src/engine/SCons/Tool/suncxx.py
+++ b/src/engine/SCons/Tool/suncxx.py
@@ -39,7 +39,6 @@ import os
import re
import subprocess
-from SCons.Util import PY3
import SCons.Tool.cxx
cplusplus = SCons.Tool.cxx
# cplusplus = __import__('c++', globals(), locals(), [])
@@ -53,10 +52,7 @@ def get_package_info(package_name, pkginfo, pkgchk):
except KeyError:
version = None
pathname = None
- try:
- from subprocess import DEVNULL # py3k
- except ImportError:
- DEVNULL = open(os.devnull, 'wb')
+ from subprocess import DEVNULL
try:
with open('/var/sadm/install/contents', 'r') as f:
@@ -72,16 +68,14 @@ def get_package_info(package_name, pkginfo, pkgchk):
try:
popen_args = {'stdout': subprocess.PIPE,
'stderr': DEVNULL}
- if PY3:
- popen_args['universal_newlines'] = True
+ popen_args['universal_newlines'] = True
p = subprocess.Popen([pkginfo, '-l', package_name],
**popen_args)
except EnvironmentError:
pass
else:
pkginfo_contents = p.communicate()[0]
- if not PY3:
- pkginfo_contents.decode()
+ pkginfo_contents.decode()
version_re = re.compile(r'^ *VERSION:\s*(.*)$', re.M)
version_match = version_re.search(pkginfo_contents)
if version_match:
@@ -91,16 +85,14 @@ def get_package_info(package_name, pkginfo, pkgchk):
try:
popen_args = {'stdout': subprocess.PIPE,
'stderr': DEVNULL}
- if PY3:
- popen_args['universal_newlines'] = True
+ popen_args['universal_newlines'] = True
p = subprocess.Popen([pkgchk, '-l', package_name],
**popen_args)
except EnvironmentError:
pass
else:
pkgchk_contents = p.communicate()[0]
- if not PY3:
- pkgchk_contents.decode()
+ pkgchk_contents.decode()
pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M)
pathname_match = pathname_re.search(pkgchk_contents)
if pathname_match:
diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py
index 9e2327a..48a2904 100644
--- a/src/engine/SCons/Tool/textfile.py
+++ b/src/engine/SCons/Tool/textfile.py
@@ -53,13 +53,10 @@ import re
from SCons.Node import Node
from SCons.Node.Python import Value
-from SCons.Util import is_String, is_Sequence, is_Dict, to_bytes, PY3
+from SCons.Util import is_String, is_Sequence, is_Dict, to_bytes
-if PY3:
- TEXTFILE_FILE_WRITE_MODE = 'w'
-else:
- TEXTFILE_FILE_WRITE_MODE = 'wb'
+TEXTFILE_FILE_WRITE_MODE = 'w'
LINESEP = '\n'
@@ -126,10 +123,7 @@ def _action(target, source, env):
# write the file
try:
- if SCons.Util.PY3:
- target_file = open(target[0].get_path(), TEXTFILE_FILE_WRITE_MODE, newline='')
- else:
- target_file = open(target[0].get_path(), TEXTFILE_FILE_WRITE_MODE)
+ target_file = open(target[0].get_path(), TEXTFILE_FILE_WRITE_MODE, newline='')
except (OSError, IOError):
raise SCons.Errors.UserError("Can't write target file %s" % target[0])
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 8ff7b4f..130cc5e 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1567,11 +1567,8 @@ del __revision__
def to_bytes(s):
if s is None:
return b'None'
- if not PY3 and isinstance(s, str):
- # PY2, must encode unicode
- return bytearray(s, 'utf-8')
- if isinstance (s, (bytes, bytearray)) or bytes is str:
- # Above case not covered here as py2 bytes and strings are the same
+ if isinstance(s, (bytes, bytearray)):
+ # if already bytes return.
return s
return bytes(s, 'utf-8')
@@ -1579,9 +1576,9 @@ def to_bytes(s):
def to_str(s):
if s is None:
return 'None'
- if bytes is str or is_String(s):
+ if is_String(s):
return s
- return str (s, 'utf-8')
+ return str(s, 'utf-8')
def cmp(a, b):
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 870e79f..3e700c9 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -311,10 +311,9 @@ class UtilTestCase(unittest.TestCase):
def test_to_Bytes(self):
""" Test the to_Bytes method"""
- if not PY3:
- self.assertEqual(to_bytes(str('Hello')),
- bytearray(u'Hello', 'utf-8'),
- "Check that to_bytes creates byte array when presented with unicode string. PY2 only")
+ self.assertEqual(to_bytes(str('Hello')),
+ bytearray(u'Hello', 'utf-8'),
+ "Check that to_bytes creates byte array when presented with unicode string.")
def test_to_String(self):
"""Test the to_String() method."""