Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue15318] IDLE - sys.stdin is writeable

 

 

First page Previous page 1 2 Next page Last page  View All Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 10, 2012, 7:13 AM

Post #1 of 31 (933 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable

New submission from Roger Serwy <roger.serwy [at] gmail>:

This is a follow-up to issue13532 which fixed problems with IDLE's sys.stdout and sys.stderr implementation.

Presently, sys.stdin has a write method, but does not raise "io.UnsupportedOperation: not writable" when passed a string. Instead, it writes to the IDLE shell.

----------
components: IDLE
messages: 165190
nosy: serwy, storchaka, terry.reedy
priority: low
severity: normal
status: open
title: IDLE - sys.stdin is writeable
type: behavior
versions: Python 2.7, Python 3.3

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 10, 2012, 6:25 PM

Post #2 of 31 (921 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Terry J. Reedy <tjreedy [at] udel> added the comment:

To me, this is part of #15319. sys.stdin is broken in being writable but not readable. Unwrapping is just the first, trivial step to fixing it. So I think we should close this in favor of the other.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 10, 2012, 6:42 PM

Post #3 of 31 (919 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Roger Serwy <roger.serwy [at] gmail> added the comment:

I agree. I'll close it.

----------
resolution: -> duplicate
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 10, 2012, 6:43 PM

Post #4 of 31 (921 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Changes by Roger Serwy <roger.serwy [at] gmail>:


----------
superseder: -> IDLE - input() is broken.

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 10, 2012, 11:35 PM

Post #5 of 31 (925 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

It's *clearly* not a duplicate. While #15319 is fixed, this issue remains - so it can't possibly be a duplicate.

----------
nosy: +loewis
resolution: duplicate ->
superseder: IDLE - readline, isatty, and input broken ->

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 10, 2012, 11:50 PM

Post #6 of 31 (919 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Changes by Martin v. Löwis <martin [at] v>:


----------
status: closed -> open

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 12:24 AM

Post #7 of 31 (926 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

I propose the attached patch to block write() calls.

----------
keywords: +patch
Added file: http://bugs.python.org/file26350/blockwrite.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 12:38 AM

Post #8 of 31 (924 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

Revised

----------
Added file: http://bugs.python.org/file26351/blockwrite.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 2:13 AM

Post #9 of 31 (925 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

sys.std* streams have many other issues.

>>> sys.stdin.readable()
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
sys.stdin.readable()
AttributeError: readable
>>> sys.stdout.writable()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
sys.stdout.writable()
AttributeError: writable
>>> sys.stdout.newlines
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
sys.stdout.newlines
AttributeError: newlines
>>> sys.stdin.read(1)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
sys.stdin.read(1)
AttributeError: read

And some other.

Here is a patch that fixes almost all IDLE sys.std* issues.

----------
Added file: http://bugs.python.org/file26353/idle_stdstreams-2.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 2:35 AM

Post #10 of 31 (921 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

Added getvar method to PyShell.console.

----------
Added file: http://bugs.python.org/file26354/idle_stdstreams-3.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
Attachments: idle_stdstreams-3.patch (5.64 KB)


report at bugs

Jul 11, 2012, 2:51 AM

Post #11 of 31 (917 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

Serhiy: can you please explicitly list what issues your patch fixes?

I can think of many *more* issues that your patch doesn't fix, e.g. sys.stdin.read(sys) and sys.stdout.read().

I'm quite opposed to monkey-patching, so I won't commit any patch that involves monkey-patching (i.e. _checked_text_writer). I'm also unsure what problem this change to monkey-patching solves: I believe the current code is fine in this respect as it stands.

Before you grow the patch to add many more lines of code, please try to stick to the "one issue at a time" principle. As a guideline: if you need to write additional lines of code, it's a separate issue.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 3:10 AM

Post #12 of 31 (923 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

As an additional note: the change to monkey-patching breaks the test

isinstance(sys.stdout, io.TextIOBase)

which currently succeeds.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 4:16 AM

Post #13 of 31 (926 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> Serhiy: can you please explicitly list what issues your patch fixes?

issue12967. And sys.std* in IDLE lacks other common sys.std* methods and
attributes.

> I can think of many *more* issues that your patch doesn't fix, e.g. sys.stdin.read(sys) and sys.stdout.read().

sys.stdin.read(sys) and sys.stdout.read() should not work.

> I'm quite opposed to monkey-patching, so I won't commit any patch that involves monkey-patching (i.e. _checked_text_writer). I'm also unsure what problem this change to monkey-patching solves: I believe the current code is fine in this respect as it stands.

I introduced _checked_text_writer, because the implementation of
_RPCFile was broken (I wrote this patch last evening and debug it this
morning). In addition, _RPCFile is a wrapper around RPCFile, which
itself is a wrapper. There are too many layers for me. If you are sure
that the current implementation of _RPCFile is correct, it is not
necessary.

> Before you grow the patch to add many more lines of code, please try to stick to the "one issue at a time" principle.

In IDLE sys.std* bad mimic text streams -- this is one issue.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 4:23 AM

Post #14 of 31 (922 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> As an additional note: the change to monkey-patching breaks the test
>
> isinstance(sys.stdout, io.TextIOBase)
>
> which currently succeeds.

Agree, this is a regression. However isinstance(sys.stdout,
io.TextIOBase) is False now in no-subprocess mode. This should be fixed
also.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 7:58 AM

Post #15 of 31 (921 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

issue9290 also has relation to this.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 8:00 AM

Post #16 of 31 (920 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

issue7163 is another PseudoFile-related issue.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 12:51 PM

Post #17 of 31 (922 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

"implements textio badly" is *not* a well-defined issue.

First it is a personal judgement: some think it's really bad, some think it's quite ok.

More importantly, such issue has no clear success criterion: how do we know we are done - can we hope to EVER close such an issue? No, because somebody might still find bad behavior. An issue absolutely needs anobjective test to determine whether it is resolved, and to reproduce it, this is not negotiable. "it behaves badly" provides no test.

In any case,*this* issue is about sys.stdin being writable.

Any objection to checking in my patch?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 1:32 PM

Post #18 of 31 (926 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> In any case,*this* issue is about sys.stdin being writable.

I already got confused with all these closing/reopening/renaming of
issues and floating code. Should I open my own issue even if it
duplicates and supersedes some other?

> Any objection to checking in my patch?

It does not fixes the issue. sys.stdin.writelines does not raise
exception.

Inheritance input file from output file looks very strange.
_RPCInputFile unnecessary, if redirect stdin not on PyShell self, but on
PyShell.stdin.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 2:29 PM

Post #19 of 31 (923 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Changes by Martin v. Löwis <martin [at] v>:


Added file: http://bugs.python.org/file26360/blockfile-3.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 2:30 PM

Post #20 of 31 (924 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Changes by Martin v. Löwis <martin [at] v>:


Removed file: http://bugs.python.org/file26360/blockfile-3.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 2:32 PM

Post #21 of 31 (919 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Changes by Martin v. Löwis <martin [at] v>:


Added file: http://bugs.python.org/file26361/blockfile-3.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 2:34 PM

Post #22 of 31 (927 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

> I already got confused with all these closing/reopening/renaming of
> issues and floating code. Should I open my own issue even if it
> duplicates and supersedes some other?

I personally think it would be best if these issues where closed
*first*, and only then you submit a patch to fix any remaining issues.

>> Any objection to checking in my patch?
>
> It does not fixes the issue. sys.stdin.writelines does not raise
> exception.

Ah. See blockfiles-3.diff then.

> Inheritance input file from output file looks very strange.

Where do you see that? In my patch, _RPCInputFile inherits from
_RPCFile, which is neither output nor input. Instead, _RPCOutputFile
also inherits from _RPCFile.

> _RPCInputFile unnecessary, if redirect stdin not on PyShell self, but on
> PyShell.stdin.

It is necessary, as rpc will not communicate the exceptions properly.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 11, 2012, 5:33 PM

Post #23 of 31 (924 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Roger Serwy <roger.serwy [at] gmail> added the comment:

I tested blockfile-3.diff against the latest code in the repository.

sys.stdin.write returns the wrong error message when passed a non-string. Presently it returns io.UnsupportedOperation instead of TypeError: must be str, not ...

The attached blockfile-4.diff incorporates blockfile-3 and creates a decorator in _RPCFile to ensure the argument is a string and applies it to the _RPCInputFile and _RPCOutputFile write methods.

A simpler alternative would be duplicating the string check code in _RPCInputFile before the raise statement.

----------
Added file: http://bugs.python.org/file26362/blockfile-4.diff

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 12, 2012, 2:13 AM

Post #24 of 31 (891 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> Ah. See blockfiles-3.diff then.

Well, I have no objections. Patch fixes this issue.

> Where do you see that? In my patch, _RPCInputFile inherits from
> _RPCFile, which is neither output nor input. Instead, _RPCOutputFile
> also inherits from _RPCFile.

I made a mistake. I mean PseudoInputFile, but it just monkey-patched.

> > _RPCInputFile unnecessary, if redirect stdin not on PyShell self, but on
> > PyShell.stdin.
> It is necessary, as rpc will not communicate the exceptions properly.

Yes, this is yet another issue. Rpc not communicates properly only
OSError. Remove "except socket.error: raise" in SocketIO.localcall in
Lib/idlelib/rpc.py and io.UnsupportedOperation will transparently
transfered.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 12, 2012, 2:13 AM

Post #25 of 31 (900 views)
Permalink
[issue15318] IDLE - sys.stdin is writeable [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> sys.stdin.write returns the wrong error message when passed a non-string. Presently it returns io.UnsupportedOperation instead of TypeError: must be str, not ...

It's not a bug. sys.stdin.write raises io.UnsupportedOperation in
standard interpreter.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

First page Previous page 1 2 Next page Last page  View All Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.