New issue 222: Re-opening NamedTemporaryFile is not valid on Windows
https://bitbucket.org/blais/beancount/issues/222/re-opening-namedtemporaryfile-is-not-valid

Jeff Brantley:

Both test and production code are using `tempfile.NamedTemporaryFile`, which on 
non-Windows can be re-opened (by name) while the original handle is still open. 
For example, `beancount.utils.test_utils.docfile` decorator extracts a test's 
docstring, writes it to a file, and then---still holding the file open---passes 
the filename to the test, to be read by that test.

Searching the repo for NamedTemporaryFile turns up 10 files with "test" in the 
name, as well as `beancount.parser.lexer` and `beancount.utils.text_utils`.

It's unfortunate that this doesn't just work. Assuming all instances are in a 
`with` statement (not true, but perhaps that is a bug?), then it may be 
possible to workaround with a wrapper that passes `delete=False` and then 
manually deletes the file on `__exit__`. I'm not sure what flaws (if any) this 
may exhibit over the real thing.


-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/20180226055558.17740.84124%40celery-worker-107.ash1.bb-inf.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to