posix.error is a tuple, not an object or a string as docs say

Ben Gertzfield che at debian.org
Tue Aug 10 15:12:43 EDT 1999


>>>>> "Michael" == Michael P Reilly <arcege at shore.net> writes:

    Michael> The long and short of this is that you can use it like a
    Michael> tuple if more than one argument was given, and as the
    Michael> object otherwise.

    Michael> For some of your own reassurance, print the type of
    Michael> "error" in the except clause.

Right, but my problem is that I can't use it as an object as the
documentation says..

Python 1.5.1 (#1, Dec 17 1998, 20:58:15)  [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> try:
...     input = os.fdopen(42)
... except os.error, error:
...     print error.errno
...     print error.strerror
... 
Traceback (innermost last):
  File "<stdin>", line 4, in ?
AttributeError: errno

Yet the documentation says:

"When exceptions are classes, this exception carries two attributes,
errno and strerror. The first holds the value of the C errno variable,
and the latter holds the corresponding error message from strerror()."

So something else is a bit wacky, no?

-- 
Brought to you by the letters C and H and the number 11.
"Ha ha! I have evaded you with the aid of these pasty white mints!"
Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/




More information about the Python-list mailing list