Commit Graph

85 Commits

Author SHA1 Message Date
Michael Hansen
a6de2209fc Add simple_const tests for Python 3.8-3.11, and handle Python 3.11 RESUME opcode 2023-01-24 10:25:10 -08:00
TheHellTower
a3e5ebd481 Add GET_YIELD_FROM_ITER support (#312) 2023-01-19 10:51:08 -08:00
Adrian Haensler
5758634f81 support three digit versions in tests 2022-07-30 00:07:38 -05:00
Adrian Haensler
deebbb044d add a test 2022-07-30 00:02:47 -05:00
Michael Hansen
96ef91b5f9 Allow specifying an output filename on the command line, instead of forcing reliance on shell redirection.
Closes #31
2022-04-26 14:56:12 -07:00
Michael Hansen
4884b5447f Add additional versions of conditional_expressions test 2022-04-26 13:11:40 -07:00
Nenad Čaklović
38a1ee59c3 Support for conditonal expression (if-expression) - review findings 2022-04-02 13:57:10 +02:00
John Richards
25f44aa079 Adds support for CONTAINS_OP opcode
Mentioned in:
- #190
- #191
- #195
2021-10-10 00:40:39 -04:00
John Richards
588f24c872 Adds support for IS_OP opcode
Mentioned in:
- #190
- #191
- #195
2021-10-07 20:29:18 -04:00
John Richards
15f2a4013e Adds an extra test case 2021-10-07 02:02:00 -04:00
John Richards
a504452b7b Adds support for LIST_EXTEND opcode
Addresses #199
2021-10-07 01:51:53 -04:00
Michael Hansen
ac189cc916 Support LOAD_METHOD and CALL_METHOD from Python 3.7+
Fixes #163
2021-04-12 09:55:52 -07:00
Aralox
7a89b72260 Support chained assignment statements, e.g. a = b = c.
We know when we have begun a chained assignment when we process a DUP_TOP with non-null on the stack. Push a NODE_CHAINSTORE onto the stack when this happens, and keep it 'floating' on top of the stack for all STORE_X operations until the stack is empty.
To support versions of Python <= 2.5 which use DUP_TOP in more places, I modified ROT_TWO, ROT_THREE and ROT_FOUR to get rid of NODE_CHAINSTORE on the stack if it is present.
2020-10-23 21:19:01 +11:00
Aralox
1db8d28729 Add compiled test for python 2.7 2020-10-23 14:30:42 +11:00
Aralox
db94f3c257 CRLF -> LF 2020-10-23 11:28:42 +11:00
Aralox
8e8bb95592 Support unpacking empty list.
If UNPACK_SEQUENCE with operand 0 is encountered, treat it like a STORE_X and either assign the TOS to it or set it as the for-loop index.
Issue #183.
2020-10-23 11:23:46 +11:00
Michael Hansen
8eb18de269 Update tests to show that #39 is resolved, and add dummy support for
STORE_LOCALS used in Python 3.0-3.3.

Closes #39
Closes #63
2020-10-22 09:06:57 -07:00
Michael Hansen
0540b3991c Merge pull request #181 from Aralox/Issue-124-handle-async-for-GET_AITER_GET_ANEXT
Add support for `async for`
2020-10-22 08:24:56 -07:00
Aralox
7022db1bf6 Modify async for test to avoid known try-except problem with trailing unnecessary continue when the try-except is not followed by any other statements.
Add an xfail test to capture this failing scenario.
2020-10-22 15:35:59 +11:00
John Richards
345035b544 Adds support for SETUP_ANNOTATION op and variable annotations
Tests have also been added.

Fixes #169
2020-10-21 21:42:13 -04:00
Aralox
e80aa996fa Only initialize the async for once. 2020-10-22 09:11:51 +11:00
Aralox
5bdc0b5baf Merge remote-tracking branch 'upstream/master' into Issue-124-handle-async-for-GET_AITER_GET_ANEXT
Conflicts:
	ASTree.cpp
2020-10-21 19:34:37 +11:00
Aralox
91a23f914d Implement better handling for async for.
Instead of ignoring boilerplate when decompiling `async for`, build the loop semantically by deconstructing the BLK_WHILE -> BLK_CONTAINER -> BLK_TRY that python generates when compiling an `async for` (see https://www.python.org/dev/peps/pep-0492/#asynchronous-iterators-and-async-for).
When reading GET_AITER, convert the BLK_WHILE into a BLK_ASYNCFOR in the same way as a `for` loop.
Ignore GET_ANEXT.
Use END_FINALLY as the trigger to finish building the BLK_ASYNCFOR:
-> Extract the loop variable from the contents of the BLK_TRY.
-> Throw away the BLK_TRY and BLK_CONTAINER, leave the BLK_ASYNCFOR on top of the stack.
2020-10-21 19:32:20 +11:00
Michael Hansen
d3a46f711f Merge remote-tracking branch 'dotjrich/issue-172' into master 2020-10-20 21:10:55 -07:00
Aralox
db12d15e08 Fix token_dump for strings with single quotes in them. Update f-string test tokens. 2020-10-21 10:38:58 +11:00
Aralox
8933c9a4a9 Add support for async for. Issue #124
Ignore 'boilerplate' opcodes that set up the async iteration logic internally (https://www.python.org/dev/peps/pep-0492/#asynchronous-iterators-and-async-for) - We don’t need any of this as GET_AITER is enough to tell us that we are in an `async for`.
2020-10-20 20:39:23 +11:00
John Richards
5b819fa23e Adds support for BUILD_CONST_KEY_MAP opcode
Tests have also been added.

Fixes #172
2020-10-20 01:46:38 -04:00
Aralox
7af40a779f CRAs 2020-10-20 16:42:19 +11:00
Aralox
0c9fbd9caf Issue-165 Added support for f-strings (literal string interpolation https://www.python.org/dev/peps/pep-0498/)
Opcodes handled: FORMAT_VALUE, BUILD_STRING.
Added AST node classes for FormattedValue and JoinedStr.
2020-10-17 20:52:57 +11:00
John Richards
870ecdc430 Handle NaN and infinity values
Right now, NaN/infinity values will produce "nan" and "inf", but
Python doesn't allow those in source code. This change will wrap
those values in float(''), which is allowed.

Tests for Python 2.7 and 3.8 have been added as well.

Fixes #136
2020-10-15 21:04:57 -04:00
Michael Hansen
de78e1b882 Unmangle private names ('__' prefix) in class declarations.
Fixes #166.
2019-10-10 14:47:48 -07:00
Michael Hansen
375b8b0c68 Fix non-inplace matrix multiplication operator. 2019-10-10 11:47:48 -07:00
Michael Hansen
de3f7982c3 Support 'yield from' (Python 3.3) and await (Python 3.5) expressions.
Currently unsupported are yield from in newer Python versions, and
yield/yield from into an assignment expression.
2019-10-10 10:59:10 -07:00
Michael Hansen
13397c940e Don't emit statements for null values on the stack.
Fixes several test cases with extraneous None lines.
2019-10-10 10:26:19 -07:00
Michael Hansen
c71d41efb6 Add MSVC-based CI build 2019-10-09 20:33:39 -07:00
Michael Hansen
15da179173 Merge print nodes in the AST rather than attempting to manage it during
print statement output. Fixes numerous bugs with mangled print statements.
2019-10-09 14:20:46 -07:00
Michael Hansen
c928df906b Fix applyEquiv test by writing the correct name from the call object. 2019-10-08 11:44:52 -07:00
Michael Hansen
9309effba9 Support Python 3.x kw-only arguments. 2019-10-08 11:36:12 -07:00
Michael Hansen
3e379c114e Don't emit a 'pass' statement on an empty top-level module code object
Fixes test_empty test case.
2019-10-08 09:04:41 -07:00
Michael Hansen
3009ea38d2 Handle Python 3.3's automatic __qualname__ assignment.
Fixes loadbuild_class.py test.
2019-10-08 08:53:53 -07:00
Michael Hansen
44af6a2c04 Finish removing old tests and old "test" framework. 2019-10-07 20:57:43 -07:00
Michael Hansen
391ba6502d Migrate additional tests which previously didn't have reference source to
the new test system, including new reference source.
2019-10-07 17:06:08 -07:00
Michael Hansen
9524099488 Migrate test_tuple_params to new test framework.
This test relies on some old syntax for tuples that may need to get
cleaned up before the test can pass on both old and new Pythons.
2019-10-07 13:54:46 -07:00
Michael Hansen
86b88091df Unify test_prettyprint variations and add to passing tests. 2019-10-07 13:42:39 -07:00
Michael Hansen
ab58fba23b Move more tests into the new framework, including current xfails. 2019-10-07 13:38:19 -07:00
Michael Hansen
0dc49b5872 Add support for expected test failures 2019-10-07 11:36:09 -07:00
Michael Hansen
8014ac2b14 Print unicode as default in Python 2.x when CO_FUTURE_UNICODE_LITERALS
is set.

Fixes #141.
2019-10-06 14:34:24 -07:00
Michael Hansen
892616b560 Add tests for unicode/bytes string literals 2019-10-06 13:50:53 -07:00
Michael Hansen
b5696c8398 Port Python 2.7 list comprehension fixes by @ReDucTor from #78 2019-10-04 16:35:58 -07:00
Michael Hansen
727da48ba5 Display the diff when a test doesn't match the expected output. 2019-10-04 14:57:59 -07:00