Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.9 ast changes #333

Merged
merged 4 commits into from Mar 20, 2021
Merged

Python 3.9 ast changes #333

merged 4 commits into from Mar 20, 2021

Commits on Mar 19, 2021

  1. Test for Python 3.9 as well

    mcepl authored and mattst88 committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    5fbce2b View commit details
    Browse the repository at this point in the history
  2. Fix test expectations for Python 3.9 AST changes

    Fixes the following two tests under Python 3.9:
    
    FAILED ropetest/refactor/patchedasttest.py::PatchedASTTest::test_ext_slice_node - AssertionError: Node <ExtSlice> cannot be found
    FAILED ropetest/refactor/patchedasttest.py::PatchedASTTest::test_simple_subscript - AssertionError: False is not true : Expected <Index> but was <Constant>
    
    The ast module in Python 3.9 has some API changes. Quoting [1]:
    
        Simplified AST for subscription. Simple indices will be represented
        by their value, extended slices will be represented as tuples.
        Index(value) will return a value itself, ExtSlice(slices) will
        return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in
        bpo-34822.)
    
    [1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api
    mattst88 committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    a63ae26 View commit details
    Browse the repository at this point in the history
  3. Handle AST.expr in _Subscript()

    The ast module in Python 3.9 has some API changes. Quoting [1]:
    
        Simplified AST for subscription. Simple indices will be represented
        by their value, extended slices will be represented as tuples.
        Index(value) will return a value itself, ExtSlice(slices) will
        return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in
        bpo-34822.)
    
    [1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api
    
    isinstance(thing, ast.Index) always return false in Python >= 3.9, so we
    need to handle... whatever the value is now. ast.expr catches 20 of the
    remaining 24 failures. The remaining 4 are resolved in the next patch.
    
    Fixes: #299
    mattst88 committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    02284e4 View commit details
    Browse the repository at this point in the history
  4. Handle AST.expr in static object analysis

    The ast module in Python 3.9 has some API changes. Quoting [1]:
    
        Simplified AST for subscription. Simple indices will be represented
        by their value, extended slices will be represented as tuples.
        Index(value) will return a value itself, ExtSlice(slices) will
        return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in
        bpo-34822.)
    
    [1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api
    
    This fixes the remaining 4 failures under Python 3.9.
    
    FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_append_function
    FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_for_loops
    FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_update
    FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_lists_per_object_for_set_item
    
    Fixes: #299
    mattst88 committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    46a3403 View commit details
    Browse the repository at this point in the history