SpooledTemporaryFile introduced new changes in 3.11 (https://docs.python.org/3/library/tempfile.html)
It now fully implements the io.BufferedIOBase and io.TextIOBase abstract base classes allowing the file
to be readable in the mode that it was specified (without accessing the underlying ._file object).
It seems like wrapping the underlying ._file is forbidden for versions 3.11 and higher (results in the ValueError)
Having two have separate methods for different versions isn't the prettiest fix but should suffice.
Fixes https://github.com/jschneier/django-storages/pull/1381 CI Failures for Python 3.11 and above
SpooledTemporaryFile
introduced new changes in 3.11 (https://docs.python.org/3/library/tempfile.html) It now fully implements theio.BufferedIOBase
andio.TextIOBase
abstract base classes allowing the file to be readable in the mode that it was specified (without accessing the underlying._file
object).It seems like wrapping the underlying
._file
is forbidden for versions 3.11 and higher (results in theValueError
) Having two have separate methods for different versions isn't the prettiest fix but should suffice.