question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

implement ast module, or a least its `literal_eval`

See original GitHub issue

Hello,

while trying to import jinja2 for testing purpose, the import of literal_eval from ast module from stdlib failed. literal_eval is a safe eval which can be used with untrusted source (see https://docs.python.org/3/library/ast.html#ast.literal_eval) and could be useful in the web context. Would it be possible to implement ast module, or at least its literal_eval method?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
gilchcommented, Dec 21, 2020

I hacked together a (mostly) working literal_eval from pycopy-ast and CPython 3.6.

https://gist.github.com/gilch/efdd9a1f600cef976be921bb3c5ed421

1reaction
moepnsecommented, Oct 29, 2020

I am currently working on porting the AST module of the pycopy-lib and RestrictedPython to Brython.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ast — Abstract Syntax Trees — Python 3.11.1 documentation
The ast module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each...
Read more >
Assistance with Python's ast.literal_eval('a_string')
1 Answer 1 · you cannot use ast.literal_eval because logging.Debug is not a litteral: you ask a value from a module, and that...
Read more >
What is ast.literal_eval(node_or_string) in Python?
The ast module (Abstract Syntax Tree) allows us to interact with and modify Python code. ... It may consist of the following Python...
Read more >
Rephrase ast.literal_eval() to remove any security warranty
Currently, ast.literal_eval() documentation gives multiple security warranties: Safely evaluate This can be used for safely evaluating ...
Read more >
ValueError malformed string when using ast literal eval
It is widely known that using eval() is a potential security risk so the use of ast.literal_eval( ... 2.7 without using the risky...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found