zopefoundation / RestrictedPython

A restricted execution environment for Python to run untrusted code.
http://restrictedpython.readthedocs.io/
Other
456 stars 38 forks source link

Fix ast deprecations for 3.12 #257

Closed cdce8p closed 1 year ago

cdce8p commented 1 year ago

ast.Str and ast.Num have been deprecated since Python 3.8. Starting with 3.12, they will now emit DeprecationWarnings. Replace them with calls to ast.Constant for Python 3.8+.

An alternative would be to drop support for Python 3.7.

DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead

https://docs.python.org/3.12/library/ast.html#ast.AST

cdce8p commented 1 year ago

The lint errors where a result of the recent pycodestyle==2.11.0 release.

For coverage, I chose to ignore all Python 3.7 branches. The report is generated with Python 3.8 currently, so those will never match. An alternative would be to rewrite the CI config to generate partial coverage results for each Python version and combine them in a later step. Not sure that's worth it though. Could also still be done at a later point.

dataflake commented 1 year ago

In order to accept your contribution please sign our contributor agreement: https://zope.dev/developer/becoming-a-committer.html

cdce8p commented 1 year ago

In order to accept your contribution please sign our contributor agreement: https://zope.dev/developer/becoming-a-committer.html

I'm sorry I won't sign it just for a simple PR like this one. The PR doesn't do anything unique that would be protected anyway. Feel free to use it or don't, your call. For what it's worth, consider any changes in this PR to be public domain or CC0-1.0-Universal licensed.

dataflake commented 1 year ago

Superceded by #259