This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年03月19日 01:24 by belopolsky, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| posix-strerror.diff | belopolsky, 2008年03月19日 01:28 | Patch against revision 61579 | ||
| Messages (7) | |||
|---|---|---|---|
| msg64023 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2008年03月19日 01:24 | |
ISO/ANSI C strerror indicates out of range error by setting errno, but existing code incorrectly checks for NULL return value. Attached patch (tested n Mac OS X) makes os.strerror raise ValueError for out of range argument. |
|||
| msg64024 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2008年03月19日 01:30 | |
Please ignore the first patch. I don't have enough permissions to remove it. |
|||
| msg64039 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2008年03月19日 05:02 | |
Removed earlier version |
|||
| msg64105 - (view) | Author: Ralf Schmitt (schmir) | Date: 2008年03月19日 21:28 | |
my manpage (debian testing) states: POSIX.1-2001 permits strerror() to set errno if the call encounters an error, but does not specify what value should be returned as the func‐ tion result in the event of an error. On some systems, strerror() returns NULL if the error number is unknown. On other systems, str‐ error() returns a string something like "Error nnn occurred" and sets errno to EINVAL if the error number is unknown. So, I think this patch should be rejected. |
|||
| msg64113 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2008年03月19日 22:02 | |
And on some system "Unknown error: nnn" is returned with no error indication. Your concern that the patch is invalid on some unidentified system. This concern can easily be addressed by checking for NULL return *in addition* to the errno check. The real question is whether it is desirable to raise ValueError from strerror() when error code is out of bound. I would say the existing code intends to do exactly that, but th error check is incorrect on at least one popular platform. I believe it is better to raise an error because as a user, seeing "unknown error has occurred" message, is one of the worst experiences. On the other hand, if the consensus is that strerror() should always (short of out of memory condition) return a string, then (assuming null return is a possibility) the code needs to be changed to return "Unknown error: nnn" instead of raising an error. |
|||
| msg64446 - (view) | Author: Ralf Schmitt (schmir) | Date: 2008年03月24日 22:41 | |
The current behaviour (without your patch) seems ok to me. I just wanted to point out that the patch in its current form could break on some platforms. |
|||
| msg66670 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年05月11日 21:15 | |
IMO, the current behavior is the least problematic. It also mirrors the rest of Python's posix-wrapping calls: if something usable is returned, use it; if NULL is returned, raise an error. For most people, "Unknown error XXX" or "Value error: strerror() argument out of range" won't be much different in terms of user experience. Rejecting this patch. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:32 | admin | set | github: 46665 |
| 2008年05月11日 21:15:27 | georg.brandl | set | status: open -> closed resolution: rejected messages: + msg66670 nosy: + georg.brandl |
| 2008年03月24日 22:41:59 | schmir | set | messages: + msg64446 |
| 2008年03月19日 23:38:00 | terry.reedy | set | nosy: - terry.reedy |
| 2008年03月19日 22:02:57 | belopolsky | set | messages: + msg64113 |
| 2008年03月19日 21:28:36 | schmir | set | nosy:
+ schmir messages: + msg64105 |
| 2008年03月19日 05:02:25 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg64039 |
| 2008年03月19日 05:01:30 | terry.reedy | set | files: - posix-strerror.diff |
| 2008年03月19日 01:30:17 | belopolsky | set | messages: + msg64024 |
| 2008年03月19日 01:28:56 | belopolsky | set | files: + posix-strerror.diff |
| 2008年03月19日 01:25:22 | belopolsky | set | components: + Extension Modules |
| 2008年03月19日 01:24:52 | belopolsky | create | |