Re: [Python-Dev] Symbolic errno values in error messages

2008-05-19 Thread Georg Brandl
Yannick Gingras schrieb: "Alexandre Vassalotti" <[EMAIL PROTECTED]> writes: So now I am not sure what OP is proposing. Do you want to replace 21 with EISDIR in the above? Yes, that's what I had in mind. Then, check out EnvironmentError_str in Objects/exceptions.c. You should be able impor

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-19 Thread Yannick Gingras
"Guido van Rossum" <[EMAIL PROTECTED]> writes: > Have you considered whether this works on all platforms? (E.g. > Windows, or embedded non-Unix-based.) Yes but I guess I didn't comment it properly. The line printed_errno = errno_str ? errno_str : self->myerrno; ensures that we gracefully fal

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-19 Thread Yannick Gingras
"Alexandre Vassalotti" <[EMAIL PROTECTED]> writes: >>> So now I am not sure what OP is proposing. Do you want to replace 21 >>> with EISDIR in the above? >> >> Yes, that's what I had in mind. >> > > Then, check out EnvironmentError_str in Objects/exceptions.c. You > should be able import the errn

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Martin v. Löwis
> Until recently, python had its own cross-platform implementation of > strerror, but it was removed because it was deemed redundant. This > tells me that it should work on windows. That conclusion is incorrect. It works on MSVCRT, but for this specific aspect, using MSVCRT is a bad idea (because

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Alexandre Vassalotti
On Fri, May 16, 2008 at 10:52 AM, Yannick Gingras <[EMAIL PROTECTED]> wrote: > "Alexander Belopolsky" <[EMAIL PROTECTED]> writes: > > try: >> ...open('/') >> ... except Exception,e: >> ...pass >> ... > print e >> [Errno 21] Is a directory >> >> So now I am not sure what OP is propos

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread M.-A. Lemburg
On 2008-05-16 17:02, Alexander Belopolsky wrote: On Fri, May 16, 2008 at 10:52 AM, Yannick Gingras <[EMAIL PROTECTED]> wrote: print e [Errno 21] Is a directory So now I am not sure what OP is proposing. Do you want to replace 21 with EISDIR in the above? Yes, that's what I had in mind. I

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread M.-A. Lemburg
On 2008-05-16 16:15, Nick Coghlan wrote: Alexander Belopolsky wrote: Yannick Gingras ygingras.net> writes: 2) Where can I find the symbolic name in C? Use standard C library char* strerror(int errnum) function. You can see an example usage in Modules/posixmodule.c (posix_strerror). I don

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Alexander Belopolsky
On Fri, May 16, 2008 at 10:52 AM, Yannick Gingras <[EMAIL PROTECTED]> wrote: > print e >> [Errno 21] Is a directory >> >> So now I am not sure what OP is proposing. Do you want to replace 21 >> with EISDIR in the above? > > Yes, that's what I had in mind. > In this case, I have a more drasti

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Yannick Gingras
"Alexander Belopolsky" <[EMAIL PROTECTED]> writes: try: > ...open('/') > ... except Exception,e: > ...pass > ... print e > [Errno 21] Is a directory > > So now I am not sure what OP is proposing. Do you want to replace 21 > with EISDIR in the above? Yes, that's what I had in mi

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Alexander Belopolsky
On Fri, May 16, 2008 at 10:15 AM, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Alexander Belopolsky wrote: .. >> Use standard C library char* strerror(int errnum) function. You can see >> an example usage in Modules/posixmodule.c (posix_strerror). > > I don't believe that would provide adequate Wind

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Jean-Paul Calderone
On Sat, 17 May 2008 00:15:23 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: Alexander Belopolsky wrote: Yannick Gingras ygingras.net> writes: 2) Where can I find the symbolic name in C? Use standard C library char* strerror(int errnum) function. You can see an example usage in Modules/posi

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Nick Coghlan
Alexander Belopolsky wrote: Yannick Gingras ygingras.net> writes: 2) Where can I find the symbolic name in C? Use standard C library char* strerror(int errnum) function. You can see an example usage in Modules/posixmodule.c (posix_strerror). I don't believe that would provide adequate Win

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Nick Coghlan
Yannick Gingras wrote: 1) Should OSError.__str__() print the symbolic name of errno? +1 (assuming the performance hit for doing so is incurred only when the exception is actually printed) 2) Where can I find the symbolic name in C? Modules/errnomodule.c Cheers, Nick. -- Nick Coghlan |

Re: [Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Alexander Belopolsky
Yannick Gingras ygingras.net> writes: .. > > 1) Should OSError.__str__() print the symbolic name of errno? > +1 for the change > 2) Where can I find the symbolic name in C? Use standard C library char* strerror(int errnum) function. You can see an example usage in Modules/posixmodule.c (pos

[Python-Dev] Symbolic errno values in error messages

2008-05-16 Thread Yannick Gingras
Hi, I spent some time googleing for "OSError 4" before it occurred to me that "4" was actually an irrelevant implementation detail. As soon as I searched for "EINTR", I found exactly what I was looking for. (not really but this is another story) I jumped to the conclusion that OSError.__str_