scyjava icon indicating copy to clipboard operation
scyjava copied to clipboard

When running python scripts from fiji it is possible to have a None_writer().

Open odinsbane opened this issue 2 months ago • 0 comments

I tried to run a very simple script in headless fiji.

fiji --python --headless --run hello_world.py

File "python-venv/lib/python3.13/site-packages/scyjava/_script.py", line 47, in write self._writer().write(s) ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'write'

The script:

import sys
print("hello world", sys.version)

I checked the code, and _script.py has the following line.

return self._std_default if ctx is None else ctx.getWriter()

It appears that a context is created, but the context writer is None. If I change the condition

if ctx is not None and ctx.getWriter() is not None:
    return ctx.getWriter()
return self._std_default

Now my script appears to work ok.

odinsbane avatar Nov 26 '25 09:11 odinsbane