Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-asteval for openSUSE:Factory
checked in at 2026-11-24 14:41:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-asteval (Old)
and /work/SRC/openSUSE:Factory/.python-asteval.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-asteval"
Tue Nov 24 14:41:14 2026 rev:25 rq:1400267 version:1.0.10
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-asteval/python-asteval.changes
2026-08-01 18:37:18.944324850 +0200
+++
/work/SRC/openSUSE:Factory/.python-asteval.new.1340718/python-asteval.changes
2026-11-24 14:41:18.099833084 +0100
@@ -1,0 +2,15 @@
+Mon Nov 9 14:39:37 UTC 2026 - Danilo Spinella <[email protected]>
+
+- Update to 1.0.10
+ * Fix comprehension loop variables leaking into the symbol
+ table(#156, Fixes: from exgcdwu)
+ * Reject assignment to unsafe attribute, including all "dunder"
+ attributes
+ * Update security advisory guidelines in SECURITY.md
+ * Fix typo raising exception where node is not defined
+ * Use ndarray.reshape instead of assigning to ndarray.shape to
+ avoid NumPy deprecation.
+ * Add some testing of implemented/non-implemented nodes
+ * Update docs to use breeze theme
+
+-------------------------------------------------------------------
Old:
----
asteval-1.0.9.tar.gz
New:
----
asteval-1.0.10.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-asteval.spec ++++++
--- /var/tmp/diff_new_pack.3QdYFx/_old 2026-11-24 14:41:18.977870415 +0100
+++ /var/tmp/diff_new_pack.3QdYFx/_new 2026-11-24 14:41:18.979870500 +0100
@@ -18,7 +18,7 @@
%{?sle15_python_module_pythons}
Name: python-asteval
-Version: 1.0.9
+Version: 1.0.10
Release: 0
Summary: Safe, minimalistic evaluator of python expression using ast
module
License: MIT
++++++ asteval-1.0.9.tar.gz -> asteval-1.0.10.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/.github/workflows/codeql.yml
new/asteval-1.0.10/.github/workflows/codeql.yml
--- old/asteval-1.0.9/.github/workflows/codeql.yml 1970-01-01
01:00:00.000000000 +0100
+++ new/asteval-1.0.10/.github/workflows/codeql.yml 2026-08-21
23:03:14.966562500 +0200
@@ -0,0 +1,101 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL Advanced"
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+ schedule:
+ - cron: '24 1 * * 3'
+
+jobs:
+ analyze:
+ name: Analyze (${{ matrix.language }})
+ # Runner size impacts CodeQL analysis time. To learn more, please see:
+ # - https://gh.io/recommended-hardware-resources-for-running-codeql
+ # - https://gh.io/supported-runners-and-hardware-resources
+ # - https://gh.io/using-larger-runners (GitHub.com only)
+ # Consider using larger runners or machines with greater resources for
possible analysis time improvements.
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') ||
'ubuntu-latest' }}
+ permissions:
+ # required for all workflows
+ security-events: write
+
+ # required to fetch internal or private CodeQL packs
+ packages: read
+
+ # only required for workflows in private repositories
+ actions: read
+ contents: read
+
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - language: actions
+ build-mode: none
+ - language: python
+ build-mode: none
+ # CodeQL supports the following values keywords for 'language':
'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript',
'python', 'ruby', 'rust', 'swift'
+ # Use `c-cpp` to analyze code written in C, C++ or both
+ # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
+ # Use 'javascript-typescript' to analyze code written in JavaScript,
TypeScript or both
+ # To learn more about changing the languages that are analyzed or
customizing the build mode for your analysis,
+ # see
https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
+ # If you are analyzing a compiled language, you can modify the
'build-mode' for that language to customize how
+ # your codebase is analyzed, see
https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ # Add any setup steps before running the `github/codeql-action/init`
action.
+ # This includes steps like installing compilers or runtimes
(`actions/setup-node`
+ # or others). This is typically only required for manual builds.
+ # - name: Setup runtime (example)
+ # uses: actions/setup-example@v1
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v4
+ with:
+ languages: ${{ matrix.language }}
+ build-mode: ${{ matrix.build-mode }}
+ # If you wish to specify custom queries, you can do so here or in a
config file.
+ # By default, queries listed here will override any specified in a
config file.
+ # Prefix the list here with "+" to use these queries and those in the
config file.
+
+ # For more details on CodeQL's query packs, refer to:
https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+ # If the analyze step fails for one of the languages you are analyzing with
+ # "We were unable to automatically build your code", modify the matrix
above
+ # to set the build mode to "manual" for that language. Then modify this
step
+ # to build your code.
+ # âšī¸ Command-line programs to run using the OS shell.
+ # đ See
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+ - name: Run manual build steps
+ if: matrix.build-mode == 'manual'
+ shell: bash
+ run: |
+ echo 'If you are using a "manual" build mode for one or more of the' \
+ 'languages you are analyzing, replace this with the commands to
build' \
+ 'your code, for example:'
+ echo ' make bootstrap'
+ echo ' make release'
+ exit 1
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v4
+ with:
+ category: "/language:${{matrix.language}}"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/LICENSE new/asteval-1.0.10/LICENSE
--- old/asteval-1.0.9/LICENSE 2025-12-17 21:57:18.000000000 +0100
+++ new/asteval-1.0.10/LICENSE 2026-08-21 23:03:14.968952200 +0200
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2025 Matthew Newville, The University of Chicago
+Copyright (c) 2026 Matthew Newville, The University of Chicago
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/PKG-INFO new/asteval-1.0.10/PKG-INFO
--- old/asteval-1.0.9/PKG-INFO 2026-06-11 20:39:49.612932400 +0200
+++ new/asteval-1.0.10/PKG-INFO 2026-08-21 23:06:18.425045700 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: asteval
-Version: 1.0.9
+Version: 1.0.10
Summary: Safe, minimalistic evaluator of python expression using ast module
Author-email: Matthew Newville <[email protected]>
License-Expression: MIT
@@ -25,6 +25,7 @@
Requires-Dist: twine; extra == "dev"
Provides-Extra: doc
Requires-Dist: Sphinx; extra == "doc"
+Requires-Dist: sphinx-breeze-theme; extra == "doc"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/SECURITY.md
new/asteval-1.0.10/SECURITY.md
--- old/asteval-1.0.9/SECURITY.md 1970-01-01 01:00:00.000000000 +0100
+++ new/asteval-1.0.10/SECURITY.md 2026-08-21 23:03:14.969931400 +0200
@@ -0,0 +1,44 @@
+# Security Policy
+
+## Supported Versions
+
+Use this section to tell people about which versions of your project are
+currently being supported with security updates.
+
+| Version | Supported |
+| ------- | ------------------ |
+| 1.0.9 | :white_check_mark: |
+
+
+## Reporting a Vulnerability
+
+Thanks for looking into the possible vulnerabilities of Asteval. As we
clearly state in the documentation,
+we are aiming to removing known vulnerabilities that can crash the Python
program running Asteval or allow
+access to system files that the program the Asteval Interpreter cannot access.
+
+Sadly, we have experienced a several advisories that required substantial
editing. We assume that most of
+these submission are well-intentioned, but they do demand attention from the
developers. We feel compelled
+to give guidance on these to consider when creating a security advisory for
Asteval.
+
+Please be aware of the following:
+
+1. Asteval does not ever run on a network. It can not run over a network. It
always is run by a Python process on
+ a local machine that provides an asteval.Interpreter() to a user. An
instance of Asteval that is exposed from
+ a web service would NOT qualify, as asteval is running in a Python process
on the local machine. That Python
+ process may give access to the filesystem to the user account running the
web service. These are both choices
+ for how to run Asteval. If you say the Attack Vector is "Network", you will
need to explain that fully.
+2. Similarly, the Asteval user is enabled by the Python process providing the
Interpreter to use this software.
+ If you say the Privilege Required is "None", you will need to explain that
fully. Similarly, if you say that User
+ Interaction is "None" you will need to explain how a user can do anything
with a Python library that does not
+ require User Interaction. You should apply similar care when selecting the
Scope, Confidentiality, Integrity, and
+ Availability.
+4. If your report describes using NumPy from within Asteval, clearly explain
why this is not already covered in the
+ documentation and why, "Well, then don't expose NumPy to your Asteval
users" is insufficient.
+
+Note that advisories about NumPy functions being able to write to the local
disk are simply not issues that we intend
+to solve. Such advisories will be closed. If having NumPy functions able to
write to the local disk are a problem,
+then the user should not include NumPy in an Asteval Interpreter.
+
+If you believe that some aspect of Asteval's use of NumPy should be changed,
then submit an Issue and/or a Pull Request.
+Issues involving NumPy are extremely unlikely to be treated as security
problems.
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval/asteval.py
new/asteval-1.0.10/asteval/asteval.py
--- old/asteval-1.0.9/asteval/asteval.py 2026-06-11 19:44:51.000000000
+0200
+++ new/asteval-1.0.10/asteval/asteval.py 2026-08-21 23:03:14.970912700
+0200
@@ -46,7 +46,7 @@
from .astutils import (HAS_NUMPY, ExceptionHolder, ReturnedNone,
Empty, make_symbol_table, op2func,
- safe_getattr, safe_format, valid_symbol_name,
+ safe_getattr, safe_setattr, safe_format,
valid_symbol_name,
Procedure)
ALL_NODES = ['arg', 'assert', 'assign', 'attribute', 'augassign',
@@ -280,7 +280,7 @@
except Exception:
self.raise_exception(None, exc=RuntimeError, expr=text)
except (KeyboardInterrupt, SystemExit, GeneratorExit) as exc:
- self.raise_exception(node, exc=RuntimeError, msg=f"{NORAISE}
{exc.__name__}")
+ self.raise_exception(None, exc=RuntimeError, msg=f"{NORAISE}
{exc.__name__}")
out = ast.fix_missing_locations(out)
return out
@@ -361,7 +361,7 @@
raise lerr.exc(errmsg)
if show_errors:
print(errmsg, file=self.err_writer)
- return None
+ return
except (KeyboardInterrupt, SystemExit, GeneratorExit) as exc:
self.raise_exception(node, exc=RuntimeError, msg=f"{NORAISE}
{exc.__name__}")
@@ -428,7 +428,7 @@
except Exception:
self.raise_exception(None, exc=ImportError, msg='Import Error')
except (KeyboardInterrupt, SystemExit, GeneratorExit) as exc:
- self.raise_exception(node, exc=RuntimeError, msg=f"{NORAISE}
{exc.__name__}")
+ self.raise_exception(None, exc=RuntimeError, msg=f"{NORAISE}
{exc.__name__}")
if fromlist is None:
@@ -480,7 +480,7 @@
def on_pass(self, node):
"""Pass statement."""
- return None # ()
+ return
# for break and continue: set the instance variable _interrupt
def on_interrupt(self, node): # ()
@@ -575,7 +575,8 @@
msg = f"cannot assign to attribute {node.attr}"
self.raise_exception(node, exc=AttributeError, msg=msg)
- setattr(self.run(node.value), node.attr, val)
+ safe_setattr(self.run(node.value), node.attr, val,
+ self.raise_exception, node)
elif node.__class__ == ast.Subscript:
self.run(node.value)[self.run(node.slice)] = val
@@ -817,6 +818,7 @@
def _comp_save_syms(self, node):
"""find and save symbols that will be used in a comprehension"""
saved_syms = {}
+ delete_syms = set()
for tnode in node.generators:
# Extract all names from the target (handles nested tuples)
names = self._extract_names_from_target(tnode.target)
@@ -826,7 +828,9 @@
self.raise_exception(tnode.target, exc=NameError,
msg=errmsg)
if name in self.symtable:
saved_syms[name] = copy.deepcopy(self.symtable.get(name))
- return saved_syms
+ else:
+ delete_syms.add(name)
+ return saved_syms, delete_syms
def do_generator(self, gnodes, node, out):
@@ -860,12 +864,14 @@
def on_listcomp(self, node):
"""List comprehension v2"""
- saved_syms = self._comp_save_syms(node)
+ saved_syms, delete_syms = self._comp_save_syms(node)
out = []
self.do_generator(node.generators, node, out)
for name, val in saved_syms.items():
self.symtable[name] = val
+ for name in delete_syms:
+ self.symtable.pop(name, None)
return out
def on_setcomp(self, node):
@@ -874,12 +880,14 @@
def on_dictcomp(self, node):
"""Dict comprehension v2"""
- saved_syms = self._comp_save_syms(node)
+ saved_syms, delete_syms = self._comp_save_syms(node)
out = {}
self.do_generator(node.generators, node, out)
for name, val in saved_syms.items():
self.symtable[name] = val
+ for name in delete_syms:
+ self.symtable.pop(name, None)
return out
def on_excepthandler(self, node): # ('type', 'name', 'body')
@@ -935,7 +943,7 @@
def on_call(self, node):
"""Function execution."""
func = self.run(node.func)
- if not hasattr(func, '__call__') and not isinstance(func, type):
+ if not callable(func) and not isinstance(func, type):
msg = f"'{func}' is not callable!!"
self.raise_exception(node, exc=TypeError, msg=msg)
args = [self.run(targ) for targ in node.args]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval/astutils.py
new/asteval-1.0.10/asteval/astutils.py
--- old/asteval-1.0.9/asteval/astutils.py 2026-06-11 19:44:51.000000000
+0200
+++ new/asteval-1.0.10/asteval/astutils.py 2026-08-21 23:03:14.971487300
+0200
@@ -279,7 +279,7 @@
ast.UAdd: lambda a: +a,
ast.USub: lambda a: -a}
-# Safe version of getattr
+# Safe versions of getattr and setattr
def safe_getattr(obj, attr, raise_exc, node, allow_unsafe_modules=False):
"""safe version of getattr"""
@@ -301,6 +301,13 @@
else:
return getattr(obj, attr, None)
+def safe_setattr(obj, attr, val, raise_exc, node):
+ """safe version of setattr"""
+ if attr in UNSAFE_ATTRS or (attr.startswith('__') and attr.endswith('__')):
+ msg = f"cannot assign to unsafe attribute {attr}"
+ raise_exc(node, exc=AttributeError, msg=msg)
+ setattr(obj, attr, val)
+
class SafeFormatter(Formatter):
def __init__(self, raise_exc, node):
self.raise_exc = raise_exc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval/version.py
new/asteval-1.0.10/asteval/version.py
--- old/asteval-1.0.9/asteval/version.py 2026-06-11 20:39:49.000000000
+0200
+++ new/asteval-1.0.10/asteval/version.py 2026-08-21 23:06:18.285116200
+0200
@@ -18,7 +18,7 @@
commit_id: str | None
__commit_id__: str | None
-__version__ = version = '1.0.9'
-__version_tuple__ = version_tuple = (1, 0, 9)
+__version__ = version = '1.0.10'
+__version_tuple__ = version_tuple = (1, 0, 10)
-__commit_id__ = commit_id = 'g0b359d0b0'
+__commit_id__ = commit_id = 'ge0f794543'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval.egg-info/PKG-INFO
new/asteval-1.0.10/asteval.egg-info/PKG-INFO
--- old/asteval-1.0.9/asteval.egg-info/PKG-INFO 2026-06-11 20:39:49.000000000
+0200
+++ new/asteval-1.0.10/asteval.egg-info/PKG-INFO 2026-08-21
23:06:18.362537400 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: asteval
-Version: 1.0.9
+Version: 1.0.10
Summary: Safe, minimalistic evaluator of python expression using ast module
Author-email: Matthew Newville <[email protected]>
License-Expression: MIT
@@ -25,6 +25,7 @@
Requires-Dist: twine; extra == "dev"
Provides-Extra: doc
Requires-Dist: Sphinx; extra == "doc"
+Requires-Dist: sphinx-breeze-theme; extra == "doc"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval.egg-info/SOURCES.txt
new/asteval-1.0.10/asteval.egg-info/SOURCES.txt
--- old/asteval-1.0.9/asteval.egg-info/SOURCES.txt 2026-06-11
20:39:49.000000000 +0200
+++ new/asteval-1.0.10/asteval.egg-info/SOURCES.txt 2026-08-21
23:06:18.413065000 +0200
@@ -2,9 +2,11 @@
.gitignore
LICENSE
README.rst
+SECURITY.md
pyproject.toml
setup.py
.github/dependabot.yml
+.github/workflows/codeql.yml
.github/workflows/macos_numpy.yml
.github/workflows/ubuntu_nonumpy.yml
.github/workflows/ubuntu_numpy.yml
@@ -17,6 +19,8 @@
asteval.egg-info/SOURCES.txt
asteval.egg-info/dependency_links.txt
asteval.egg-info/requires.txt
+asteval.egg-info/scm_file_list.json
+asteval.egg-info/scm_version.json
asteval.egg-info/top_level.txt
doc/Makefile
doc/api.rst
@@ -25,6 +29,7 @@
doc/index.rst
doc/installation.rst
doc/motivation.rst
+doc/safety.rst
doc/_static/empty
doc/_templates/indexsidebar.html
tests/test_asteval.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval.egg-info/requires.txt
new/asteval-1.0.10/asteval.egg-info/requires.txt
--- old/asteval-1.0.9/asteval.egg-info/requires.txt 2026-06-11
20:39:49.000000000 +0200
+++ new/asteval-1.0.10/asteval.egg-info/requires.txt 2026-08-21
23:06:18.363357000 +0200
@@ -8,6 +8,7 @@
[doc]
Sphinx
+sphinx-breeze-theme
[test]
pytest
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval.egg-info/scm_file_list.json
new/asteval-1.0.10/asteval.egg-info/scm_file_list.json
--- old/asteval-1.0.9/asteval.egg-info/scm_file_list.json 1970-01-01
01:00:00.000000000 +0100
+++ new/asteval-1.0.10/asteval.egg-info/scm_file_list.json 2026-08-21
23:06:18.359868800 +0200
@@ -0,0 +1,31 @@
+{
+ "files": [
+ ".codecov.yml",
+ ".github/dependabot.yml",
+ ".github/workflows/codeql.yml",
+ ".github/workflows/macos_numpy.yml",
+ ".github/workflows/ubuntu_nonumpy.yml",
+ ".github/workflows/ubuntu_numpy.yml",
+ ".github/workflows/windows_numpy.yml",
+ ".gitignore",
+ "LICENSE",
+ "README.rst",
+ "SECURITY.md",
+ "asteval/__init__.py",
+ "asteval/asteval.py",
+ "asteval/astutils.py",
+ "doc/Makefile",
+ "doc/_static/empty",
+ "doc/_templates/indexsidebar.html",
+ "doc/api.rst",
+ "doc/basics.rst",
+ "doc/conf.py",
+ "doc/index.rst",
+ "doc/installation.rst",
+ "doc/motivation.rst",
+ "doc/safety.rst",
+ "pyproject.toml",
+ "setup.py",
+ "tests/test_asteval.py"
+ ]
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/asteval.egg-info/scm_version.json
new/asteval-1.0.10/asteval.egg-info/scm_version.json
--- old/asteval-1.0.9/asteval.egg-info/scm_version.json 1970-01-01
01:00:00.000000000 +0100
+++ new/asteval-1.0.10/asteval.egg-info/scm_version.json 2026-08-21
23:06:18.310135100 +0200
@@ -0,0 +1,8 @@
+{
+ "tag": "1.0.10",
+ "distance": 0,
+ "node": "ge0f79454330851ae03ab5d1a38b246049da2c1c0",
+ "dirty": false,
+ "branch": "master",
+ "node_date": "2026-08-21"
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/Makefile
new/asteval-1.0.10/doc/Makefile
--- old/asteval-1.0.9/doc/Makefile 2025-12-17 21:57:18.000000000 +0100
+++ new/asteval-1.0.10/doc/Makefile 2026-08-21 23:03:14.972269300 +0200
@@ -11,6 +11,10 @@
.PHONY: html pdf all help clean dirhtml latex
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
all: html pdf
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
@@ -20,10 +24,6 @@
-cd $(BUILDDIR) && ln -s html asteval_doc && zip -pur asteval_doc.zip
asteval_doc/* && mv asteval_doc.zip html && rm -f asteval_doc
@echo "Build finished. The HTML pages are in _build/html."
-html:
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
tarball: all
cd $(BUILDDIR)/html && tar cvzf ../../../_doc.tgz *
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/_templates/indexsidebar.html
new/asteval-1.0.10/doc/_templates/indexsidebar.html
--- old/asteval-1.0.9/doc/_templates/indexsidebar.html 2025-12-17
21:57:18.000000000 +0100
+++ new/asteval-1.0.10/doc/_templates/indexsidebar.html 2026-08-21
23:03:14.972905600 +0200
@@ -1,10 +1,11 @@
<h3>Contents</h3>
<ul>
- <li> <a href="{{ pathto('installation') }}"> Installing
Asteval</a></li>
- <li> <a href="{{ pathto('basics') }}"> Using
Asteval</a></li>
- <li> <a href="{{ pathto('api') }}"> Astevel
Reference</a></li>
- <li> <a href="{{ pathto('motivation') }}"> Motivation for
Asteval</a></li>
+ <li> <a href="{{ pathto('installation') }}">
Installionn</a></li>
+ <li> <a href="{{ pathto('basics') }}"> Usage</a></li>
+ <li> <a href="{{ pathto('api') }}"> Reference</a></li>
+ <li> <a href="{{ pathto('motivation') }}"> Motivation</a></li>
+ <li> <a href="{{ pathto('safety') }}"> How Safe is
Asteval?</a></li>
</ul>
<h3>Get Asteval</h3>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/api.rst
new/asteval-1.0.10/doc/api.rst
--- old/asteval-1.0.9/doc/api.rst 2026-06-09 04:09:12.000000000 +0200
+++ new/asteval-1.0.10/doc/api.rst 2026-08-21 23:03:14.973284000 +0200
@@ -1,7 +1,7 @@
.. _asteval_api:
========================
-Asteval Reference
+Reference
========================
.. _numpy: https://numpy.org
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/basics.rst
new/asteval-1.0.10/doc/basics.rst
--- old/asteval-1.0.9/doc/basics.rst 2026-06-11 19:44:57.000000000 +0200
+++ new/asteval-1.0.10/doc/basics.rst 2026-08-21 23:03:14.973702400 +0200
@@ -1,5 +1,5 @@
================
-Using Asteval
+User Guide
================
This chapter gives a quick overview of asteval, showing basic usage and the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/conf.py
new/asteval-1.0.10/doc/conf.py
--- old/asteval-1.0.9/doc/conf.py 2025-12-17 21:57:18.000000000 +0100
+++ new/asteval-1.0.10/doc/conf.py 2026-08-21 23:03:14.974161900 +0200
@@ -26,7 +26,10 @@
'sphinx.ext.napoleon',
'sphinx.ext.todo',
'sphinx.ext.coverage',
- 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
+ 'sphinx_copybutton',
+ 'sphinx.ext.mathjax',
+ 'sphinx.ext.intersphinx',
+ ]
intersphinx_mapping = {'py': ('https://docs.python.org/3/', None)}
@@ -34,7 +37,7 @@
templates_path = ['_templates']
# The suffix of source filenames.
-source_suffix = '.rst'
+source_suffix = {'.rst': 'restructuredtext'}
# The encoding of source files.
#source_encoding = 'utf-8'
@@ -97,10 +100,17 @@
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'bizstyle'
+html_theme = 'breeze'
-# html_theme = 'nature'
-# html_theme = 'agogo'
+html_theme_options = { "external_links": [
+ { "name": "PDF", "icon": "download", "url":
"https://lmfit.github.io/asteval/asteval.pdf"},
+ "https://github.com/lmfit/asteval",
+]
+
+ }
+
+
+# html_theme = 'bizstyle'
# html_theme_options = {'pagewidth':'85em', 'documentwidth':'60em',
'sidebarwidth': '25em',
# # 'headercolor1': '#000080',
# # 'headercolor2': '#0000A0',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/index.rst
new/asteval-1.0.10/doc/index.rst
--- old/asteval-1.0.9/doc/index.rst 2026-06-09 04:09:12.000000000 +0200
+++ new/asteval-1.0.10/doc/index.rst 2026-08-21 23:03:14.974459600 +0200
@@ -6,6 +6,7 @@
.. _numpy: https://numpy.org/
.. _numpy_financial: https://numpy.org/numpy-financial/
+
The asteval package evaluates Python expressions and statements, providing a
safer alternative to Python's builtin :py:func:`eval` and a richer, easier to
use alternative to :py:func:`ast.literal_eval`. It does this by building an
@@ -71,3 +72,4 @@
basics
api
motivation
+ safety
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/installation.rst
new/asteval-1.0.10/doc/installation.rst
--- old/asteval-1.0.9/doc/installation.rst 2025-12-17 21:57:18.000000000
+0100
+++ new/asteval-1.0.10/doc/installation.rst 2026-08-21 23:03:14.974747400
+0200
@@ -1,5 +1,5 @@
====================================
-Installing Asteval
+Installation
====================================
.. _numpy: https://numpy.org/
@@ -7,11 +7,8 @@
.. _github: https://github.com/lmfit/asteval
.. _PyPI: https://pypi.org/project/asteval/
-Requirements
-~~~~~~~~~~~~~~~
-
-Asteval is a pure Python module. The latest stable version is |release|, which
-supports Python 3.9 through 3.13.
+Asteval is a pure Python library. The latest version is |release|,
+supporting Python 3.10 through 3.14.
Installing `asteval` requires `setuptools` and `setuptools_scm`. No other
libraries outside of the standard library are required. If `numpy`_ and
@@ -20,11 +17,10 @@
modules, deployment uses `build` and `twine`, and building the documentation
requires `sphinx`.
-Python 3.9 through 3.13 are tested on Windows, MacOS, and Linux, with
+Python 3.10 through 3.14 are tested on Windows, MacOS, and Linux, with
and without `numpy`_ installed. Older Python versions have generally
been supported by `asteval` until they are well past the end of
-security fixes. While `asteval` may continue to work with Python 3.8
-or even 3.7, these are not supported.
+security fixes.
Support for new versions of the Python 3 series is not guaranteed until some
@@ -34,6 +30,13 @@
features.
++--------------+----------------------------------+
+| Source code | https://github.com/lmfit/asteval |
++--------------+----------------------------------+
+| PyPI | https://pypi.org/project/asteval |
++--------------+----------------------------------+
+
+
Installing with `pip`
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -43,10 +46,11 @@
pip install asteval
-It may also be available on some conda channels, including `conda-forge`,
-but as it is a pure Python package with no dependencies or OS-specific
-extensions, using `pip` should be the preferred method on all platforms and
-environments.
+`asteval` may also be available on some conda channels, including
+`conda-forge`, or in other packaging systems. Since `asteval` is a
+pure Python package with truly minimal dependencies (`setuptools`) or
+OS-specific extensions, using `pip` should be the preferred method on
+all platforms and environments.
Development Version
~~~~~~~~~~~~~~~~~~~~~~~~
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/motivation.rst
new/asteval-1.0.10/doc/motivation.rst
--- old/asteval-1.0.9/doc/motivation.rst 2026-06-11 19:44:57.000000000
+0200
+++ new/asteval-1.0.10/doc/motivation.rst 2026-08-21 23:03:14.975026000
+0200
@@ -2,7 +2,7 @@
.. _xraylarch: https://github.com/xraypy/xraylarch
====================================
-Motivation for Asteval
+Motivation
====================================
The asteval module allows you to evaluate a large subset of the Python language
@@ -48,205 +48,3 @@
than Python. That said, for certain use cases (see
https://stackoverflow.com/questions/34106484), use of asteval and numpy can
approach the speed of `eval` and the `numexpr` modules.
-
-How Safe is asteval?
-=======================
-
-Asteval avoids all of the exploits we know about that make
-:py:func:`eval` dangerous. For reference, see, `Eval is really
-dangerous
-<https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html>`_
-and the comments and links therein. From this discussion it is
-apparent that not only is :py:func:`eval` unsafe, but that it is a
-difficult prospect to make any program that takes user input perfectly
-safe. In particular, if a user can cause Python to crash with a
-segmentation fault, safety cannot be guaranteed. Asteval explicitly
-forbids the exploits described in the above link, and works hard to
-prevent malicious code from crashing Python or accessing the
-underlying operating system. That said, we cannot guarantee that
-asteval is completely safe from malicious code. We claim only that it
-is safer than the builtin :py:func:`eval`, and that you might find it
-useful. We also note that several other Python libraries that
-evaluate user-supplied expressions, including `numexpr` and `sympy`
-use the builtin :py:func:`eval` as part of their processing.
-
-Prohibited Python statements and attributes
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Some of the things not allowed in the asteval interpreter for safety reasons
include:
-
- * importing modules. Neither ``import`` nor ``__import__`` are supported by
- default. If you do want to support ``import`` and ``import from``, you
have to
- explicitly enable these.
- * create classes or modules.
- * use ``string.format()``, though f-string formatting and using the ``%``
- operator for string formatting are supported.
- * access to Python's :py:func:`eval`, :py:func:`getattr`, :py:func:`hasattr`,
- :py:func:`setattr`, and :py:func:`delattr`.
- * accessing object attributes that begin and end with ``__``, the so-called
- ``dunder`` attributes. This will include (but is not limited to
- ``__globals__``, ``__code__``, ``__func__``, ``__self__``, ``__module__``,
- ``__dict__``, ``__class__``, ``__call__``, and ``__getattribute__``. None
of
- these can be accessed for any object.
-
-In addition (and following the discussion in the link above), the following
-attributes are blacklisted for all objects, and cannot be accessed:
-
- ``func_globals``, ``func_code``, ``func_closure``, ``im_class``,
- ``im_func``, ``im_self``, ``gi_code``, ``gi_frame``, ``f_locals``,
- ``__mro__``, ``_mro``
-
-[Note: this list may be incomplete - there may be other disallowed
-attributes]. While this approach of making a blacklist cannot be
-guaranteed to be complete, it does eliminate entire classes of attacks
-known to be able to seg-fault the Python interpreter or give access to
-the operating system.
-
-An important caveat is that by default asteval will use ``numpy`` and
-import and expose numpy ``ufuncs`` from the numpy module. Several of
-these can seg-fault Python without much difficulty. In addition,
-several numpy objects, including the basic `ndarray` have methods to
-write data to disk. If you safety from user input causing segmentation
-fault is a primary concern, you may want to consider disabling the use
-of numpy, or take extra care to specify what numpy functions can be
-used.
-
-In 2024, an independent security audit of asteval done by Andrew
-Effenhauser, Ayman Hammad, and Daniel Crowley in the X-Force Security
-Research division of IBM showed insecurities with ``string.format``,
-so that access to this and ``string.format_map`` method were removed.
-In addition, this audit showed that the ``numpy`` submodules
-``linalg``, ``fft``, and ``polynomial`` expose many exploitable
-objects, so these submodules were removed by default. If needed,
-these modules can be added to any Interpreter either using the
-``user_symbols`` argument when creating it, or adding the needed
-symbols to the symbol table after the Interpreter is created.
-
-In 2025, William Khem Marquez demonstrated two vulnerabilities: one
-from leaving some AST objects exposed within the interpreter for
-user-defined functions ("Procedures"), and one with f-string
-formatting. Both of these were fixed for version 1.0.6.
-
-In 2026, for version 1.0.9, the abiilty to raise some kinds exceptions
-(including `SystemExit`, `KeyboardInterrupt`, and a few others) that
-could cause the calling process to exit were either removed from the
-symbol table completely or captured to raise a more benign
-`RuntimeError` instead. In addition, for Numpy ndarrays, the `ctypes`
-attribute and `tofile` and `dump` methods were made inaccessible.
-
-
-Avoiding resource hogging
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-There are other categories of safety that asteval may attempt to
-address, but cannot guarantee success. The most important of these is
-resource hogging, which might be used for a denial-of-service attack.
-There is no guaranteed timeout on any calculation, and so a reasonable
-looking calculation such as::
-
- from asteval import Interpreter
- aeval = Interpreter()
- txt = """
- nmax = 1e8
- a = sqrt(arange(nmax)) # using numpy.sqrt() and numpy.arange()
- """
- aeval.eval(txt)
-
-can take a noticeable amount of CPU time - if it does not, increasing
-that value of ``nmax`` almost certainly will, and can even crash the
-Python shell.
-
-As another illustration of the fundamental challenge, consider the
-Python expression ``a = x**y**z``. With values ``x=y=z=5``, the run
-time will be well under 0.001 seconds. Even with ``x=y=z=8``, run
-time will be under 1 sec. Changing to ``x=8, y=9, z=9``, Python will
-take several seconds (the value is :math:`\sim 10^{350,000,000}`) With
-``x=y=z=9``, executing that statement may take more than 1 hour on
-some machines. The result is that it is not hard to come up with
-short program that would run for hundreds of years, which probably
-exceeds everyones threshold for an acceptable run-time. The point
-here is that there simply is not a good way to predict runtime for any
-code from the text of the code alone: run time cannot be determined
-lexically.
-
-To be clear, for the ``x**y**z`` exponentiation example, asteval will
-raise a runtime error, telling you that an exponent > 10,000 is not
-allowed. Several other attempts are also made to prevent long-running
-operations or memory exhaustion. These checks will prevent the
-following ways to hog resources:
-
- * statements longer than 50,000 bytes.
- * values of exponents (``p`` in ``x**p``) > 10,000.
- * string operations with strings longer than 262144 bytes
- * shift operations with shifts (``p`` in ``x << p``) > 1000.
- * more than 262144 open buffers
- * opening a file with a mode other than ``'r'``, ``'rb'``, or ``'ru'``.
-
-These checks happen at runtime, not by analyzing the text of the code,
-but the values for these operations. Still, as with the example above
-using ``numpy.arange``, very large arrays and lists can be created
-that can approach memory limits. There are countless "clever ways" to
-have very long run times that cannot be readily predicted from the
-text of the code.
-
-
-File access
-~~~~~~~~~~~~~~~~~~~~~~~
-
-By default, the list of supported functions does include Python's
-``open()`` which will allow disk access to the untrusted user. By
-default, Asteval limits ``open()`` to work in read-only mode, and with
-the permissions of the calling program.
-
-When ``numpy`` is supported, its ``load()`` and ``loadtxt()`` functions
-will also normally be supported to read data. But it should be noted
-that ``numpy`` ndarrays do have a ``tofile()`` method that will write to
-disk, limited by the permissions of the calling program.
-
-If writing to disk is a concern, ``numpy`` should be disabled. If
-reading from disk must be forbidden, you will want to overwrite the
-``open()`` function from the symbol table, or re-implement this to
-restrict access. to information on disk that should be kept private.
-
-
-Monitoring Runtime and interrupting processes
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-The exponential example also highlights the issue that there is not a
-good way to check for a long-running calculation within a single
-Python process. That calculation is not stuck within the Python
-interpreter, but in C code (no doubt the ``pow()`` function) called by
-the Python interpreter itself. That call will not return from the C
-library to the Python interpreter or allow other threads to run until
-that call is done. That means that from within a single process,
-there is not a reliable way to tell asteval (or really, even Python)
-when a calculation has taken too long: Denial of Service is hard to
-detect before it happens, and even challenging to detect while it is
-happening. The only reliable way to limit run time is at the level of
-the operating system, with a second process watching the execution
-time of the asteval process and either try to interrupt it or kill it.
-
-For a limited range of problems, you can try to avoid asteval taking too
-long. For example, you may try to limit the *recursion limit* when
-executing expressions, with a code like this::
-
- import contextlib
-
- @contextlib.contextmanager
- def limited_recursion(recursion_limit):
- old_limit = sys.getrecursionlimit()
- sys.setrecursionlimit(recursion_limit)
- try:
- yield
- finally:
- sys.setrecursionlimit(old_limit)
-
- with limited_recursion(100):
- Interpreter().eval(...)
-
-
-In summary, while asteval attempts to be safe and is definitely safer than
-using :py:func:`eval`, there may be ways that using asteval could lead to
-increased risk of malicious use. Recommendations for how to improve this
-situation would be greatly appreciated.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/doc/safety.rst
new/asteval-1.0.10/doc/safety.rst
--- old/asteval-1.0.9/doc/safety.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/asteval-1.0.10/doc/safety.rst 2026-08-21 23:03:14.975552000 +0200
@@ -0,0 +1,217 @@
+.. _lmfit: https://github.com/lmfit/lmfit-py
+.. _xraylarch: https://github.com/xraypy/xraylarch
+
+====================================
+Safety
+====================================
+
+
+Astevel aims at being a safer and safe-ish replacement for Python's
+built-in :py:func:`eval` function. It is perfectly reasonable to ask "how
+safe?". Unfortunately, the answer is complicated.
+
+For reference on the dangers of using :py:func:`eval` see, `Eval is
+really dangerous
+<https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html>`_
+and the comments and links therein. From this discussion it is
+apparent that not only is :py:func:`eval` unsafe, but that it is a
+difficult prospect to make any program that takes user input perfectly
+safe. In particular, if a user can cause Python to crash with a
+segmentation fault, safety cannot be guaranteed.
+
+Asteval avoids all of the exploits listed in that discussion, and all
+other problems that we know about that make :py:func:`eval` dangerous.
+Asteval explicitly forbids the exploits described in the above link,
+and works hard to prevent malicious code from crashing Python or
+accessing the underlying operating system. That said, we cannot
+guarantee that asteval is completely safe from malicious code. We
+claim only that it is safer than the builtin :py:func:`eval`, and that
+you might find it useful. We also note that several other Python
+libraries that evaluate user-supplied expressions, including `numexpr`
+and `sympy` use the builtin :py:func:`eval` as part of their
+processing.
+
+Prohibited Python statements and attributes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some of the things not allowed in the asteval interpreter for safety reasons
include:
+
+ * importing modules. Neither ``import`` nor ``__import__`` are supported by
+ default. If you do want to support ``import`` and ``import from``, you
have to
+ explicitly enable these.
+ * creating classes or modules.
+ * using ``string.format()``. String formatting with f-strings and the ``%``
operator are supported.
+ * accessing Python's :py:func:`eval`, :py:func:`getattr`,
:py:func:`hasattr`, :py:func:`setattr`, and :py:func:`delattr`.
+ * accessing object attributes that begin and end with ``__``, the so-called
+ ``dunder`` attributes. This will include (but is not limited to
+ ``__globals__``, ``__code__``, ``__func__``, ``__self__``, ``__module__``,
+ ``__dict__``, ``__class__``, ``__call__``, and ``__getattribute__``. None
of
+ these can be accessed for any object.
+ * writing to an object's ``dunder`` attributes (new in version 1.0.10).
+
+
+In addition (and following the discussion in the link above), the following
+attributes are blacklisted for all objects, and cannot be accessed:
+
+ ``func_globals``, ``func_code``, ``func_closure``, ``im_class``,
+ ``im_func``, ``im_self``, ``gi_code``, ``gi_frame``, ``f_locals``,
+ ``__mro__``, ``_mro``
+
+[Note: this list may be incomplete - there may be other disallowed
+attributes]. While this approach of making a blacklist cannot be
+guaranteed to be complete, it does eliminate entire classes of attacks
+known to be able to seg-fault the Python interpreter or give access to
+the operating system. Similarly, preventing writing to any ``dunder``
+method can greatly reduce a malicious user changing the internal state
+of Python objects.
+
+An important caveat is that by default asteval will use ``numpy`` and
+import and expose numpy ``ufuncs`` from the numpy module. Several of
+these can seg-fault Python without much difficulty. In addition,
+several numpy objects, including the basic `ndarray` have methods to
+write data to disk. If you safety from user input causing segmentation
+fault is a primary concern, you may want to consider disabling the use
+of numpy, or take extra care to specify what numpy functions can be
+used.
+
+In 2024, an independent security audit of asteval done by Andrew
+Effenhauser, Ayman Hammad, and Daniel Crowley in the X-Force Security
+Research division of IBM showed insecurities with ``string.format``,
+so that access to this and ``string.format_map`` method were removed.
+In addition, this audit showed that the ``numpy`` submodules
+``linalg``, ``fft``, and ``polynomial`` expose many exploitable
+objects, so these submodules were removed by default. If needed,
+these modules can be added to any Interpreter either using the
+``user_symbols`` argument when creating it, or adding the needed
+symbols to the symbol table after the Interpreter is created.
+
+In 2025, William Khem Marquez demonstrated two vulnerabilities: one
+from leaving some AST objects exposed within the interpreter for
+user-defined functions ("Procedures"), and one with f-string
+formatting. Both of these were fixed for version 1.0.6.
+
+In 2026, for version 1.0.9, the abiilty to raise some kinds exceptions
+(including `SystemExit`, `KeyboardInterrupt`, and a few others) that
+could cause the calling process to exit were either removed from the
+symbol table completely or captured to raise a more benign
+`RuntimeError` instead. In addition, for Numpy ndarrays, the `ctypes`
+attribute and `tofile` and `dump` methods were made inaccessible.
+For version 1.0.10, the ability to write to any ``dunder`` attribute
+was removed.
+
+
+Avoiding resource hogging
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+There are other categories of safety that asteval may attempt to
+address, but cannot guarantee success. The most important of these is
+resource hogging, which might be used for a denial-of-service attack.
+There is no guaranteed timeout on any calculation, and so a reasonable
+looking calculation such as::
+
+ from asteval import Interpreter
+ aeval = Interpreter()
+ txt = """
+ nmax = 1e8
+ a = sqrt(arange(nmax)) # using numpy.sqrt() and numpy.arange()
+ """
+ aeval.eval(txt)
+
+can take a noticeable amount of CPU time - if it does not, increasing
+that value of ``nmax`` almost certainly will, and can even crash the
+Python shell.
+
+As another illustration of the fundamental challenge, consider the
+Python expression ``a = x**y**z``. With values ``x=y=z=5``, the run
+time will be well under 0.001 seconds. Even with ``x=y=z=8``, run
+time will be under 1 sec. Changing to ``x=8, y=9, z=9``, Python will
+take several seconds (the value is :math:`\sim 10^{350,000,000}`) With
+``x=y=z=9``, executing that statement may take more than 1 hour on
+some machines. The result is that it is not hard to come up with
+short program that would run for hundreds of years, which probably
+exceeds everyones threshold for an acceptable run-time. The point
+here is that there simply is not a good way to predict runtime for any
+code from the text of the code alone: run time cannot be determined
+lexically.
+
+To be clear, for the ``x**y**z`` exponentiation example, asteval will
+raise a runtime error, telling you that an exponent > 10,000 is not
+allowed. Several other attempts are also made to prevent long-running
+operations or memory exhaustion. These checks will prevent the
+following ways to hog resources:
+
+ * statements longer than 50,000 bytes.
+ * values of exponents (``p`` in ``x**p``) > 10,000.
+ * string operations with strings longer than 262144 bytes
+ * shift operations with shifts (``p`` in ``x << p``) > 1000.
+ * more than 262144 open buffers
+ * opening a file with a mode other than ``'r'``, ``'rb'``, or ``'ru'``.
+
+These checks happen at runtime, not by analyzing the text of the code,
+but the values for these operations. Still, as with the example above
+using ``numpy.arange``, very large arrays and lists can be created
+that can approach memory limits. There are countless "clever ways" to
+have very long run times that cannot be readily predicted from the
+text of the code.
+
+
+File access
+~~~~~~~~~~~~~~~~~~~~~~~
+
+By default, the list of supported functions does include Python's
+``open()`` which will allow disk access to the untrusted user. By
+default, Asteval limits ``open()`` to work in read-only mode, and with
+the permissions of the calling program.
+
+When ``numpy`` is supported, its ``load()`` and ``loadtxt()`` functions
+will also normally be supported to read data. But it should be noted
+that ``numpy`` ndarrays do have a ``tofile()`` method that will write to
+disk, limited by the permissions of the calling program.
+
+If writing to disk is a concern, ``numpy`` should be disabled. If
+reading from disk must be forbidden, you will want to overwrite the
+``open()`` function from the symbol table, or re-implement this to
+restrict access. to information on disk that should be kept private.
+
+
+Monitoring Runtime and interrupting processes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+The exponential example also highlights the issue that there is not a
+good way to check for a long-running calculation within a single
+Python process. That calculation is not stuck within the Python
+interpreter, but in C code (no doubt the ``pow()`` function) called by
+the Python interpreter itself. That call will not return from the C
+library to the Python interpreter or allow other threads to run until
+that call is done. That means that from within a single process,
+there is not a reliable way to tell asteval (or really, even Python)
+when a calculation has taken too long: Denial of Service is hard to
+detect before it happens, and even challenging to detect while it is
+happening. The only reliable way to limit run time is at the level of
+the operating system, with a second process watching the execution
+time of the asteval process and either try to interrupt it or kill it.
+
+For a limited range of problems, you can try to avoid asteval taking too
+long. For example, you may try to limit the *recursion limit* when
+executing expressions, with a code like this::
+
+ import contextlib
+
+ @contextlib.contextmanager
+ def limited_recursion(recursion_limit):
+ old_limit = sys.getrecursionlimit()
+ sys.setrecursionlimit(recursion_limit)
+ try:
+ yield
+ finally:
+ sys.setrecursionlimit(old_limit)
+
+ with limited_recursion(100):
+ Interpreter().eval(...)
+
+
+In summary, while asteval attempts to be safe and is definitely safer than
+using :py:func:`eval`, there may be ways that using asteval could lead to
+increased risk of malicious use. Recommendations for how to improve this
+situation would be greatly appreciated.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/pyproject.toml
new/asteval-1.0.10/pyproject.toml
--- old/asteval-1.0.9/pyproject.toml 2026-06-08 23:26:52.000000000 +0200
+++ new/asteval-1.0.10/pyproject.toml 2026-08-21 23:03:14.975955700 +0200
@@ -46,6 +46,6 @@
[project.optional-dependencies]
dev = ["build", "twine"]
-doc = ["Sphinx"]
+doc = ["Sphinx", "sphinx-breeze-theme"]
test = ["pytest", "pytest-cov", "coverage"]
all = ["asteval[dev, doc, test]"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/asteval-1.0.9/tests/test_asteval.py
new/asteval-1.0.10/tests/test_asteval.py
--- old/asteval-1.0.9/tests/test_asteval.py 2026-06-11 19:44:51.000000000
+0200
+++ new/asteval-1.0.10/tests/test_asteval.py 2026-08-21 23:03:14.976619500
+0200
@@ -12,6 +12,7 @@
from io import StringIO
from sys import version_info
from tempfile import NamedTemporaryFile
+from types import SimpleNamespace
import pytest
@@ -590,6 +591,20 @@
interp('a[1:5] = 1 + 0.5 * arange(4)')
isnear(interp, "a", np.array([0., 1., 1.5, 2., 2.5, 5., 6., 7., 8.,
9.]))
+
[email protected]("nested", [False, True])
[email protected]("attr", ["__private__", "func_globals"])
+def test_unsafe_attribute_assignment(nested, attr):
+ """unsafe attribute assignment"""
+ obj = SimpleNamespace()
+ sym_table = make_symbol_table(nested=nested, obj=obj)
+ interp = Interpreter(symtable=sym_table)
+ interp(f"obj.{attr} = 1", show_errors=False)
+ check_error(interp, 'AttributeError',
+ f'cannot assign to unsafe attribute {attr}')
+ assert not hasattr(obj, attr)
+
+
@pytest.mark.parametrize("nested", [False, True])
def test_names(nested):
"""names test"""
@@ -685,7 +700,7 @@
istrue(interp, "isinstance(n, ndarray)")
istrue(interp, "n.shape == (5, 4)")
interp("myx = n.shape")
- interp("n.shape = (4, 5)")
+ interp("n.reshape((4, 5))")
istrue(interp, "n.shape == (4, 5)")
interp("a = arange(20)")
interp("gg = a[1:13:3]")
@@ -876,6 +891,43 @@
isvalue(interp, 'result', [10, 26])
@pytest.mark.parametrize("nested", [False, True])
+def test_comprehension_no_leak(nested):
+ """comprehension loop variables must not leak into the symbol table"""
+ interp = make_interpreter(nested_symtable=nested)
+
+ # new loop variable must not remain accessible
+ interp('x = [ti for ti in range(13)]')
+ isvalue(interp, 'x', list(range(13)))
+ assert 'ti' not in interp.symtable
+
+ # pre-existing symbol shadowed by comprehension must keep its value
+ interp('j = 42')
+ interp('y = [j*j for j in range(4)]')
+ isvalue(interp, 'y', [0, 1, 4, 9])
+ isvalue(interp, 'j', 42)
+
+ # tuple-unpacking targets are also cleaned up
+ interp('z = [a + b for a, b in [(1, 2), (3, 4)]]')
+ isvalue(interp, 'z', [3, 7])
+ assert 'a' not in interp.symtable
+ assert 'b' not in interp.symtable
+
+ # set and dict comprehensions too
+ interp('s = {k for k in range(3)}')
+ isvalue(interp, 's', {0, 1, 2})
+ assert 'k' not in interp.symtable
+
+ interp('d = {n: n*2 for n in range(3)}')
+ isvalue(interp, 'd', {0: 0, 1: 2, 2: 4})
+ assert 'n' not in interp.symtable
+
+ # nested generators: each loop variable is cleaned up
+ interp('m = [(i, j) for i in range(2) for j in range(3)]')
+ isvalue(interp, 'm', [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)])
+ assert 'i' not in interp.symtable
+ isvalue(interp, 'j', 42)
+
[email protected]("nested", [False, True])
def test_ifexp(nested):
"""test if expressions"""
interp = make_interpreter(nested_symtable=nested)
@@ -1370,14 +1422,39 @@
assert not imin.config['augassign']
assert not imin.config['with']
+ imin('import socket')
+ assert len(imin.error) > 0
+ imin.error = []
+ imin('x = 9')
+ imin('y = 4 if x > 0 else -1')
+ assert len(imin.error) > 0
+
+
ix = Interpreter(with_import=True, with_importfrom=True,
nested_symtable=nested)
assert ix.node_handlers['ifexp'] != ix.unimplemented
assert ix.node_handlers['import'] != ix.unimplemented
assert ix.node_handlers['importfrom'] != ix.unimplemented
+ ix('import socket')
+ assert len(ix.error) == 0
+ ix('from pathlib import Path')
+ assert len(ix.error) == 0
+ ix('from pathlib import not_importable')
+ assert len(ix.error) > 0
+
+ ix.error = []
+ ix('import nq77spr23as_module_not_avaiable')
+ assert len(ix.error) > 0
+
i2 = Interpreter(config=conf, nested_symtable=nested)
assert i2.node_handlers['ifexp'] != i2.unimplemented
assert i2.node_handlers['import'] == i2.unimplemented
+ i2('import socket')
+ assert len(i2.error) > 0
+ i2.error = []
+ i2('x = 9')
+ i2('y = 4 if x > 0 else -1')
+ assert len(i2.error) == 0
@pytest.mark.parametrize("nested", [False, True])