Message294988
The following is an example of the problem, right?
>>> fd = os.open('stdout.txt', os.O_CREAT | os.O_WRONLY)
>>> os.dup2(fd, 1)
>>> print('spam')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [WinError 87] The parameter is incorrect
Code like this used to work, so possibly this needs to be addressed more generally. I have a couple ideas, but they're major changes. It's simpler to require code that pulls the rug out from under _WindowsConsoleIO to rebind sys.std*.
For a counterexample, PyOS_StdioReadline always checks for a console and falls back on the old my_fgets function for a non-console. For example:
>>> open('stdin.txt', 'w').write('x=42; os.dup2(oldfd, 0)\n')
24
>>> fd = os.open('stdin.txt', os.O_RDONLY)
>>> oldfd = os.dup(0); os.dup2(fd, 0)
>>> Breakpoint 0 hit
python36!my_fgets:
00000000`66e98318 488bc4 mov rax,rsp
0:000> g
>>> x
42 |
|
Date |
User |
Action |
Args |
2017-06-02 08:11:17 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower, Segev Finer |
2017-06-02 08:11:17 | eryksun | set | messageid: <1496391077.66.0.239111296724.issue30544@psf.upfronthosting.co.za> |
2017-06-02 08:11:17 | eryksun | link | issue30544 messages |
2017-06-02 08:11:16 | eryksun | create | |
|