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 2011年06月29日 00:07 by anacrolix, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| dlopen_raise.py | anacrolix, 2011年06月29日 00:07 | test case | ||
| Messages (8) | |||
|---|---|---|---|
| msg139382 - (view) | Author: Matt Joiner (anacrolix) | Date: 2011年06月29日 00:07 | |
_ctypes.dlopen is not including the errno when it raises OSError. This occurs when attempting to load a library that doesn't exist, the error string given is clearly generated from an ENOENT. joiner@dbssyd800:~$ python3 dlopen_raise.py None somelib.so: cannot open shared object file: No such file or directory |
|||
| msg139387 - (view) | Author: Santoso Wijaya (santoso.wijaya) * | Date: 2011年06月29日 01:09 | |
On Windows:
>>> try:
... ctypes.CDLL('somelib')
... except OSError as exc:
... print repr(exc)
... print exc.errno
...
WindowsError(126, 'The specified module could not be found')
22
|
|||
| msg141592 - (view) | Author: Matt Joiner (anacrolix) | Date: 2011年08月03日 01:47 | |
Should I just submit a patch for this myself? Can someone confirm the behaviour is incorrect so I don't waste time fixing it? |
|||
| msg141617 - (view) | Author: Santoso Wijaya (santoso.wijaya) * | Date: 2011年08月04日 00:27 | |
At least in Windows, the exception object has its `winerror` attribute correctly set to 126, which is also translated to POSIX `errno` with `winerror_to_errno()`; the latter gives us EINVAL (22). |
|||
| msg141618 - (view) | Author: Santoso Wijaya (santoso.wijaya) * | Date: 2011年08月04日 00:37 | |
From what I gather from the code, when dlopen fails in POSIX platforms, ctypes raises an PyExc_OSError instantiated with a simple string (via PyErr_SetString()). I suppose this could be changed to raise a more complex tuple, instead (like its WindowsError equivalent when LoadLibrary fails in Windows platforms), but that might break existing code that relies on this behavior. 3.3 only? |
|||
| msg141754 - (view) | Author: Vlad Riscutia (vladris) | Date: 2011年08月07日 22:45 | |
Not sure how this can be fixed actually. I don't think PyErr_SetFromErrno instead of PyErr_SetString would work because as far as I can tell, standard does not mention dlopen making use of errno. Unlike Windows, where LoadLibrary will change last-error, if dlopen fails, only way to retrieve error is to dlerror which returns a string, no error code. |
|||
| msg141759 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年08月08日 07:25 | |
Indeed, it looks more like a bug in the POSIX standard unfortunately. I'm suggesting to close as "won't fix". |
|||
| msg141760 - (view) | Author: Matt Joiner (anacrolix) | Date: 2011年08月08日 07:42 | |
I didn't notice there was no use of errno. It's quite possible that dlopen might be used without the C library present, so perhaps this is why it wasn't included. The error strings however are very C-like, which made me think of this in the first place. Thanks all. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56646 |
| 2011年08月08日 07:49:21 | pitrou | set | status: open -> closed |
| 2011年08月08日 07:42:33 | anacrolix | set | status: pending -> open messages: + msg141760 |
| 2011年08月08日 07:25:03 | pitrou | set | status: open -> pending nosy: + pitrou messages: + msg141759 resolution: wont fix |
| 2011年08月07日 22:45:49 | vladris | set | nosy:
+ vladris messages: + msg141754 |
| 2011年08月04日 00:37:58 | santoso.wijaya | set | messages: + msg141618 |
| 2011年08月04日 00:27:38 | santoso.wijaya | set | messages:
+ msg141617 versions: + Python 3.3 |
| 2011年08月03日 01:47:45 | anacrolix | set | messages: + msg141592 |
| 2011年06月29日 01:09:40 | santoso.wijaya | set | nosy:
+ santoso.wijaya messages: + msg139387 |
| 2011年06月29日 00:07:06 | anacrolix | create | |