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

Mailing List Archive: Python: Dev

Help to fix this bug http://bugs.python.org/issue15068

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


gmspro at yahoo

Jun 19, 2012, 4:39 AM

Post #1 of 4 (134 views)
Permalink
Help to fix this bug http://bugs.python.org/issue15068

Hi,

I'm working on this bug to fix it. http://bugs.python.org/issue15068

>>> from sys import stdin
>>> str=stdin.read()
hello
hello world
CTRL+D
CTRL+D

Can anyone tell me where is stdin.read() function defined?
Or where is sys.stdin defined?
Or which function is called for str=stdin.read() ?

Thanks


eliben at gmail

Jun 19, 2012, 5:01 AM

Post #2 of 4 (130 views)
Permalink
Re: Help to fix this bug http://bugs.python.org/issue15068 [In reply to]

It depends on the Python version. In 3.3, for example, look into
Modules/_io/fileio.c

Eli



On Tue, Jun 19, 2012 at 2:39 PM, gmspro <gmspro [at] yahoo> wrote:

> Hi,
>
> I'm working on this bug to fix it. http://bugs.python.org/issue15068
>
> >>> from sys import stdin
> >>> str=stdin.read()
> hello
> hello world
> CTRL+D
> CTRL+D
>
> Can anyone tell me where is stdin.read() function defined?
> Or where is sys.stdin defined?
> Or which function is called for str=stdin.read() ?
>
> Thanks
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev [at] python
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/eliben%40gmail.com
>
>


solipsis at pitrou

Jun 19, 2012, 5:13 AM

Post #3 of 4 (130 views)
Permalink
Re: Help to fix this bug http://bugs.python.org/issue15068 [In reply to]

Hi,

On Tue, 19 Jun 2012 04:39:30 -0700 (PDT)
gmspro <gmspro [at] yahoo> wrote:
> Hi,
>
> I'm working on this bug to fix it. http://bugs.python.org/issue15068

I'm not sure why you think this is fixable, given the comments on the
tracker. What is your plan?

> >>> from sys import stdin
> >>> str=stdin.read()
> hello
> hello world
> CTRL+D
> CTRL+D
>
> Can anyone tell me where is stdin.read() function defined?
> Or where is sys.stdin defined?

Can I suggest you try to investigate it a bit yourself:

>>> sys.stdin
<_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>

So it's a TextIOWrapper from the _io module (which is really the
implementation of the io module). You'll find its source in
Modules/_io. TextIOWrapper objects are defined in Modules/_io/textio.c.
But as you know, they wrap buffered I/O objects, which are defined in
Modules/_io/bufferedio.c. In sys.stdin's case, the buffered I/O object
wraps a raw FileIO object, defined in Modules/_io/fileio.c:

>>> sys.stdin.buffer
<_io.BufferedReader name='<stdin>'>
>>> sys.stdin.buffer.raw
<_io.FileIO name='<stdin>' mode='rb'>


Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


storchaka at gmail

Jun 19, 2012, 7:28 AM

Post #4 of 4 (126 views)
Permalink
Re: Help to fix this bug http://bugs.python.org/issue15068 [In reply to]

On 19.06.12 15:13, Antoine Pitrou wrote:
>>>> sys.stdin
> <_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>
>
> So it's a TextIOWrapper from the _io module (which is really the
> implementation of the io module). You'll find its source in
> Modules/_io. TextIOWrapper objects are defined in Modules/_io/textio.c.
> But as you know, they wrap buffered I/O objects, which are defined in
> Modules/_io/bufferedio.c. In sys.stdin's case, the buffered I/O object
> wraps a raw FileIO object, defined in Modules/_io/fileio.c:
>
>>>> sys.stdin.buffer
> <_io.BufferedReader name='<stdin>'>
>>>> sys.stdin.buffer.raw
> <_io.FileIO name='<stdin>' mode='rb'>

And don't forget about _pyio module.

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev 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.