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

AttributeError: 'FileUpload' object has no attribute 'seekable' #44

Closed
mgedmin opened this issue Jul 10, 2019 · 2 comments · Fixed by #47
Closed

AttributeError: 'FileUpload' object has no attribute 'seekable' #44

mgedmin opened this issue Jul 10, 2019 · 2 comments · Fixed by #47

Comments

@mgedmin
Copy link
Member

mgedmin commented Jul 10, 2019

If you pass self.request['file_field'] to zipfile.ZipFile() on Python 3.7, you will get this error:

Traceback (most recent call last):
    ...
  File "/usr/lib/python3.7/zipfile.py", line 1428, in read
    with self.open(name, "r", pwd) as fp:
  File "/usr/lib/python3.7/zipfile.py", line 1480, in open
    self._fpclose, self._lock, lambda: self._writing)
  File "/usr/lib/python3.7/zipfile.py", line 722, in __init__
    self.seekable = file.seekable
AttributeError: 'FileUpload' object has no attribute 'seekable'

Adding seekable to the methods list in FileUpload.__init__ is enough to make the error go away.

This error does not show up on Python 3.5. I haven't checked Python 3.6 yet.

mgedmin added a commit that referenced this issue Jul 10, 2019
@mgedmin
Copy link
Member Author

mgedmin commented Sep 24, 2024

This appears to have regressed in zope.publisher 6.0.0 recently. GitHub Actions show that the tests passed four days ago, but are failing now.

There was a new https://pypi.org/project/multipart/#history release (1.0.0) four days ago, which I don't think is a coincidence.

@mgedmin mgedmin reopened this Sep 24, 2024
@mgedmin
Copy link
Member Author

mgedmin commented Sep 24, 2024

So, the seekable() method disappeared for me because multipart.MultipartPart.file, which is a tempfile.SpooledTemporaryFile since multipart 1.0.0, doesn't have seekable() in Python 3.10 or older, and I'm using 3.8 (because Ubuntu 20.04 LTS).

mgedmin added a commit that referenced this issue Sep 24, 2024
The new parser in multipart 1.0.0 requires CRLF rather than LF line
endings: defnull/multipart#55

Fixes most of #74.  The one remaining failure is a regression of #44
(lack of `.seekable()` on FileUpload objects).
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

Successfully merging a pull request may close this issue.

1 participant