[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2014-05-25 Thread Марк Коренберг
Марк Коренберг added the comment: Is issue 21579 fixed in that bug? too many letters..sorry... -- nosy: +mmarkk ___ Python tracker ___ ___

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2014-04-16 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- title: tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variablwe -> tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable ___ Pyth

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- stage: commit review -> committed/rejected versions: -Python 2.7 ___ Python tracker ___ ___ Python-bug

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Fixed in 3.3 and 3.4. I think 2.7 is irrelevant at this point. -- resolution: -> fixed status: open -> closed ___ Python tracker ___ __

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Roundup Robot
Roundup Robot added the comment: New changeset f3b7a76fb778 by Antoine Pitrou in branch '3.3': Issue #18879: When a method is looked up on a temporary file, avoid closing the file before the method is possibly called. http://hg.python.org/cpython/rev/f3b7a76fb778 New changeset d68ab2eb7a77 by A

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM. Thank you Antoine. -- assignee: serhiy.storchaka -> pitrou stage: patch review -> commit review ___ Python tracker ___ _

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Antoine Pitrou
Changes by Antoine Pitrou : Added file: http://bugs.python.org/file33252/tempfile_lifetime.patch ___ Python tracker ___ ___ Python-bugs-list m

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Oops, removed two debug lines. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Antoine Pitrou
Changes by Antoine Pitrou : Removed file: http://bugs.python.org/file33250/tempfile_lifetime.patch ___ Python tracker ___ ___ Python-bugs-list

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here is a proper patch (for 3.3). Untested under Windows, but should work. -- nosy: +pitrou Added file: http://bugs.python.org/file33250/tempfile_lifetime.patch ___ Python tracker

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Unfortunately last patch causes resource leak on 3.3+. $ ./python -Wall -m test.regrtest test_tempfile [1/1] test_tempfile 1 test OK. sys:1: ResourceWarning: gc: 5 uncollectable objects at shutdown; use gc.set_debug(gc.DEBUG_UNCOLLECTABLE) to list them -

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is fixed Jakub's patch. -- assignee: -> serhiy.storchaka Added file: http://bugs.python.org/file33153/tempfile_wrap_methods.patch ___ Python tracker ___

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-12-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Jakub's patch has a bug: >>> import tempfile >>> f = tempfile.NamedTemporaryFile(dir=".",delete=False) >>> write = f.write >>> write >>> write2 = f.write >>> write2 >>> del f >>> write(b'foo') 3 >>> del write >>> write2(b'bar') Traceback (most recent call la

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-11-29 Thread Martin Panter
Changes by Martin Panter : -- nosy: +vadmium ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-11-29 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-11-29 Thread Zdeněk Pavlas
Zdeněk Pavlas added the comment: Hit this issue too, but with the "read" method. I think that providing a custom read() and write() methods in the wrapper class that override __getattr__ is a sufficient solution. These are the attributes most likely to be used as the "tail". -- nosy:

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > The monkey-patched version breaks the auto-close on __del__ feature: Files were closed. Just with a warning. I consider this as an enhancement. If you don't close file explicitly you will get a leak on non-refcounted Python implementations. It's true for b

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Meador Inge
Meador Inge added the comment: The monkey-patched version breaks the auto-close on __del__ feature: [meadori@li589-207 cpython]$ ./python Python 3.4.0a1+ (default:c41c68a18bb6, Sep 5 2013, 17:51:03) [GCC 4.7.2 20120921 (Red Hat 4.7.2-2)] on linux Type "help", "copyright", "credits" or "licens

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Meador Inge
Meador Inge added the comment: I was experimenting with something similar to what Jakub has. Rebinding the call the the wrapper seems like a simple and clean way to do it. Although, I wasn't absolutely sure whether this approach covers all cases. -- _

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yet one way is just remove __del__() and monkey-patch underlied file. -- Added file: http://bugs.python.org/file31603/tempfile_simplify.patch ___ Python tracker _

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-05 Thread Jakub Stasiak
Jakub Stasiak added the comment: I don't see an obvious way of solving that. One thing I could think of is creating a wrapper for file method being returned from __getattr__ that holds reference to _TemporaryFileWrapper instance until the method gets called, please find a patch attached.

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-09-04 Thread jort bloem
jort bloem added the comment: I am only new to Python, but... Having looked at the code, I am surprised that the _TemporaryFileWrapper is not a subclass of "file". Surely that would be the "python" way, and would solve this problem, too? __getattr__ would no longer be needed. The opening of th

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread Meador Inge
Meador Inge added the comment: 'tempfile.NamedTemporaryFile' returns an instance of '_TemporaryFileWrapper' that wraps the created file object. The wrapper object implements '__getattr__' and we end up with a situation like the following simplified example where the wrapper gets destroyed bef

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread R. David Murray
Changes by R. David Murray : -- nosy: +r.david.murray ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread Meador Inge
Meador Inge added the comment: Confirmed in trunk: >>> tempfile.NamedTemporaryFile(dir=".",delete=False).write(b"hello") Traceback (most recent call last): File "", line 1, in ValueError: write to closed file -- nosy: +meador.inge ___ Python track

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread Nick Coghlan
Nick Coghlan added the comment: The method call should keep the file object alive until it completes (due to the self reference). What behaviour prompted the conclusion that it is being closed early? If the symptom is that the data isn't being written to disk, we may have a missing flush() ca

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread jort bloem
jort bloem added the comment: Sorry, my python-foo is not quite up to providing a solution. A partial solution would be for the file not to be closed at NamedTemporaryFile destruction, if delete==False. If delete==True, then there is no point writing to a file (though it shouldn't raise an exc

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- components: +IO, Library (Lib) nosy: +georg.brandl, ncoghlan, serhiy.storchaka versions: +Python 3.3, Python 3.4 -Python 2.6 ___ Python tracker _

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue18879] tempfile.NamedTemporaryFile can close the file too early, if not assigning to a variable

2013-08-29 Thread jort bloem
New submission from jort bloem: Issue occurs in the following code: tempfile.NamedTemporaryFile(dir=".",delete=False).write("hello") The NamedTemporaryFile is deleted before the write is complete; deleting the object closes the file, so the write fails. -- messages: 196485 nosy: jort.