Skip to content

ast.literal_eval is still referred to as safe by the documentation for eval #100305

Activity

  1. ramvikrams commented on Dec 17, 2022

    @ramvikrams
    Contributor

    Could you please elabourate about it, I would like to work on this but I can't get what the issue is trying to say.

  2. pochmann commented on Dec 17, 2022

    @pochmann
    Contributor

    @ramvikrams Have you read literal_eval's documentation?

  3. ramvikrams commented on Dec 17, 2022

    @ramvikrams
    Contributor

    @ramvikrams Have you read literal_eval's documentation?

    yes, I read it now earlier I read ast.literal_eval from a different source I saw there was a warning there I'll put the warning in the eval documentation

  4. Zephyrkul commented on Dec 17, 2022

    @Zephyrkul
    Author

    Could you please elabourate about it, I would like to work on this but I can't get what the issue is trying to say.

    From the docs for literal_eval:

    This function had been documented as “safe” in the past without defining what that meant. That was misleading.... [It] is not free from attack.

    Python 3.11 changed the documentation to no longer refer to the function as "safe" due to the misleading vagueness of the term (see #95588), but this entry under eval() seems to have been missed.

  5. ramvikrams commented on Dec 17, 2022

    @ramvikrams
    Contributor

    Could you please elabourate about it, I would like to work on this but I can't get what the issue is trying to say.

    From the docs for literal_eval:

    This function had been documented as “safe” in the past without defining what that meant. That was misleading.... [It] is not free from attack.

    Python 3.11 changed the documentation to no longer refer to the function as "safe" due to the misleading vagueness of the term (see #95588), but this entry under eval() seems to have been missed.

    thanks i'll change it

  6. pochmann commented on Dec 18, 2022

    @pochmann
    Contributor

    Your proposed replacement text looks weirdly out of place and negative to me:

    ast.literal_eval is no longer marked as safe for evaluating strings with expressions containing only literals. For further information, please check the documentation for ast.literal_eval

    I'd wonder why it's suddenly talking about some other function as if the reader knew about it already, as if it had been pointed out before.

    I'd just weaken the "safely", like (adding "more")

    See ast.literal_eval() for a function that can more safely evaluate strings with expressions containing only literals.

    or (adding quote characters):

    See ast.literal_eval() for a function that can "safely" evaluate strings with expressions containing only literals.

    These keep introducing it properly and keep the positive tone.

    And in my opinion there's no need for the extra sentence telling the reader to read the documentation for details, that's what one does anyway.

  7. ramvikrams commented on Dec 18, 2022

    @ramvikrams
    Contributor

    Yeah I'll do that

  8. added a commit that references this issue on Apr 12, 2026
  9. added 2 commits that reference this issue on Apr 12, 2026
  10. added 2 commits that reference this issue on Apr 15, 2026
  11. PlaceReporter99 commented on Apr 18, 2026

    @PlaceReporter99

    Your proposed replacement text looks weirdly out of place and negative to me:

    ast.literal_eval is no longer marked as safe for evaluating strings with expressions containing only literals. For further information, please check the documentation for ast.literal_eval

    I'd wonder why it's suddenly talking about some other function as if the reader knew about it already, as if it had been pointed out before.

    I'd just weaken the "safely", like (adding "more")

    See ast.literal_eval() for a function that can more safely evaluate strings with expressions containing only literals.

    or (adding quote characters):

    See ast.literal_eval() for a function that can "safely" evaluate strings with expressions containing only literals.

    These keep introducing it properly and keep the positive tone.

    And in my opinion there's no need for the extra sentence telling the reader to read the documentation for details, that's what one does anyway.

    Putting stuff in quotes does’t quite say “positive tone” to me…

  12. added a commit that references this issue on Apr 25, 2026
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

    docsDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions