Skip to content

[FIX] pytta.generate crashes in plain scripts on Python 3.12 and SciPy 1.13+ - #52

Open
aguirreSL wants to merge 2 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-fix_creation_name
Open

aguirreSL wants to merge 2 commits into
PyTTaMaster:developmentfrom
aguirreSL:dev-fix_creation_name

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Oct 31, 2026 •

Copy link
Copy Markdown

On Python 3.12 with a current SciPy, x = pytta.generate.sweep() in a plain script fails, both at module level and inside a function:

AttributeError: 'NoneType' object has no attribute 'f_back'
UnboundLocalError: cannot access local variable 'framenline' where it is not associated with a value
AttributeError: module 'scipy.signal' has no attribute 'hann'

Two causes, one commit each:

  1. The name given to generated objects (creation_name) was read by a block copied in 20 places (generate, the run methods of the measurements, rooms, iso3741, apps/roomir). It walks the stack with traceback.walk_stack(None), which since Python 3.12 starts four frames up instead of two; in a shallow script it walks past the end of the stack. The 20 copies are replaced by one helper, _instanceinfo.caller_name(), which walks from the caller explicitly and returns an empty name when the source line is not available (python -c). Behaviour is otherwise the same: the text before = on the module-level line of the calling script.
  2. scipy.signal.hann and scipy.signal.tukey were removed in SciPy 1.13; the 5 calls now use scipy.signal.windows, the same functions with the same defaults.

Tests (tests/test_creation_name.py, 2 tests) run real scripts in a subprocess, since under pytest the stack is deep enough to hide the first failure: a script gets the module-level name, also when the generator is called inside a function, and python -c works with an empty name.

The fix also clears 4 of the 7 failures that development has: the 3 in tests/test_h5io.py and test_pyttasave_impulsiveresponse in tests/test_pyttasave.py. The 3 left, all in tests/test_pyttasave.py (ChannelsList initialization, int64 in JSON), are unrelated.

Checked with Python 3.12, numpy 1.26, scipy 1.17.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

aguirreSL and others added 2 commits October 31, 2026 19:44
The name given to generated objects was read by a block copied in 20
places that walked the stack with traceback.walk_stack(None). Since
Python 3.12 it starts four frames up instead of two, so in a plain
script it walks past the end of the stack and pytta.generate.sweep()
raises AttributeError at module level and UnboundLocalError inside a
function. One helper, _instanceinfo.caller_name, replaces the copies: it
walks from the caller explicitly and returns an empty name when the
source line is not available (python -c).

Tests run real scripts in a subprocess, since under pytest the stack is
deep enough to hide the failure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
scipy.signal.hann and scipy.signal.tukey were removed in SciPy 1.13. The
five calls now use scipy.signal.windows, the same functions with the
same defaults.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant