[issue15068] fileinput requires two EOF when reading stdin

2016-03-08 Thread Roundup Robot
Roundup Robot added the comment: New changeset 88d6742aa99a by Serhiy Storchaka in branch '2.7': Issue #15068: Avoid creating a reference loop in fileinput. https://hg.python.org/cpython/rev/88d6742aa99a New changeset a0de41b46aa6 by Serhiy Storchaka in branch '3.5': Issue #15068: Avoid creating

[issue15068] fileinput requires two EOF when reading stdin

2016-03-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Ah, thanks Martin. I forgot that assigning an attribute to a bound method creates a reference loop. This can be fixed without performance lost by using a clever trick. -- ___ Python tracker

[issue15068] fileinput requires two EOF when reading stdin

2016-03-08 Thread Martin Panter
Martin Panter added the comment: It seems this change is causing some (intermittent?) buildbot failures in 2.7: http://buildbot.python.org/all/builders/s390x%20RHEL%202.7/builds/273/steps/test/logs/stdio == FAIL: test_saveall (

[issue15068] fileinput requires two EOF when reading stdin

2016-03-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Committed in changesets 5fbd16326353 (2.7), 9ead3a6c5f81 (3.5), and fefedbaac640 (default). Due to SMTP failure there is no Roundup report. Warnings are not emitted in maintained releases. -- resolution: -> fixed stage: patch review -> resolved stat

[issue15068] fileinput requires two EOF when reading stdin

2016-02-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Ping. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue15068] fileinput requires two EOF when reading stdin

2015-12-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > It's more a question of whether the entire change is appropriate for 2.7. What is your answer? To me there is a bug and we can fix it. -- ___ Python tracker __

[issue15068] fileinput requires two EOF when reading stdin

2015-12-22 Thread Benjamin Peterson
Benjamin Peterson added the comment: That individually is probably okay. It's more a question of whether the entire change is appropriate for 2.7. Note PendingDeprecationWarning is fairly useless, since it's rarely enabled. On Sat, Dec 19, 2015, at 00:34, Serhiy Storchaka wrote: > > Serhiy Sto

[issue15068] fileinput requires two EOF when reading stdin

2015-12-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Benjamin, is it good to add PendingDeprecationWarning in 2.7? -- nosy: +benjamin.peterson versions: -Python 3.4 ___ Python tracker ___ __

[issue15068] fileinput requires two EOF when reading stdin

2015-12-07 Thread Kristján Valur Jónsson
Changes by Kristján Valur Jónsson : -- nosy: -kristjan.jonsson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue15068] fileinput requires two EOF when reading stdin

2015-12-03 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- versions: +Python 2.7 Added file: http://bugs.python.org/file41226/fileinput_no_buffer-2.7.patch ___ Python tracker ___ _

[issue15068] fileinput requires two EOF when reading stdin

2015-12-03 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file41225/fileinput_no_buffer.patch ___ Python tracker ___ ___ Python-bugs-li

[issue15068] fileinput requires two EOF when reading stdin

2015-12-03 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Removed file: http://bugs.python.org/file41224/fileinput_no_buffer.patch ___ Python tracker ___ ___ Python-bugs-

[issue15068] fileinput requires two EOF when reading stdin

2015-12-03 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue15068] fileinput requires two EOF when reading stdin

2015-12-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Using readlines() instead of readline() was added in 4dbbf322a9df for performance. But it looks that now this is not needed. Naive implementation with readline() is about 2 times slower, but with careful optimization we can achieve the same performance (or b

[issue15068] fileinput requires two EOF when reading stdin

2012-06-19 Thread Kristján Valur Jónsson
Changes by Kristján Valur Jónsson : -- Removed message: http://bugs.python.org/msg163150 ___ Python tracker ___ ___ Python-bugs-list m

[issue15068] fileinput requires two EOF when reading stdin

2012-06-19 Thread Kristján Valur Jónsson
Kristján Valur Jónsson added the comment: Thanks Antoine. I tested this in my virtualbox so something new must have happened... Anyway, the GIL code should not have changed from before, only moved about slightly. I´ll figure out what happened. -- nosy: +kristjan.jonsson __

[issue15068] fileinput requires two EOF when reading stdin

2012-06-16 Thread Florent Xicluna
Changes by Florent Xicluna : -- nosy: +flox ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Oh, it seems that the mail server again ate some lines of my examples. This is a bug in the e-mail gateway. You can lobby for a fix at http://psf.upfronthosting.co.za/roundup/meta/issue264 -- ___ Python tracker <

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > > > > qwert > > 'qwert\n' Oh, it seems that the mail server again ate some lines of my examples. > Well, did you try readline() or readlines()? Yes, it's my mistake, I used readline(). -- ___ Python tracker

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > But sys.stdin does not implement RawIOBase, it implements TextIOBase. sys.stdin.buffer.raw implements RawIOBase. -- ___ Python tracker ___

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > so the readlines function should always return at least as many bytes as > > its first parameter. Is this assumption wrong? > > qwert > 'qwert\n' > > You type five characters "qwert" end press . Python immediately > receives these six characters, and ret

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Forget other filelike objects. The FileInput class only works with actual > files, No. sys.stdin can be reassigned before using FileInput. And FileInput has openhook parameter (for read compressed files or get files from Web, for example). > so the readl

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le vendredi 15 juin 2012 à 14:41 +, Serhiy Storchaka a écrit : > >From io.RawIOBase.read docs: > > """ > Read up to n bytes from the object and return them. As a convenience, if > n is unspecified or -1, readall() is called. Otherwise, only one system > cal

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread R. David Murray
R. David Murray added the comment: The _pyio.py version of readlines does read until the count is equaled or exceeded. This could, however, be an implementation detail and not part of the spec. -- ___ Python tracker

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread R. David Murray
R. David Murray added the comment: So the real question is: does readlines block until the byte count is satisified? It might, but the docs for io.IOBase.readlines leave open the possibility that fewer lines will be read, and do not limit that to the EOF case. It's not clear, however, if th

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread R. David Murray
R. David Murray added the comment: fileinput should work (for some definition of work) for anything that can be opened by name using the open syscall on unix. That includes many more things than files. Named pipes are a particularly interesting example in this context. -- _

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Joey Geralnik
Joey Geralnik added the comment: Forget other filelike objects. The FileInput class only works with actual files, so the readlines function should always return at least as many bytes as its first parameter. Is this assumption wrong? -- ___ Python

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Joey Geralnik
Joey Geralnik added the comment: But this is calling the readlines function, which continually reads from the file until more bytes have been read than the specified argument. >From bz2.readlines: "size can be specified to control the number of lines read: no further lines will be read once t

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > The patch I've attached checks if the number of bytes read from the file is > less than the size of the buffer (which means that the file has ended). >From io.RawIOBase.read docs: """ Read up to n bytes from the object and return them. As a convenience,

[issue15068] fileinput requires two EOF when reading stdin

2012-06-15 Thread Joey Geralnik
Joey Geralnik added the comment: First off, I'm a complete noob looking at the python source code for the first time so forgive me if I've done something wrong. What if the length of the chunk is checked as well? The following code works fine: import sys while True: chunk = sys.stdin.rea

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: It is unlikely to be solvable at the Python level. Witness the raw stream's behaviour (in Python 3): >>> sys.stdin.buffer.raw.read(1000) If you type a letter followed by ^D (Linux) or ^Z (Windows), this returns immediately: >>> sys.stdin.buffer.raw.read(100

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that in the rare cases, when stdio ends immediately on the limit of the read buffer, just one EOF is sufficient. In particular for read(1) one EOF is sufficient always, and for read(2) it is sufficient in about half of the cases. -- __

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread R. David Murray
R. David Murray added the comment: That makes sense. It is a consequence of (a) buffered input and (b) the fact that EOF on stdin doesn't really close it. (And by interactive here I don't just mean Python's interactive prompt, but also the shell). By default fileinput uses readlines with a

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is not only the fileinput. The same effect can be achieved by simple idiomatic code: import sys while True: chunk = sys.stdin.read(1000) if not chunk: break # process -- nosy: +storchaka __

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread R. David Murray
R. David Murray added the comment: I don't know how the EOF character works, but I wouldn't be surprised if it had to be on a line by itself to mean EOF. If the double EOF is required when not at the interactive prompt, then there could be a long standing bug in fileinput's logic where it is

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Zachary Ware
Zachary Ware added the comment: I just tested on Python 3.2, and found something interesting; it seems a ^Z character on a line that has other input read in as a character. Also, other input after an EOF on its own means you still have to do two more EOFs to end. Python 3.2.3 (default, Apr 1

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Jason R. Coombs
Jason R. Coombs added the comment: FWIW, I encountered the double-EOF behavior when invoking fileinput.input from a script running non-interactively (except of course for the input() call). -- ___ Python tracker

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread R. David Murray
R. David Murray added the comment: Frankly I'm surprised it works at all, since fileinput.input() will by default read from stdin, and stdin is in turn being read by the python prompt. I just checked 2.5 on linux, and the same situation exists there (two ^Ds are required to end the input()).

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Jason R. Coombs
Jason R. Coombs added the comment: I observed if I send EOF as the first character, it honors it immediately and doesn't require a second EOF. -- ___ Python tracker ___ ___

[issue15068] fileinput requires two EOF when reading stdin

2012-06-14 Thread Jason R. Coombs
New submission from Jason R. Coombs : I found that fileinput.input() requires two EOF characters to stop reading input on Python 2.7.3 on Windows and Ubuntu: PS C:\Users\jaraco> python Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32 >>> import fileinput >>> l