Errno 9] Bad file descriptor

Tim Roberts timr at probo.com
Tue Jul 13 02:15:27 EDT 2010


joblack <johannes.black at gmail.com> wrote:
>
>I get sometimes a
>
>Errno 9 Bad file descriptor
>
>the code is too long to show it here but what are the circumstances
>this could happen? A web search showed nothing.
>
>I have especially the feeling Python 2.6 has some problems with
>Unicode ... and might not find the file. Is that possible?

You seem to be under the mistaken impression that we all have crystal balls
and are able to read your mind.  There is SO MUCH you haven't told us here.
Which platform?  Surely you can post SOME of the code around where the
error occurs.

For example, there is a bug in the Windows shell that will cause this error
if you try to read stdin when a Python script is called implicitly from a
command line:

  C:\tmp>type y.py
  import sys

  print sys.stdin.readlines()

  C:\tmp>y.py < y.py
  Traceback (most recent call last):
    File "C:\tmp\y.py", line 3, in <module>
      print sys.stdin.readlines()
  IOError: [Errno 9] Bad file descriptor

  C:\tmp>python y.py < y.py
  ['import sys\n', '\n', 'print sys.stdin.readlines()\n']

  C:\tmp>
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list