[Tutor] Re: Exceptions vs error codes

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Aug 20 08:40:10 CEST 2004



On Thu, 19 Aug 2004, Alan Gauld wrote:

> I thought perror was a Unix thing? It doesn't work under Windows, VMS
> etc? But I've just tried it on XP and....it works!


Hi Alan,


Ah, I didn't think about that!  I've always thought that perror() was
standard; I can't imagine life without it.  *grin* Let me check
something...  Here's what the man page on OS X says about perror()'s
history:


###
STANDARDS
     The perror() and strerror() functions conform to ISO/IEC 9899:1999
     (``ISO C99'').  The strerror_r() function conforms to IEEE Std
     1003.1-2001 (``POSIX.1'').

HISTORY
     The strerror() and perror() functions first appeared in 4.4BSD.  The
     strerror_r() function was implemented in FreeBSD 4.4 by Wes Peters
     <wes at FreeBSD.org>.
###

Wow.  Ok, so it looks like perror() was incorporated into Standard C, so
that's probably why it works on XP now.  But you're right: not all C
systems have had it.

> I've used perror for years on Unix but for some reason believed it
> wasn't part of the C library but Unix only.
>
> Between curses, getch and perror I'm not having a good week! :-)

No, no, I should be apologizing.  I was wrong about the history there.



By the way, though, it looks like the patch did get in, after all!

https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1011822&group_id=5470
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/main.c?r1=1.82&r2=1.83

Good closure on the whole episode.  *grin* The next version of Python
should give a better error message when a mistyped file is passed in.
Martin Loewis extended the patch's behavior to account for systems without
the strerror() function.



More information about the Tutor mailing list