Skip to content

NamedTemporaryFile expects bytes, not string in documentation for tempfile module #61473

Closed

Description

@jsf80238gmailcom
BPO 17271
Nosy @ezio-melotti

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/ezio-melotti'
closed_at = <Date 2013-02-22.06:30:18.775>
created_at = <Date 2013-02-22.05:55:23.604>
labels = ['type-feature', 'docs']
title = 'NamedTemporaryFile expects bytes, not string in documentation for tempfile module'
updated_at = <Date 2013-02-22.06:30:18.772>
user = 'https://bugs.python.org/jsf80238gmailcom'

bugs.python.org fields:

activity = <Date 2013-02-22.06:30:18.772>
actor = 'ezio.melotti'
assignee = 'ezio.melotti'
closed = True
closed_date = <Date 2013-02-22.06:30:18.775>
closer = 'ezio.melotti'
components = ['Documentation']
creation = <Date 2013-02-22.05:55:23.604>
creator = 'jsf80238@gmail.com'
dependencies = []
files = []
hgrepos = []
issue_num = 17271
keywords = []
message_count = 3.0
messages = ['182640', '182649', '182650']
nosy_count = 4.0
nosy_names = ['ezio.melotti', 'docs@python', 'python-dev', 'jsf80238@gmail.com']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue17271'
versions = ['Python 3.2', 'Python 3.3', 'Python 3.4']

Activity

  1. jsf80238gmailcom commented on Feb 22, 2013

    jsf80238gmailcommannequin
    MannequinAuthor

    Page is http://docs.python.org/3/library/tempfile.html#module-tempfile.

    The code in question currently reads:
    >>> f = NamedTemporaryFile(delete=False)
    >>> f
    <open file '<fdopen>', mode 'w+b' at 0x384698>
    >>> f.name
    '/var/folders/5q/5qTPn6xq2RaWqk+1Ytw3-U+++TI/-Tmp-/tmpG7V1Y0'
    >>> f.write("Hello World!\n")
    >>> f.close()
    >>> os.unlink(f.name)
    >>> os.path.exists(f.name)
    False
    
    It should read:
    >>> import os
    >>> from tempfile import NamedTemporaryFile
    >>> f = NamedTemporaryFile(delete=False)
    >>> f
    <tempfile._TemporaryFileWrapper object at 0x29bfc50>
    >>> f.name
    '/tmp/tmpdxd_85'
    >>> f.write("Hello World!\n".encode())
    13
    >>> f.close()
    >>> os.unlink(f.name)
    >>> os.path.exists(f.name)
    False
  2. python-dev commented on Feb 22, 2013

    python-devmannequin
    Mannequin

    New changeset 82343bbf8868 by Ezio Melotti in branch '3.2':
    bpo-17271: update example in tempfile docs.
    http://hg.python.org/cpython/rev/82343bbf8868

    New changeset a9993d40821f by Ezio Melotti in branch '3.3':
    bpo-17271: merge with 3.2.
    http://hg.python.org/cpython/rev/a9993d40821f

    New changeset fcc61327c86c by Ezio Melotti in branch 'default':
    bpo-17271: merge with 3.3.
    http://hg.python.org/cpython/rev/fcc61327c86c

  3. ezio-melotti commented on Feb 22, 2013

    @ezio-melotti
    Member

    Fixed, thanks for the report!

  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dirtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions