diff options
-rw-r--r-- | src/engine/SCons/Action.py | 7 | ||||
-rw-r--r-- | src/engine/SCons/ActionTests.py | 42 |
2 files changed, 25 insertions, 24 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 4449bea..d6fe30b 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -210,7 +210,7 @@ def _object_contents(obj): return bytearray(repr(obj), 'utf-8') -def _code_contents(code): +def _code_contents(code, docstring=None): """Return the signature contents of a code object. By providing direct access to the code object of the @@ -257,7 +257,8 @@ def _code_contents(code): # function. Note that we have to call _object_contents on each # constants because the code object of nested functions can # show-up among the constants. - z = [_object_contents(cc) for cc in code.co_consts] + + z = [_object_contents(cc) for cc in code.co_consts[1:]] contents.extend(b',(') contents.extend(bytearray(',', 'utf-8').join(z)) contents.extend(b')') @@ -295,7 +296,7 @@ def _function_contents(func): func.__closure__ - None or a tuple of cells that contain bindings for the function's free variables. """ - contents = [_code_contents(func.__code__)] + contents = [_code_contents(func.__code__, func.__doc__)] # The function contents depends on the value of defaults arguments if func.__defaults__: diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index cf42307..9d856c9 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -1430,9 +1430,9 @@ class CommandGeneratorActionTestCase(unittest.TestCase): # Since the python bytecode has per version differences, we need different expected results per version func_matches = { - (2,7) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,5) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,6) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00S\x00),(),()'), + (2,7) : bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,5) : bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,6) : bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'), } meth_matches = [ @@ -1593,15 +1593,15 @@ class FunctionActionTestCase(unittest.TestCase): pass func_matches = { - (2,7) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,5) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,6) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00S\x00),(),()'), + (2,7) : bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,5) : bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,6) : bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'), } meth_matches = { - (2,7) : bytearray(b'1, 1, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,5) : bytearray(b'1, 1, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,6) : bytearray(b'1, 1, 0, 0,(N.),(),(d\x00S\x00),(),()'), + (2,7) : bytearray(b'1, 1, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,5) : bytearray(b'1, 1, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,6) : bytearray(b'1, 1, 0, 0,(),(),(d\x00S\x00),(),()'), } def factory(act, **kw): @@ -1818,9 +1818,9 @@ class LazyActionTestCase(unittest.TestCase): func_matches = { - (2,7) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,5) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00S),(),()'), - (3,6) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00S\x00),(),()'), + (2,7) : bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,5) : bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'), + (3,6) : bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'), } meth_matches = [ @@ -2058,9 +2058,9 @@ class ObjectContentsTestCase(unittest.TestCase): # Since the python bytecode has per version differences, we need different expected results per version expected = { - (2,7) : bytearray(b'3, 3, 0, 0,(A test function),(),(|\x00\x00S),(),()'), - (3,5) : bytearray(b'3, 3, 0, 0,(A test function),(),(|\x00\x00S),(),()'), - (3,6) : bytearray(b'3, 3, 0, 0,(A test function),(),(|\x00S\x00),(),()'), + (2,7) : bytearray(b'3, 3, 0, 0,(),(),(|\x00\x00S),(),()'), + (3,5) : bytearray(b'3, 3, 0, 0,(),(),(|\x00\x00S),(),()'), + (3,6) : bytearray(b'3, 3, 0, 0,(),(),(|\x00S\x00),(),()'), } c = SCons.Action._function_contents(func1) @@ -2078,9 +2078,9 @@ class ObjectContentsTestCase(unittest.TestCase): # Since the python bytecode has per version differences, we need different expected results per version expected = { - (2,7): bytearray(b"{TestClass:__main__}[[[(<type \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<type \'object\'>,))]]]]{{1, 1, 0, 0,(N.,a,b),(a,b),(d\x01\x00|\x00\x00_\x00\x00d\x02\x00|\x00\x00_\x01\x00d\x00\x00S),(),(),2, 2, 0, 0,(N.),(),(d\x00\x00S),(),()}}{{{a=a,b=b}}}"), - (3,5): bytearray(b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(N.,a,b),(a,b),(d\x01\x00|\x00\x00_\x00\x00d\x02\x00|\x00\x00_\x01\x00d\x00\x00S),(),(),2, 2, 0, 0,(N.),(),(d\x00\x00S),(),()}}{{{a=a,b=b}}}"), - (3,6): bytearray(b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(N.,a,b),(a,b),(d\x01|\x00_\x00d\x02|\x00_\x01d\x00S\x00),(),(),2, 2, 0, 0,(N.),(),(d\x00S\x00),(),()}}{{{a=a,b=b}}}"), + (2,7): bytearray(b"{TestClass:__main__}[[[(<type \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<type \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01\x00|\x00\x00_\x00\x00d\x02\x00|\x00\x00_\x01\x00d\x00\x00S),(),(),2, 2, 0, 0,(),(),(d\x00\x00S),(),()}}{{{a=a,b=b}}}"), + (3,5): bytearray(b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01\x00|\x00\x00_\x00\x00d\x02\x00|\x00\x00_\x01\x00d\x00\x00S),(),(),2, 2, 0, 0,(),(),(d\x00\x00S),(),()}}{{{a=a,b=b}}}"), + (3,6): bytearray(b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01|\x00_\x00d\x02|\x00_\x01d\x00S\x00),(),(),2, 2, 0, 0,(),(),(d\x00S\x00),(),()}}{{{a=a,b=b}}}"), } assert c == expected[sys.version_info[:2]], "Got\n"+repr(c)+"\nExpected \n"+"\n"+repr(expected[sys.version_info[:2]]) @@ -2093,9 +2093,9 @@ class ObjectContentsTestCase(unittest.TestCase): # Since the python bytecode has per version differences, we need different expected results per version expected = { - (2,7) : bytearray(b'0, 0, 0, 0,(Hello, World!,N.),(),(d\x00\x00GHd\x01\x00S)'), - (3,5) : bytearray(b'0, 0, 0, 0,(Hello, World!,N.),(print),(e\x00\x00d\x00\x00\x83\x01\x00\x01d\x01\x00S)'), - (3,6) : bytearray(b'0, 0, 0, 0,(Hello, World!,N.),(print),(e\x00d\x00\x83\x01\x01\x00d\x01S\x00)'), + (2,7) : bytearray(b'0, 0, 0, 0,(N.),(),(d\x00\x00GHd\x01\x00S)'), + (3,5) : bytearray(b'0, 0, 0, 0,(N.),(print),(e\x00\x00d\x00\x00\x83\x01\x00\x01d\x01\x00S)'), + (3,6) : bytearray(b'0, 0, 0, 0,(N.),(print),(e\x00d\x00\x83\x01\x01\x00d\x01S\x00)'), } assert c == expected[sys.version_info[:2]], "Got\n"+repr(c)+"\nExpected \n"+"\n"+expected[sys.version_info[:2]] |