sciencemesh / cs3api4lab

CS3APIs Jupyterlab connector
Apache License 2.0
4 stars 11 forks source link

Error when saving #227

Open diocas opened 1 year ago

diocas commented 1 year ago

Not sure what happened.. Opened a notebook, clicked save and got this:

[E 2023-06-07 16:22:20.363 ServerApp] Error saving: /eos/user/d/dalvesde/SWAN_projects/___DELETE2/Untitled.ipynb 'latin-1' codec can't encode character '\u2014' in position 564: Body ('—') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.

Not sure where the issue is coming.

diocas commented 1 year ago

The stranger thing is that I open the notebook, do nothing and try to immediately close it, and it says it has unsaved changes..

piotrWichlinskiSoftwaremind commented 1 year ago

@diocas That's because we are using UTF-8 encoding while reading and writing a file: https://github.com/sciencemesh/cs3api4lab/blob/ed1b9974730fa0624182ffb313f5b09bc3e31b34/cs3api4lab/api/cs3apismanager.py#LL426C21-L426C21

https://github.com/sciencemesh/cs3api4lab/blob/ed1b9974730fa0624182ffb313f5b09bc3e31b34/cs3api4lab/api/cs3apismanager.py#L321

diocas commented 1 year ago

Upstream does the same: https://github.com/jupyter-server/jupyter_server/blob/main/jupyter_server/services/contents/fileio.py#L332-L349

And with upstream I don't get this error... So something else is strange here...