This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pablogsal
Recipients BTaskaya, benjamin.peterson, pablogsal, sparverius
Date 2020-02-19.18:15:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582136131.74.0.0244035045054.issue39686@roundup.psfhosted.org>
In-reply-to
Content
> There seems to be movement towards a general usage. For instance, take a look at clang, in particular the flag '-ast-dump=json'.

I don't think the clang argument holds because clang is a command-line tool after all and it makes sense that it can produce several outputs while the ast module is exposes APIs that you can further process inside the language. Having json from the clang output will require more than one tool if clang does not support it while doing it in Python only requires Python.

> it appears that they do so in non-standard ways.

Can you clarify what do you mean with that? 

> The implementation of ast.dump also uses recursion. I have tested ast.dump_json on sufficiently large source files and have not run into recursion depth exceeded issues.

This is not the primary argumet as by itself is weaker because this is an edge case but for instance, here is an example of ast.dump succeeding and your tool failing:


>>> x = ast.List()
>>> for _ in range(1010):
    ...:     x = ast.List(x)
    ...:

>>> ast.dump(x)
'List(elts=List(elts=List(elts=List(elts=List(elts=L......

>>> dump_json(x)
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-22-fadef4fb6a0d> in <module>
RecursionError: maximum recursion depth exceeded while calling a Python object
History
Date User Action Args
2020-02-19 18:15:31pablogsalsetrecipients: + pablogsal, benjamin.peterson, BTaskaya, sparverius
2020-02-19 18:15:31pablogsalsetmessageid: <1582136131.74.0.0244035045054.issue39686@roundup.psfhosted.org>
2020-02-19 18:15:31pablogsallinkissue39686 messages
2020-02-19 18:15:31pablogsalcreate