[Tutor] Re: Exceptions vs error codes

Kent Johnson kent_johnson at skillsoft.com
Fri Aug 20 13:06:17 CEST 2004


K&R second edition (the ANSI C version, published in 1988) includes 
perror(), errno and strerror().

Kent

At 11:40 PM 8/19/2004 -0700, Danny Yoo wrote:
>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.
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list