This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SpooledTemporaryFile's name property is broken
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: collinwinter, eric.araujo, georg.brandl, giampaolo.rodola, ncoghlan, python-dev, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2010-11-08 12:14 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
SpooledTemporaryFile_properties.patch serhiy.storchaka, 2013-02-06 17:40 Patch for 3.x review
SpooledTemporaryFile_properties-2.7.patch serhiy.storchaka, 2013-02-06 17:41 Patch for 2.7 review
Messages (10)
msg120736 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-11-08 12:14
>>> import tempfile
>>> tempfile.SpooledTemporaryFile().name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/giampaolo/svn/python-2.7/Lib/tempfile.py", line 574, in name
    return self._file.name
AttributeError: 'cStringIO.StringO' object has no attribute 'name'
msg120760 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-08 15:50
What makes you think SpooledTemporaryFile *has* a name attribute? :)

Seriously, though, I presume this bug report is asking for either a better error message or for .name to raise an attribute error on a SpooledTemporaryFile?
msg120763 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-11-08 16:04
Yes, sorry, I should have been less concise. =)

> Seriously, though, I presume this bug report is asking for either a 
> better error message or for .name to raise an attribute error on a 
> SpooledTemporaryFile?

I'm not sure what's better. I must be honest and say that I opened this report more to signal this behavior rather than provide a solution, though.
msg120764 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-08 16:12
From the doc of tempfile.NamedTemporaryFile: “This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name member of the file object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later).”
msg120767 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-08 16:25
Éric: right, but we're talking about *Spooled*Temprorary file, which doesn't say anything about a name, and in fact says that the data is kept in memory (which implies it has no name).
msg120773 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-08 17:09
Wow, brain fail.  What I actually wanted to say:  SpooledTemporaryFile “operates exactly as TemporaryFile() does”, which is not guaranteed to have a name.  The definition of file-like object (linked from tempfile docs) says nothing about a name either.  Therefore, I think the presence of this attribute is a bug.

Adding Collin to nosy, as the committer of SpooledTemporaryFile.
msg120775 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-11-08 17:14
Also "encoding" and "mode" properties fail in the same manner.
msg181543 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-06 17:40
Here is a patch which implements properties for which it has a sense and remove if there is no sense.
msg181728 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-09 10:26
New changeset 5c2ff6e64c47 by Serhiy Storchaka in branch '2.7':
Issue #10355: SpooledTemporaryFile properties and xreadline method now work for unrolled files.
http://hg.python.org/cpython/rev/5c2ff6e64c47

New changeset dfc6902b63d7 by Serhiy Storchaka in branch '3.2':
Issue #10355: SpooledTemporaryFile properties now work for unrolled files.
http://hg.python.org/cpython/rev/dfc6902b63d7

New changeset f36d8ba4eeef by Serhiy Storchaka in branch '3.3':
Issue #10355: SpooledTemporaryFile properties now work for unrolled files.
http://hg.python.org/cpython/rev/f36d8ba4eeef

New changeset f1a13191f0c8 by Serhiy Storchaka in branch 'default':
Issue #10355: SpooledTemporaryFile properties now work for unrolled files.
http://hg.python.org/cpython/rev/f1a13191f0c8
msg181798 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-02-10 12:46
New changeset 6e9210a092cf by Serhiy Storchaka in branch '3.2':
Fix a test for SpooledTemporaryFile (added in issue #10355).
http://hg.python.org/cpython/rev/6e9210a092cf

New changeset b5074ed74ec3 by Serhiy Storchaka in branch '3.3':
Fix a test for SpooledTemporaryFile (added in issue #10355).
http://hg.python.org/cpython/rev/b5074ed74ec3

New changeset 029011429f80 by Serhiy Storchaka in branch 'default':
Fix a test for SpooledTemporaryFile (added in issue #10355).
http://hg.python.org/cpython/rev/029011429f80
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54564
2013-02-20 00:41:55r.david.murraylinkissue6541 superseder
2013-02-10 12:46:00python-devsetmessages: + msg181798
2013-02-09 10:36:50serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-02-09 10:26:55python-devsetnosy: + python-dev
messages: + msg181728
2013-02-06 17:41:06serhiy.storchakasetfiles: + SpooledTemporaryFile_properties-2.7.patch
2013-02-06 17:40:20serhiy.storchakasetfiles: + SpooledTemporaryFile_properties.patch

assignee: serhiy.storchaka
components: + Library (Lib)
versions: + Python 3.3, Python 3.4, - Python 3.1
keywords: + patch
nosy: + serhiy.storchaka, ncoghlan

messages: + msg181543
stage: needs patch -> patch review
2010-11-08 17:14:58giampaolo.rodolasetmessages: + msg120775
2010-11-08 17:09:42eric.araujosetnosy: + collinwinter
messages: + msg120773
2010-11-08 16:25:30r.david.murraysetmessages: + msg120767
2010-11-08 16:12:14eric.araujosetmessages: + msg120764
2010-11-08 16:04:45giampaolo.rodolasetmessages: + msg120763
2010-11-08 15:50:37r.david.murraysetnosy: + r.david.murray
messages: + msg120760

type: behavior
stage: needs patch
2010-11-08 15:08:05eric.araujosetnosy: + eric.araujo
2010-11-08 12:14:00giampaolo.rodolacreate