ENH: Allow ctypeslib.load_library to take any path-like object#17530
ENH: Allow ctypeslib.load_library to take any path-like object#17530charris merged 6 commits intonumpy:mainfrom
ctypeslib.load_library to take any path-like object#17530Conversation
| reason="Known to fail on cygwin") | ||
| class TestLoadLibrary: | ||
| def test_basic(self): | ||
| try: |
There was a problem hiding this comment.
Note that the try / except clause is redundant due to the pytest fixture:
numpy/numpy/tests/test_ctypeslib.py
Lines 35 to 39 in a9edc04
| Parameters | ||
| ---------- | ||
| libname : str | ||
| libname : path-like |
There was a problem hiding this comment.
Are paths with / actually allowed here? If not, this looks like it should remain a str
There was a problem hiding this comment.
It seems to be, yes.
What happens when defining libpath is, roughly speaking, calling os.path.join on loader_path and libname the input parameters.
Lines 144 to 148 in 4afd82d
There was a problem hiding this comment.
Hmm, to me that implies the path component should always be in loader_path, and libname should always be a string.
There was a problem hiding this comment.
Perhaps, though os.path.join is not required to join a path and a file name;
the joining of two paths is also perfectly acceptable.
In [1]: import os
In [2]: os.path.join('a/b/c/', 'd/e/f')
Out[2]: 'a/b/c/d/e/f'Besides, why should it remain a string if a / is not allowed?
The likes of pathlib.Path are just generally useful objects, regardless of whether it is used to represent a path- or file-name.
|
Needs a release note. |
See d690cf6. |
|
@eric-wieser Look good to you? |
|
close/reopen |
|
@eric-wieser Ping. |
|
Thanks Bas. |
This PR allows
ctypeslib.load_library()take take any path-like object,which includes the likes of strings, bytes and any object implementing the
__fspath__protocol.