New submission from Sergei Lebedev <superbo...@gmail.com>:
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> ---------- messages: 324654 nosy: superbobry priority: normal severity: normal status: open title: cdll.LoadLibrary allows None as an argument versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34592> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com