Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.10 save_data to StringIO error TypeError: string argument expected, got 'bytes' #33

Open
ondrejkolin opened this issue Jul 17, 2022 · 1 comment

Comments

@ondrejkolin
Copy link

Writing to memory example from the README.md doesn't work in Python3.10.

>>> from pyexcel_ods3 import save_data
>>> data = OrderedDict()
>>> data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
>>> data.update({"Sheet 2": [[7, 8, 9], [10, 11, 12]]})
>>> io = StringIO()
>>> save_data(io, data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/pyexcel_ods3/__init__.py", line 43, in save_data
    write_data(afile, data, file_type=file_type, **keywords)
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/pyexcel_io/io.py", line 142, in save_data
    with get_writer(**keywords) as writer:
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/pyexcel_io/writer.py", line 51, in __exit__
    self.close()
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/pyexcel_io/writer.py", line 45, in close
    self.writer.close()
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/pyexcel_ods3/odsw.py", line 114, in close
    self.ods_book.save()
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/ezodf/document.py", line 125, in save
    self._saving_routine()
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/ezodf/document.py", line 233, in _saving_routine
    self.filemanager.save(self.docname, backup=self.backup)
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/ezodf/filemanager.py", line 88, in save
    self._tozip(zippo)
  File "/home/ondrej/logistic/backend/venv/lib64/python3.10/site-packages/ezodf/filemanager.py", line 144, in _tozip
    zippo.writestr(mimetype.zipinfo, mimetype.tobytes())
  File "/usr/lib64/python3.10/zipfile.py", line 1814, in writestr
    with self.open(zinfo, mode='w') as dest:
  File "/usr/lib64/python3.10/zipfile.py", line 1517, in open
    return self._open_to_write(zinfo, force_zip64=force_zip64)
  File "/usr/lib64/python3.10/zipfile.py", line 1612, in _open_to_write
    self.fp.write(zinfo.FileHeader(zip64))
TypeError: string argument expected, got 'bytes'

@Lapeth
Copy link

Lapeth commented Sep 15, 2023

Agreed. This is quite annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants