Skip to content

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

@odinsbane

Description

@odinsbane

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions