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

SpooledTemporaryFile's name property is broken #54564

Closed
giampaolo opened this issue Nov 8, 2010 · 10 comments
Closed

SpooledTemporaryFile's name property is broken #54564

giampaolo opened this issue Nov 8, 2010 · 10 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@giampaolo
Copy link
Contributor

BPO 10355
Nosy @birkenfeld, @ncoghlan, @giampaolo, @merwok, @bitdancer, @serhiy-storchaka
Files
  • SpooledTemporaryFile_properties.patch: Patch for 3.x
  • SpooledTemporaryFile_properties-2.7.patch: Patch for 2.7
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2013-02-09.10:36:50.792>
    created_at = <Date 2010-11-08.12:14:00.575>
    labels = ['type-bug', 'library']
    title = "SpooledTemporaryFile's name property is broken"
    updated_at = <Date 2013-02-10.12:46:00.237>
    user = 'https://github.com/giampaolo'

    bugs.python.org fields:

    activity = <Date 2013-02-10.12:46:00.237>
    actor = 'python-dev'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2013-02-09.10:36:50.792>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2010-11-08.12:14:00.575>
    creator = 'giampaolo.rodola'
    dependencies = []
    files = ['28980', '28981']
    hgrepos = []
    issue_num = 10355
    keywords = ['patch']
    message_count = 10.0
    messages = ['120736', '120760', '120763', '120764', '120767', '120773', '120775', '181543', '181728', '181798']
    nosy_count = 8.0
    nosy_names = ['georg.brandl', 'collinwinter', 'ncoghlan', 'giampaolo.rodola', 'eric.araujo', 'r.david.murray', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue10355'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @giampaolo
    Copy link
    Contributor Author

    >>> 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'

    @bitdancer
    Copy link
    Member

    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?

    @bitdancer bitdancer added the type-bug An unexpected behavior, bug, or error label Nov 8, 2010
    @giampaolo
    Copy link
    Contributor Author

    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.

    @merwok
    Copy link
    Member

    merwok commented Nov 8, 2010

    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).”

    @bitdancer
    Copy link
    Member

    É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).

    @merwok
    Copy link
    Member

    merwok commented Nov 8, 2010

    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.

    @giampaolo
    Copy link
    Contributor Author

    Also "encoding" and "mode" properties fail in the same manner.

    @serhiy-storchaka
    Copy link
    Member

    Here is a patch which implements properties for which it has a sense and remove if there is no sense.

    @serhiy-storchaka serhiy-storchaka added the stdlib Python modules in the Lib dir label Feb 6, 2013
    @serhiy-storchaka serhiy-storchaka self-assigned this Feb 6, 2013
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 9, 2013

    New changeset 5c2ff6e64c47 by Serhiy Storchaka in branch '2.7':
    Issue bpo-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 bpo-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 bpo-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 bpo-10355: SpooledTemporaryFile properties now work for unrolled files.
    http://hg.python.org/cpython/rev/f1a13191f0c8

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 10, 2013

    New changeset 6e9210a092cf by Serhiy Storchaka in branch '3.2':
    Fix a test for SpooledTemporaryFile (added in issue bpo-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 bpo-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 bpo-10355).
    http://hg.python.org/cpython/rev/029011429f80

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants