Dollar sign to call variable in text box crashes PsychoPY

Ubuntu 22.04
Psychopy 2023.1.1.
standalone in virtual environment

calling variable in text box kills psychopy - using $var

same problem as: Jan 22 posting: Dollar sign in text box crashes Psychopy

PsychoPy error
Traceback (most recent call last):
File “/home/cat/Psycho/lib/python3.8/site-packages/PsychoPy-2023.1.1-py3.8.egg/psychopy/app/builder/dialogs/paramCtrls.py”, line 50, in validate
validate(self, self.valType)
File “/home/cat/Psycho/lib/python3.8/site-packages/PsychoPy-2023.1.1-py3.8.egg/psychopy/app/builder/dialogs/paramCtrls.py”, line 1013, in validate
if re.findall(r"(?<!\)"", val):
File “/usr/lib/python3.8/re.py”, line 241, in findall
return _compile(pattern, flags).findall(string)
File “/usr/lib/python3.8/re.py”, line 291, in _compile
if isinstance(flags, RegexFlag):
RecursionError: maximum recursion depth exceeded while calling a Python object

Also:

(psychopy:1515926): Gtk-WARNING **: 08:43:02.565: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects ‘indexable’ buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators

Did you try using a variable with a different name?
It’s possible the var() function which is part of Python, messes up your code.

This happens even when running a PsychoPy demo (e.g., Stroop). In exploring, I think there may be a GTK threading error. Following from https://www.manpagez.com/html/gdk3/gdk3-3.14.4/gdk3-Threads.php

GTK+, however, is not thread safe. You should only use GTK+ and GDK from the thread gtk_init() and gtk_main() were called on. This is usually referred to as the “main thread”.

Signals on GTK+ and GDK types, as well as non-signal callbacks, are emitted in the main thread.

You can schedule work in the main thread safely from other threads by using gdk_threads_add_idle() and gdk_threads_add_timeout():

Also from Threads & Concurrency — PyGObject

Operations which could potentially block should not be executed in the main loop. The main loop is in charge of input processing and drawing and blocking it results in the user interface freezing. For the user this means not getting any feedback and not being able to pause or abort the operation which causes the problem.

Such an operation might be:
Loading external resources like an image file on the web
Searching the local file system
Writing, reading and copying files
Calculations where the runtime depends on some external factor

OK, more info. Problem seems to be isolated to Builder. When I run a script created in an older version of PsychoPy, the pyexp (builder version) crashes, but the py (coder) version runs fine without crashing. But, that means Builder can’t be used to create new scripts as currently configured. Is there a fix?

Update: Apparently, there is an interaction between the theme setting for PsychoPy and the crash. Using the “classic” theme the script runs (and the demos), but other themes cause Builder to crash

Update 2: Old scripts will run as last comment, but new scripts still crash when calling a $var in text even under classic and other themes.

OK, for anyone having this problem, it’s apparently a bug that’s been reported on GitHub: