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

Mailing List Archive: Python: Bugs

[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1

 

 

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


report at bugs

Oct 29, 2009, 10:15 PM

Post #1 of 6 (367 views)
Permalink
[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1

New submission from Peter Gibson <petehere [at] gmail>:

subprocess.Popen.stdout.flush() fails on OS-X 10.6.1 under the bundled
Python 2.6.1 and 2.6.3 from Macports.

>>> from subprocess import Popen, PIPE
>>> p = Popen('cat', stdin=PIPE, stdout=PIPE)
>>> p.stdout.flush()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 9] Bad file descriptor

However it works on Python 2.6.2 on Linux.

----------
components: Library (Lib)
messages: 94694
nosy: petegibson
severity: normal
status: open
title: subprocess.Popen.stdout.flush fails os OS-X 10.6.1
type: crash
versions: Python 2.6

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7240>
_______________________________________
_______________________________________________
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

Oct 29, 2009, 11:23 PM

Post #2 of 6 (347 views)
Permalink
[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1 [In reply to]

Philip Jenvey <pjenvey [at] underboss> added the comment:

Why are you flushing stdout? It's read-only and flush is for writing. This
behavior is dependent on the underlying platform's fflush, which really
*should* be raising EBADF when fflushing a read only file, anyway

----------
nosy: +pjenvey

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7240>
_______________________________________
_______________________________________________
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

Oct 29, 2009, 11:26 PM

Post #3 of 6 (341 views)
Permalink
[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1 [In reply to]

Ned Deily <nad [at] acm> added the comment:

Philip is correct:

>>> p.stdout.flush()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 9] Bad file descriptor
>>> p.stdout
<open file '<fdopen>', mode 'rb' at 0x100527470>

You'll get the same error on OS X (at least as far back as Python 2.3.5
on OS X 10.4) if you try to flush a disk read-only file:

>>> f = open('a.txt', 'rb')
>>> f.flush()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 9] Bad file descriptor

Note, both the OS X and Linux 2.6 fflush(3) man pages clearly state that
EBADF can be returned if the stream is not open for writing but there
seems to be a difference in behavior between the two OS's.

As this doesn't seem to be a new issue and can easily be avoided (don't
flush a read-only file), I suggest closing the issue.

----------
assignee: -> ronaldoussoren
components: +Macintosh
nosy: +ned.deily, ronaldoussoren

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7240>
_______________________________________
_______________________________________________
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

Oct 30, 2009, 6:42 AM

Post #4 of 6 (340 views)
Permalink
[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1 [In reply to]

Peter Gibson <petehere [at] gmail> added the comment:

Not my code, but as it's using a pipe to communicate with another
process, I assume that the flush call is intended to discard any
unwanted output prior to sending a command and processing the result.

Is there another way to achieve the same effect, such as reading and
remaining characters in the buffer?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7240>
_______________________________________
_______________________________________________
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

Nov 2, 2009, 11:52 PM

Post #5 of 6 (306 views)
Permalink
[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1 [In reply to]

Ronald Oussoren <ronaldoussoren [at] mac> added the comment:

I don't think so. stdio on OSX has a fdiscard function, but that's not
exposed to Python.

I tend to explicitly synchronize on prompts when communicating with an
interactive program over a pipe. That is, read until you found the prompt,
then send a command, then read again until getting to the prompt, ...

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7240>
_______________________________________
_______________________________________________
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

Nov 3, 2009, 12:57 PM

Post #6 of 6 (293 views)
Permalink
[issue7240] subprocess.Popen.stdout.flush fails os OS-X 10.6.1 [In reply to]

Changes by Philip Jenvey <pjenvey [at] underboss>:


----------
resolution: -> invalid
status: open -> closed

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

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.