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.

Title: file,close() can fail assert on Windows in 2.7
Type: crash Stage: resolved
Components: Versions: Python 2.7
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, amaury.forgeotdarc, sbt
Priority: normal Keywords:

Created on 2012-09-10 14:16 by sbt, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg170188 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-09-10 14:16
With Python 2.7 on Windows the following crashes with an assertion:

    >>> import os
    [43042 refs]
    >>> f = open("foobar", "wb")
    [43048 refs]
    >>> os.close(f.fileno())
    [43048 refs]
    >>> f.close()
    <Failed assertion>

A box pops up with

    Program: C:\Repos\cpython-27\PCbuild\python_d.exe
    File: f:\dd\vctools\crt_bld\self_x86\crt\src\close.c
    Line: 48

    Expression: (_osfile(fh) & FOPEN)

Python 3.2 and 3.3 give IOError(EBADF, ...) as expected.

Compare #15261 and #15263.
msg170192 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-09-10 14:44
Is it also the case for other file operations?  Here is a list that may use a closed FILE object:
    print >>f, 'something'
msg170195 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-09-10 14:57
If buffering is off then they all fail the assertion except isatty().
msg366616 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2020-04-16 18:05
Python 2 is EOL.
Date User Action Args
2022-04-11 14:57:35adminsetgithub: 60108
2020-04-16 20:29:14benjamin.petersonsetstatus: open -> closed
resolution: wont fix
stage: needs patch -> resolved
2020-04-16 18:05:30ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg366616
2012-09-10 14:57:23sbtsetmessages: + msg170195
2012-09-10 14:44:07amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg170192
2012-09-10 14:16:38sbtcreate