tempfile.mkstemp and os.fdopen

draghuram at gmail.com draghuram at gmail.com
Tue Aug 28 14:40:45 EDT 2007


On Aug 28, 1:55 pm, billiejoex <gne... at gmail.com> wrote:

> In conjunction I used os.fdopen() to get a wrapper around file
> properties (write & read methods, and so on...) but 'name' attribute
> does not contain the correct file name. Why?
>
> >>> import os
> >>> import tempfile
> >>> fileno, name = tempfile.mkstemp(prefix='ftpd.', dir=os.getcwd())
> >>> fd = os.fdopen(fileno, 'wb')
> >>> fd.name
>
> <fdopen>
>
> Moreover, I'd like to know if I'm doing fine. Does this approach avoid
> race conditions or other types of security problems?
>
> Thanks in advance

There seems to be a feature request for this:

http://bugs.python.org/issue1625576







More information about the Python-list mailing list