Skip to content

Crash on Preview: AttributeError: 'SpooledTemporaryFile' object has no attribute 'encode' #1974

@sebix

Description

@sebix

A user clicked the Preview button when the Moin wiki threw an Internal Server Error. This is the corresponding traceback from the logs.

Traceback (most recent call last):
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1511, in 
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 919, in f
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 917, in f
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 902, in d
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/apps/frontend/views.py", line 951, in modify_item
    ret = item.do_modify(item_may=item_may)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/items/__init__.py", line 1604, in do_modify
    edit_utils.put_draft(data)
  File "/home/intevation/source/moin.git/src/moin/utils/edit_locking.py", line 175, in put_draft
    data_in = data_in.encode(self.coding)
              ^^^^^^^^^^^^^^
AttributeError: 'SpooledTemporaryFile' object has no attribute 'encode'
2025-08-08 10:00:02,923 ERROR moin:875 Exception on /+modify/A2/49 [POST]
Traceback (most recent call last):
  [same as above]

Using Moin 2.0.0b3-73-g44a66b21 (latest revision as of now).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions