[Python-Dev] Re: NamedTemporaryFile and context managers

2021-04-08 Thread Ivan Pozdeev via Python-Dev
On 08.04.2021 23:31, Ethan Furman wrote: In issue14243 [1] there are two issues being tracked: - the difference in opening shared files between posix and Windows - the behavior of closing the underlying file in the middle of  NamedTemporaryFile's context management I'd like to address and get

[Python-Dev] Re: NamedTemporaryFile and context managers

2021-04-08 Thread Eric V. Smith
On 4/8/2021 4:43 PM, Antoine Pitrou wrote: On Thu, 8 Apr 2021 13:31:26 -0700 Ethan Furman wrote: ```python from tempfile import NamedTemporaryFile with NamedTemporaryFile() as fp: fp.write(b'some data') fp.close() # Windows workaround fp.open() data = fp.read() assert

[Python-Dev] Re: NamedTemporaryFile and context managers

2021-04-08 Thread Rob Cliffe via Python-Dev
Well this works: from tempfile import NamedTemporaryFile import os with NamedTemporaryFile(delete=False) as fp:   fp.write(b'some data')   fp.close()   with open(fp.name, 'rb') as fp2:     data = fp2.read()   os.remove(fp.name) assert data == b'some data' Of course it is

[Python-Dev] Re: Request for reviewers: pathlib improvements

2021-04-08 Thread Barney Gale
Thanks so much to everyone who discussed and reviewed the code and made suggestions. The bulk of these patches have now landed. For those following along at home, here’s a summary of the remaining PRs/bugs : - #18909 / bpo-39950

[Python-Dev] Re: NamedTemporaryFile and context managers

2021-04-08 Thread Ethan Furman
On 4/8/21 1:43 PM, Antoine Pitrou wrote: On Thu, 8 Apr 2021 13:31:26 -0700 Ethan Furman wrote: ```python from tempfile import NamedTemporaryFile with NamedTemporaryFile() as fp: fp.write(b'some data') fp.close() # Windows workaround fp.open() data = fp.read() assert

[Python-Dev] Re: NamedTemporaryFile and context managers

2021-04-08 Thread Ronald Oussoren via Python-Dev
> On 8 Apr 2021, at 22:31, Ethan Furman wrote: > > In issue14243 [1] there are two issues being tracked: > > - the difference in opening shared files between posix and Windows > - the behavior of closing the underlying file in the middle of > NamedTemporaryFile's context management > > I'd l

[Python-Dev] Re: NamedTemporaryFile and context managers

2021-04-08 Thread Antoine Pitrou
On Thu, 8 Apr 2021 13:31:26 -0700 Ethan Furman wrote: > > ```python > from tempfile import NamedTemporaryFile > > with NamedTemporaryFile() as fp: > fp.write(b'some data') > fp.close() # Windows workaround > fp.open() > data = fp.read() > > assert data == 'some_data' > ```

[Python-Dev] NamedTemporaryFile and context managers

2021-04-08 Thread Ethan Furman
In issue14243 [1] there are two issues being tracked: - the difference in opening shared files between posix and Windows - the behavior of closing the underlying file in the middle of NamedTemporaryFile's context management I'd like to address and get feedback on the context management issue.

[Python-Dev] Re: PEP 647 Accepted

2021-04-08 Thread Federico Salerno
I vaguely remember reading some discussion about Annotated and, for what little it's worth, I disagree with the consensus. For now all that comes to mind is either stuffing the information in docstrings (which would be kind of an involution, seeing as that was the way for annotating type befor

[Python-Dev] Re: Help to Resolve issues with Pull request 25220

2021-04-08 Thread Tony Flury via Python-Dev
Terry, Barney, I think I have done it right now - I have no idea what went wrong last time. I fixed it by recreating the changes from scratch, and scrupulously checking for the differences. Thanks for your help - although ultimately I didn't try to rebase. -- On 08/04/2021 01:32, Terry Ree

[Python-Dev] Re: How to attract developer attention to issue tracker items?

2021-04-08 Thread pjfarley3
Thanks Brett. I guess I will just have to wait and see. Peter From: Brett Cannon Sent: Wednesday, April 7, 2021 4:37 PM To: pjfarl...@earthlink.net Cc: python-dev Subject: Re: [Python-Dev] How to attract developer attention to issue tracker items? On Tue, Apr 6, 2021 at 11:22

[Python-Dev] Re: When we remove 'U' mode of open()?

2021-04-08 Thread Victor Stinner
That sounds reasonable ;-) Victor On Thu, Apr 8, 2021 at 3:02 AM Inada Naoki wrote: > > We are close to 3.10 beta and it is not ideal timing for removing. > So my proposal is: > > * Remove 'U' in fileinput, because it makes my task little simpler. > * Remove 'U' in other places in Python 3.11, a