Pablo Galindo Salgado <[email protected]> added the comment:
> 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
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39686>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com