[issue24073] sys.stdin.mode can not give the right mode and os.fdopen does not check argument

2015-04-29 Thread Ned Deily
Ned Deily added the comment: I think the issue here is that you are expecting the mode attribute of a file object (or io.* object in Py3) to reflect the readable and writeable access mode of the underlying file descriptor (for POSIX-like systems). But, as noted in the documentation for the

[issue24073] sys.stdin.mode can not give the right mode and os.fdopen does not check argument

2015-04-29 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks for your reply Ned and it does solve my puzzle. It's my fault to misunderstand the attribute and make noise here. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24073

[issue24073] sys.stdin.mode can not give the right mode and os.fdopen does not check argument

2015-04-28 Thread Xiang Zhang
New submission from Xiang Zhang: The problem is what the title tells and can be produced by the snippet below. import sys import os sys.stdout.write(%s\n % sys.stdin.mode) sys.stdout.flush() f = os.fdopen(sys.stdin.fileno(), r) f.write() f.flush() f.read() f.close() When running this