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.

Author sbt
Recipients brian.curtin, dabrahams, davide.rizzo, dlenski, eric.araujo, eric.smith, jaraco, ncoghlan, pitrou, r.david.murray, sbt, tim.golden
Date 2012-07-01.23:45:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I checked the source in

   c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/crt/src/open.c

and it seems that on Windows open() is more or less implemented as a wrapper of sopen(..., ..., SH_DENYNO, ...).

So the only reason that trying to reopen a NamedTemporaryFile fails on Windows is because when we reopen we need to use O_TEMPORARY.

The following works for unmodified python:

  import os, tempfile

  DATA = b"hello bob"

  def temp_opener(name, flag, mode=0o777):
      return, flag | os.O_TEMPORARY, mode)

  with tempfile.NamedTemporaryFile() as f:
      with open(, "rb", opener=temp_opener) as f:
          assert == DATA

  assert not os.path.exists(

So maybe we should just define tempfile.opener().
Date User Action Args
2012-07-01 23:45:49sbtsetrecipients: + sbt, jaraco, ncoghlan, pitrou, eric.smith, tim.golden, eric.araujo, r.david.murray, brian.curtin, dabrahams, davide.rizzo, dlenski
2012-07-01 23:45:48sbtsetmessageid: <>
2012-07-01 23:45:48sbtlinkissue14243 messages
2012-07-01 23:45:48sbtcreate