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

[doc] On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile #78610

Closed
dwich mannequin opened this issue Aug 18, 2018 · 6 comments
Closed

[doc] On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile #78610

dwich mannequin opened this issue Aug 18, 2018 · 6 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy

Comments

@dwich
Copy link
Mannequin

dwich mannequin commented Aug 18, 2018

BPO 34429
Nosy @miss-islington, @iritkatriel, @slateny
PRs
  • bpo-34429: Noted TemporaryFile behavior on non-Posix/non-Cygwin systems #31547
  • [3.10] bpo-34429: Noted TemporaryFile behavior on non-Posix/non-Cygwin systems (GH-31547) #31567
  • [3.9] bpo-34429: Noted TemporaryFile behavior on non-Posix/non-Cygwin systems (GH-31547) #31568
  • 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 = None
    closed_at = <Date 2022-02-25.11:34:58.907>
    created_at = <Date 2018-08-18.11:00:17.881>
    labels = ['easy', '3.11', '3.9', '3.10', 'docs']
    title = '[doc] On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile'
    updated_at = <Date 2022-02-25.11:34:58.906>
    user = 'https://bugs.python.org/dwich'

    bugs.python.org fields:

    activity = <Date 2022-02-25.11:34:58.906>
    actor = 'iritkatriel'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2022-02-25.11:34:58.907>
    closer = 'iritkatriel'
    components = ['Documentation']
    creation = <Date 2018-08-18.11:00:17.881>
    creator = 'dwich'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34429
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['323702', '324032', '411431', '413974', '413977', '413980']
    nosy_count = 5.0
    nosy_names = ['docs@python', 'miss-islington', 'dwich', 'iritkatriel', 'slateny']
    pr_nums = ['31547', '31567', '31568']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue34429'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @dwich
    Copy link
    Mannequin Author

    dwich mannequin commented Aug 18, 2018

    On Windows tempfile.TemporaryFile() accepts delete attribute. On Linux TemporaryFile() raises TypeError if delete attribute is used.

    In tempfile.py source is the code below which means that on Windows TemporaryFile behaves like NamedTemporaryFile. I suppose the code should not be changed but the behaviour should be mentioned in documentation.

    if _os.name != 'posix' or _os.sys.platform == 'cygwin':
        # On non-POSIX and Cygwin systems, assume that we cannot unlink a file
        # while it is open.
        TemporaryFile = NamedTemporaryFile
    Steps to reproduce:
    >>> import tempfile
    >>> tf = tempfile.TemporaryFile(delete=False)

    On Linux Python throws TypeError:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: TemporaryFile() got an unexpected keyword argument 'delete'

    On Windows Python does not throw TypeError because on Windows TemporaryFile is in fact NamedTemporaryFile which accepts delete attribute.

    Tested on all these versions: 3.7.0 64 bit, 3.6.5 32 bit, 3.5.4 32 bit, 3.4.4 32 bit, 2.7.15 32 bit

    Proposed text to tempfile.TemporaryFile documentation:

    On non POSIX or Cygwin platforms TemporaryFile behaves exacly like NamedTemporaryFile including the fact that TemporaryFile accepts delete attribute and does not raise
    TypeError: TemporaryFile() got an unexpected keyword argument 'delete'.

    @dwich dwich mannequin added the 3.7 (EOL) end of life label Aug 18, 2018
    @dwich dwich mannequin assigned docspython Aug 18, 2018
    @dwich dwich mannequin added the docs Documentation in the Doc dir label Aug 18, 2018
    @terryjreedy
    Copy link
    Member

    3.4 and 3.5 only get security fixes.

    Anyone preparing PR should check that behavior and doc is same on master; I just assumed in setting Versions header.

    In the proposed text, it is not clear that 'non' applies to cygwin also. Instead: "On platforms that are neither Posix nor Cygwin, ..."
    Or "On non-Posix, non-Cygwin platforms, ..."

    @terryjreedy terryjreedy added the 3.8 only security fixes label Aug 25, 2018
    @iritkatriel
    Copy link
    Member

    The docs and the code are the same now. I would add just the first half of the suggested sentence:

    "On platforms that are neither Posix nor Cygwin, TemporaryFile behaves exactly like NamedTemporaryFile".

    @iritkatriel iritkatriel added easy 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes and removed 3.7 (EOL) end of life 3.8 only security fixes labels Jan 24, 2022
    @iritkatriel iritkatriel changed the title On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile [doc] On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile Jan 24, 2022
    @iritkatriel
    Copy link
    Member

    New changeset 53ecf9e by slateny in branch 'main':
    bpo-34429: Noted TemporaryFile behavior on non-Posix/non-Cygwin systems (GH-31547)
    53ecf9e

    @miss-islington
    Copy link
    Contributor

    New changeset 632a812 by Miss Islington (bot) in branch '3.10':
    bpo-34429: Noted TemporaryFile behavior on non-Posix/non-Cygwin systems (GH-31547)
    632a812

    @miss-islington
    Copy link
    Contributor

    New changeset b7f6e8e by Miss Islington (bot) in branch '3.9':
    bpo-34429: Noted TemporaryFile behavior on non-Posix/non-Cygwin systems (GH-31547)
    b7f6e8e

    @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
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants