Skip to content

Latest commit

 

History

History
200 lines (151 loc) · 5.58 KB

README.md

File metadata and controls

200 lines (151 loc) · 5.58 KB

SymPy import with the reported versions (#4506)

Original issue. Resolved in the reported scope. SymPy 1.11.1 with mpmath 1.2.1 imports successfully. Tracing observes the original power.py:378 is_commutative assignment, and the reported Pow path succeeds.

Environment

  • Source and standard library: f39b054b9c8c.
  • Verified October 5, 2026 on macOS 26.5.2 ARM64.
  • RustPython: 0.6.1, Python 3.14.0.alpha; x86_64 through Rosetta.
  • Comparison: CPython 3.14.6 ARM64.

Use absolute paths for the variables below:

  • RP: the RustPython executable for this commit.
  • CP: the CPython 3.14.6 executable.
  • SRC: the source directory at this commit, including its matching Lib.
  • CASE: the directory containing the files shown below.

Shell variables replace recorded absolute paths. Export them so the Python inputs can use them:

export RP CP SRC CASE
unset PYTHONPATH PYTHONHOME PYTHONWARNINGS PYTHONSTARTUP
export PYTHONDONTWRITEBYTECODE=1
export LANG=en_US.UTF-8 LC_NUMERIC=en_US.UTF-8

LC_ALL was unset in these recorded runs.

unset LC_ALL

Dependencies: SymPy 1.11.1 and mpmath 1.2.1. Set SYMPY_SITE to their shared package directory and export it. Both interpreters used the same package files; package installation and the full SymPy suite are outside this check.

export SYMPY_SITE

Reproducer

Save as probe-sympy-original.py. SYMPY_SITE replaces the recorded package path.

import sys
import os
import json

site = os.environ["SYMPY_SITE"]
sys.path.insert(0, site)
import sympy
import mpmath
from sympy import Pow, S, Symbol, expand
from sympy.core.cache import clear_cache

assert sympy.__version__ == "1.11.1"
assert mpmath.__version__ == "1.2.1"
assert sympy.__file__.startswith(site + "/")
assert mpmath.__file__.startswith(site + "/")
clear_cache()
events = []


def trace(frame, event, arg):
    if (
        event == "line"
        and frame.f_code.co_filename == site + "/sympy/core/power.py"
        and frame.f_lineno == 378
    ):
        events.append([frame.f_code.co_name, frame.f_lineno])
    return trace


sys.settrace(trace)
value = Pow(S.Exp1, -1, evaluate=False)
sys.settrace(None)
assert value.is_commutative is True
assert events, "Original power.py assignment was not observed"
x = Symbol("x")
assert expand((x + 1) ** 2) == x**2 + 2 * x + 1
print(
    json.dumps(
        {
            "versions": [sympy.__version__, mpmath.__version__],
            "files": [sympy.__file__, mpmath.__file__],
            "original_assignment": events,
            "pow": str(value),
            "is_commutative": value.is_commutative,
            "expanded": str(expand((x + 1) ** 2)),
        },
        indent=2,
    )
)

Run

cd "$SRC"

RustPython:

RUSTPYTHONPATH="$SRC/Lib" "$RP" -B "$CASE/probe-sympy-original.py"

CPython:

"$CP" -B "$CASE/probe-sympy-original.py"

Results

Expected: The already installed reported package versions must import without the descriptor AttributeError.

RustPython and CPython 3.14.6

Exit code: 0. No timeout.

stdout:

{
  "versions": [
    "1.11.1",
    "1.2.1"
  ],
  "files": [
    "$SYMPY_SITE/sympy/__init__.py",
    "$SYMPY_SITE/mpmath/__init__.py"
  ],
  "original_assignment": [
    [
      "__new__",
      378
    ]
  ],
  "pow": "1/E",
  "is_commutative": true,
  "expanded": "x**2 + 2*x + 1"
}

stderr:

$SYMPY_SITE/sympy/testing/runtests.py:275: SyntaxWarning: 'return' in a 'finally' block
  return p.returncode

Historical failure

Previously recorded at adc23253e4b5; exit code 1. This run was not repeated alongside the current results. Historical inputs may differ from the expanded checks above.

stdout: No output.

stderr:

    class LambertW(Function):
  File "$SYMPY_SITE/sympy/functions/elementary/exponential.py", line 1159, in LambertW
    _singularities = (-Pow(S.Exp1, -1, evaluate=False), S.ComplexInfinity)
  File "$SYMPY_SITE/sympy/core/cache.py", line 74, in wrapper
    retval = func(*args, **kwargs)
  File "$SYMPY_SITE/sympy/core/cache.py", line 70, in wrapper
    retval = cfunc(*args, **kwargs)
  File "$SRC/pylib/Lib/functools.py", line 593, in wrapper
    result = user_function(*args, **kwds)
  File "$SYMPY_SITE/sympy/core/power.py", line 378, in __new__
    obj.is_commutative = (b.is_commutative and e.is_commutative)
AttributeError: can't set attribute

Related change and scope

PR #6390: install declared slot descriptors even over inherited attributes.

The same dependency files were used in RustPython and CPython and their RECORD hashes were checked. Package installation and the full SymPy suite were not rerun.

First fixing commit: not established.

Evidence

Recorded executable SHA-256 values:

AI assistance: OpenAI Codex.