Message324654
LoadLibrary in Python 2.7 through 3.7 accepts None as an argument. I wonder if this has been allowed for a reason? If not, it should probably be changed to raise a TypeError instead.
>>> ctypes.cdll.LoadLibrary(None)
<CDLL 'None', handle fffffffffffffffe at 10eedbe90>
Interestingly, on Python 2.7 LoadLibrary explicitly mentions None as allowed in the error message:
>>> ctypes.cdll.LoadLibrary(42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "[...]/ctypes/__init__.py", line 444, in LoadLibrary
return self._dlltype(name)
File "[...]/ctypes/__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: dlopen() argument 1 must be string or None, not int
A side-effect of None being allowed is that chaining find_library and LoadLibrary is error-prone:
>>> ctypes.cdll.LoadLibrary(find_library("foobar"))
<CDLL 'None', handle fffffffffffffffe at 10ef35fd0> |
|
Date |
User |
Action |
Args |
2018-09-05 21:35:41 | superbobry | set | recipients:
+ superbobry |
2018-09-05 21:35:41 | superbobry | set | messageid: <1536183341.44.0.56676864532.issue34592@psf.upfronthosting.co.za> |
2018-09-05 21:35:41 | superbobry | link | issue34592 messages |
2018-09-05 21:35:41 | superbobry | create | |
|