mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: Workaround inability to set name attribute on SpooledTemporaryFile
This commit is contained in:
parent
a5324474d8
commit
828c1f394a
@ -266,6 +266,7 @@ class SpooledTemporaryFile(tempfile.SpooledTemporaryFile):
|
|||||||
if dir is None:
|
if dir is None:
|
||||||
dir = base_dir()
|
dir = base_dir()
|
||||||
if ispy3:
|
if ispy3:
|
||||||
|
self._name = None
|
||||||
tempfile.SpooledTemporaryFile.__init__(self, max_size=max_size,
|
tempfile.SpooledTemporaryFile.__init__(self, max_size=max_size,
|
||||||
suffix=suffix, prefix=prefix, dir=dir, mode=mode)
|
suffix=suffix, prefix=prefix, dir=dir, mode=mode)
|
||||||
else:
|
else:
|
||||||
@ -273,6 +274,15 @@ class SpooledTemporaryFile(tempfile.SpooledTemporaryFile):
|
|||||||
suffix=suffix, prefix=prefix, dir=dir, mode=mode,
|
suffix=suffix, prefix=prefix, dir=dir, mode=mode,
|
||||||
bufsize=bufsize)
|
bufsize=bufsize)
|
||||||
|
|
||||||
|
if ispy3:
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, val):
|
||||||
|
self._name = val
|
||||||
|
|
||||||
def truncate(self, *args):
|
def truncate(self, *args):
|
||||||
# The stdlib SpooledTemporaryFile implementation of truncate() doesn't
|
# The stdlib SpooledTemporaryFile implementation of truncate() doesn't
|
||||||
# allow specifying a size.
|
# allow specifying a size.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user