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 belopolsky
Recipients belopolsky, christian.heimes, ncoghlan
Date 2008-02-10.22:57:14
SpamBayes Score 0.00116221
Marked as misclassified No
Message-id <>
Nick's comment made me think why NamedTemporaryFile can't simply 
subclass file and get properly working context manager's methods for 

It turned out that although file is subclassable, in its present form, 
it does not allow NamedTemporaryFile implementation for the following 

1. os.fdopen cannot create a subclass of file.

2. file.__exit__ does not call subclass' close method.

The attached patch fixes both issues and reimplements NamedTemporaryFile.

I understand that adding new functionality to file objects should be 
brought up on python-dev, but I would like to hear comments from the 
"nosy list" first.

The patch is proof-of-concept quality at the moment and may not work 
non-posix platforms.
Date User Action Args
2008-02-10 22:57:19belopolskysetspambayes_score: 0.00116221 -> 0.00116221
recipients: + belopolsky, ncoghlan, christian.heimes
2008-02-10 22:57:19belopolskysetspambayes_score: 0.00116221 -> 0.00116221
messageid: <>
2008-02-10 22:57:18belopolskylinkissue2021 messages
2008-02-10 22:57:17belopolskycreate