Skip to content

IPython broken on 3.8-dev, due to changes to ast.Module #11590

Closed

Description

@njsmith

In bpo-35766, Guido merged the "typed_ast" code that mypy used to maintain back into main CPython parser. This means that starting in 3.8, the regular ast module will contain information on type comments and type: ignore comments.

The type: ignore comments are stored in a list on the ast.Module object. This list is now mandatory. That means that this code is broken:

mod = ast.Module(nodelist)
async_wrapper_code = compiler(mod, 'cell_name', 'exec')

So is this:

mod = ast.Module([node])
code = compiler(mod, cell_name, "exec")

[BTW, why does one of those say 'cell_name' and the other says cell_name? Seems like one of those must be wrong... CC: @Carreau]

When you create a Module like this and try to compile it, then you get:

  TypeError: required field "type_ignores" missing from Module

On 3.8+, to create a Module object you have to instead write ast.Module(nodelist, []).

I filed a bug on python (bpo-35894), and Guido responded that the details of the AST like this aren't considered stable API, so he considers this a bug for IPython to fix, not a regression on CPython. So, now I'm filing a bug here instead :-).

The full changes are here, and AFAICT this line is the one that's breaking IPython.

Activity

  1. Carreau commented on Feb 5, 2019

    @Carreau
    Member

    For a complete picture, 3.8 is supposed to be stable by end of this year, so this should get fixed soon-ish.

  2. njsmith commented on Feb 5, 2019

    @njsmith
    ContributorAuthor

    Yeah, also the first alpha just came out and I think this change made it in? So you might get other folks testing it soon-ish.

  3. Carreau commented on Feb 18, 2019

    @Carreau
    Member

    Closed by #11593

  4. added this to the 7.3 milestone on Feb 18, 2019
  5. Carreau commented on May 31, 2019

    @Carreau
    Member

    Hi there, You seem to run IPython on Python 3.8; do you mind trying #11713 that tried to make use of the new 3.8b1 (not out yet) top-level await ?

  6. njsmith commented on May 31, 2019

    @njsmith
    ContributorAuthor

    I just run it in ci, I don't have a local build handy.

  7. added a commit that references this issue on Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions