Versions
- Python : 3.9.9
- MacOS version : 11.6.3
- XCode Version : 13.2.1
- Cython version : 0.29.28
Describe the bug
Issue was found with a load time error when pyzbar loads libzbar, see log below.
The fail is due to ctypes.util.py invoking subprocess to run /sbin/ldconfig.
I think the error message is misleading, because ctypes/util.py contains blocks of platform specific code, and is executing the catchall. The catchall because there is one earlier block for 'darwin' but no block for 'ios'.
There are two 'darwin' specific blocks (both assume posix, does iOS claim posix?)
https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L70
https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L349
Hopefully these 'darwin' cases also cover 'ios'
Logs
File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python3.9/site-packages/pyzbar/pyzbar.py", line 7, in <module>
from .wrapper import (
File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python3.9/site-packages/pyzbar/wrapper.py", line 139, in <module>
zbar_version = zbar_function(
File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python3.9/site-packages/pyzbar/wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python3.9/site-packages/pyzbar/wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python3.9/site-packages/pyzbar/zbar_library.py", line 63, in load
path = find_library('zbar')
> File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python39.zip/ctypes/util.py", line 329, in find_library
File "/private/var/containers/Bundle/Application/05C29F5B-4C28-4B05-BC61-614E42E25916/qr6.app/lib/python39.zip/ctypes/util.py", line 289, in _findSoname_ldconfig
AttributeError: module 'subprocess' has no attribute 'Popen'
2022-03-11 14:51:02.535669-1000 qr6[1324:654347] Application quit abnormally!
2022-03-11 14:51:02.552869-1000 qr6[1324:654347] Leaving
Additional context
-
Obviously the issue is more general to Python code than pyzbar loading libzbar.
-
As to other cases, a grep -R \"darwin\" of cpython finds 48 matches, but very few that look like they might be worth checking.
Versions
Describe the bug
Issue was found with a load time error when
pyzbarloadslibzbar, see log below.The fail is due to
ctypes.util.pyinvokingsubprocessto run/sbin/ldconfig.I think the error message is misleading, because
ctypes/util.pycontains blocks of platform specific code, and is executing the catchall. The catchall because there is one earlier block for'darwin'but no block for'ios'.There are two
'darwin'specific blocks (both assume posix, does iOS claim posix?)https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L70
https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L349
Hopefully these
'darwin'cases also cover'ios'Logs
Additional context
Obviously the issue is more general to Python code than
pyzbarloadinglibzbar.As to other cases, a
grep -R \"darwin\"ofcpythonfinds 48 matches, but very few that look like they might be worth checking.