Opened 9 years ago
Closed 9 years ago
#24963 closed Bug (fixed)
Missing `seekable()` method in Files
Reported by: | Carson Gee | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Neither in django/core/files/utils.py or django/core/files/base.py::File is the seekable method implemented. In python 3 this results in issues when attempting to use python standard interfaces such as bz2
or tarfile
and results in AttributeError: 'File' object has no attribute 'seekable'
errors when using File class objects.
I'm not sure the best way to patch this though. The seekable property isn't available in python2, but I think it can be duplicated in 2, by checking if it has seek
, tell
, and truncate
based on https://docs.python.org/3/library/io.html#io.IOBase.seekable. I'm happy to write the patch, but it would be worth knowing the preference for how to fix it.
Change History (4)
comment:1 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 9 years ago
I have now submitted a patch with tests: https://github.com/django/django/pull/4842
comment:3 by , 9 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
The code looks good, but it should at least be documented in docs/ref/files/file.txt
.
An acceptable option might be to implement the method only on Python 3 if it's not part of the standard interface on Python 2.