summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Blevins <wblevins001@gmail.com>2016-09-21 23:54:23 (GMT)
committerWilliam Blevins <wblevins001@gmail.com>2016-09-21 23:54:23 (GMT)
commit88eb753eb8e65721368beb2fc1247312e2a5ab4c (patch)
treef8628927dfdc201f4e4aca0a0101210be85fb1fc
parentf5035c6a61ad10f440a22c14ce22bbb1d6796f62 (diff)
downloadSCons-88eb753eb8e65721368beb2fc1247312e2a5ab4c.zip
SCons-88eb753eb8e65721368beb2fc1247312e2a5ab4c.tar.gz
SCons-88eb753eb8e65721368beb2fc1247312e2a5ab4c.tar.bz2
Fixed difference in types MethodType argument list between 2/3 which allowed finishing CC folder.
-rw-r--r--src/engine/SCons/Util.py16
-rw-r--r--test/CC/CC-fixture/bar.c10
-rw-r--r--test/CC/CC-fixture/foo.c10
-rw-r--r--test/CC/CC-fixture/test1.c3
-rw-r--r--test/CC/CC-fixture/test2.C3
-rw-r--r--test/CC/CC.py57
-rw-r--r--test/CC/CCVERSION-fixture/.exclude_tests1
-rw-r--r--test/CC/CCVERSION-fixture/versioned.py12
-rw-r--r--test/CC/CCVERSION.py29
9 files changed, 61 insertions, 80 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 6a7e4a1..7653acd 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1425,14 +1425,22 @@ def AddMethod(obj, function, name=None):
else:
function = RenameFunction(function, name)
+ # Note the Python version checks - WLB
+ # Python 3.3 dropped the 3rd parameter from types.MethodType
if hasattr(obj, '__class__') and obj.__class__ is not type:
# "obj" is an instance, so it gets a bound method.
- method = MethodType(function, obj, obj.__class__)
- setattr(obj, name, method)
+ if sys.version_info[:2] > (3, 2):
+ method = MethodType(function, obj)
+ else:
+ method = MethodType(function, obj, obj.__class__)
else:
# "obj" is a class, so it gets an unbound method.
- function = MethodType(function, None, obj)
- setattr(obj, name, function)
+ if sys.version_info[:2] > (3, 2):
+ method = MethodType(function, None)
+ else:
+ method = MethodType(function, None, obj)
+
+ setattr(obj, name, method)
def RenameFunction(function, name):
"""
diff --git a/test/CC/CC-fixture/bar.c b/test/CC/CC-fixture/bar.c
new file mode 100644
index 0000000..de1e6e5
--- /dev/null
+++ b/test/CC/CC-fixture/bar.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("foo.c\n");
+ exit (0);
+}
diff --git a/test/CC/CC-fixture/foo.c b/test/CC/CC-fixture/foo.c
new file mode 100644
index 0000000..de1e6e5
--- /dev/null
+++ b/test/CC/CC-fixture/foo.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("foo.c\n");
+ exit (0);
+}
diff --git a/test/CC/CC-fixture/test1.c b/test/CC/CC-fixture/test1.c
new file mode 100644
index 0000000..7535b0a
--- /dev/null
+++ b/test/CC/CC-fixture/test1.c
@@ -0,0 +1,3 @@
+This is a .c file.
+/*cc*/
+/*link*/
diff --git a/test/CC/CC-fixture/test2.C b/test/CC/CC-fixture/test2.C
new file mode 100644
index 0000000..a1ee9e3
--- /dev/null
+++ b/test/CC/CC-fixture/test2.C
@@ -0,0 +1,3 @@
+This is a .C file.
+/*cc*/
+/*link*/
diff --git a/test/CC/CC.py b/test/CC/CC.py
index 9500088..7478cbe 100644
--- a/test/CC/CC.py
+++ b/test/CC/CC.py
@@ -33,7 +33,7 @@ _exe = TestSCons._exe
test = TestSCons.TestSCons()
-
+test.dir_fixture('CC-fixture')
if sys.platform == 'win32':
@@ -53,7 +53,7 @@ while args:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:8] != '/*link*/':
+ if l[:8] != b'/*link*/':
outfile.write(l)
sys.exit(0)
""")
@@ -77,7 +77,7 @@ while args:
infile = open(inf, 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:6] != '/*cc*/':
+ if l[:6] != b'/*cc*/':
outfile.write(l)
sys.exit(0)
""")
@@ -93,7 +93,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:8] != '/*link*/':
+ if l[:8] != b'/*link*/':
outfile.write(l)
sys.exit(0)
""")
@@ -107,7 +107,7 @@ for opt, arg in opts:
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
- if l[:6] != '/*cc*/':
+ if l[:6] != b'/*cc*/':
outfile.write(l)
sys.exit(0)
""")
@@ -122,14 +122,9 @@ env = Environment(LINK = r'%(_python_)s mylink.py',
env.Program(target = 'test1', source = 'test1.c')
""" % locals())
-test.write('test1.c', r"""This is a .c file.
-/*cc*/
-/*link*/
-""")
-
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('test1' + _exe) != "This is a .c file.\n")
+test.must_match('test1' + _exe, "This is a .c file.\n")
if os.path.normcase('.c') == os.path.normcase('.C'):
@@ -141,23 +136,14 @@ env = Environment(LINK = r'%(_python_)s mylink.py',
env.Program(target = 'test2', source = 'test2.C')
""" % locals())
- test.write('test2.C', r"""This is a .C file.
-/*cc*/
-/*link*/
-""")
-
test.run(arguments = '.', stderr = None)
-
- test.fail_test(test.read('test2' + _exe) != "This is a .C file.\n")
-
-
-
+ test.must_match('test2' + _exe, "This is a .C file.\n")
test.write("wrapper.py",
"""import os
import sys
if '--version' not in sys.argv and '-dumpversion' not in sys.argv:
- open('%s', 'wb').write("wrapper.py\\n")
+ open('%s', 'wb').write(b"wrapper.py\\n")
os.system(" ".join(sys.argv[1:]))
""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
@@ -169,33 +155,6 @@ foo.Program(target = 'foo', source = 'foo.c')
bar.Program(target = 'bar', source = 'bar.c')
""" % locals())
-test.write('foo.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("foo.c\n");
- exit (0);
-}
-""")
-
-test.write('bar.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("foo.c\n");
- exit (0);
-}
-""")
-
-
test.run(arguments = 'foo' + _exe)
test.must_not_exist(test.workpath('wrapper.out'))
diff --git a/test/CC/CCVERSION-fixture/.exclude_tests b/test/CC/CCVERSION-fixture/.exclude_tests
new file mode 100644
index 0000000..775816e
--- /dev/null
+++ b/test/CC/CCVERSION-fixture/.exclude_tests
@@ -0,0 +1 @@
+versioned.py
diff --git a/test/CC/CCVERSION-fixture/versioned.py b/test/CC/CCVERSION-fixture/versioned.py
new file mode 100644
index 0000000..d6c7ae8
--- /dev/null
+++ b/test/CC/CCVERSION-fixture/versioned.py
@@ -0,0 +1,12 @@
+import os
+import sys
+if '-dumpversion' in sys.argv:
+ print('3.9.9')
+ sys.exit(0)
+if '--version' in sys.argv:
+ print('this is version 2.9.9 wrapping', sys.argv[2])
+ sys.exit(0)
+if sys.argv[1] not in [ '2.9.9', '3.9.9' ]:
+ print('wrong version', sys.argv[1], 'when wrapping', sys.argv[2])
+ sys.exit(1)
+os.system(" ".join(sys.argv[2:]))
diff --git a/test/CC/CCVERSION.py b/test/CC/CCVERSION.py
index f785ddc..20d8616 100644
--- a/test/CC/CCVERSION.py
+++ b/test/CC/CCVERSION.py
@@ -36,20 +36,8 @@ test = TestSCons.TestSCons()
if sys.platform == 'win32':
test.skip_test('CCVERSION not set with MSVC, skipping test.')
-test.write("versioned.py",
-"""import os
-import sys
-if '-dumpversion' in sys.argv:
- print '3.9.9'
- sys.exit(0)
-if '--version' in sys.argv:
- print 'this is version 2.9.9 wrapping', sys.argv[2]
- sys.exit(0)
-if sys.argv[1] not in [ '2.9.9', '3.9.9' ]:
- print 'wrong version', sys.argv[1], 'when wrapping', sys.argv[2]
- sys.exit(1)
-os.system(" ".join(sys.argv[2:]))
-""")
+test.dir_fixture('CCVERSION-fixture')
+test.file_fixture(os.path.join('CC-fixture', 'foo.c'))
test.write('SConstruct', """
cc = Environment().Dictionary('CC')
@@ -57,19 +45,6 @@ foo = Environment(CC = r'%(_python_)s versioned.py "${CCVERSION}" ' + cc)
foo.Program(target = 'foo', source = 'foo.c')
""" % locals())
-test.write('foo.c', r"""
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("foo.c\n");
- exit (0);
-}
-""")
-
test.run(arguments = 'foo' + _exe)
test.up_to_date(arguments = 'foo' + _exe)