[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Steve Dower

Changes by Steve Dower :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Steve Dower

Steve Dower added the comment:


New changeset c63ae1122f84d4188ffadfd1454902093eb10be1 by Steve Dower in branch 
'3.6':
bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when 
WriteConsoleW fails (#1912) (#1925)
https://github.com/python/cpython/commit/c63ae1122f84d4188ffadfd1454902093eb10be1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Steve Dower

Changes by Steve Dower :


--
pull_requests: +2005

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Segev Finer

Changes by Segev Finer :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Steve Dower

Steve Dower added the comment:

Yeah, make it a separate issue.

This PR fixes an obvious error that we should just fix, so I've merged it. (I 
might get to the backport today, but if someone else submits it then I'll 
merge.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Steve Dower

Steve Dower added the comment:


New changeset 523776c3419f6795e78173d53c10e35ec4eed48d by Steve Dower (Segev 
Finer) in branch 'master':
bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when 
WriteConsoleW fails (#1912)
https://github.com/python/cpython/commit/523776c3419f6795e78173d53c10e35ec4eed48d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Segev Finer

Segev Finer added the comment:

We might want to open a separate issue for the FD redirection issue since this 
one was really about the _io._WindowsConsoleIO.write GetLastError() issue.

Also see https://github.com/pytest-dev/pytest/pull/2462 where I discuss this 
more.

Still not sure why it's random in Pytest. I can only guess it's due to another 
console handle getting opened with the same number or something.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-02 Thread Eryk Sun

Eryk Sun added the comment:

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 "", line 1, in 
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:
`66e98318 488bc4  mov rax,rsp
0:000> g
>>> x
42

--
keywords: +3.2regression
nosy: +eryksun

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-01 Thread Segev Finer

Changes by Segev Finer :


--
pull_requests: +1992

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30544] _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

2017-06-01 Thread Segev Finer

New submission from Segev Finer:

Found due to this: https://github.com/pytest-dev/py/issues/103

I'm going to submit a PR.

--
components: IO, Windows
messages: 294975
nosy: Segev Finer, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW 
fails
versions: Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com