-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gracefully degrade when loading libreadline fails #807
Conversation
libreadline may not be loadable for many reasons, especially in environments where a packager is using zipapp or PyOxidizer. Avoid critical failure; degrade gracefully to operating without libreadline and notify the user this has happened. Related to python-cmd2#802
Codecov Report
@@ Coverage Diff @@
## master #807 +/- ##
=========================================
- Coverage 97.3% 97.2% -0.11%
=========================================
Files 14 14
Lines 3493 3501 +8
=========================================
+ Hits 3399 3403 +4
- Misses 94 98 +4
Continue to review full report at Codecov.
|
Let me know if I need to build convoluted tests to reach these. |
import ctypes | ||
readline_lib = ctypes.CDLL(readline.__file__) | ||
try: | ||
import ctypes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would an import of ctypes fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctypes is a module. It doesnt need to exist, and is one of the first to be disabled in embedded Python, especially on new arch/platforms where the entire gcc toolchain isnt available/stable yet. In a completely static build of Python with all needed modules built in, there is no need for ctypes, and it adds bloat.
We are comfortable with cmd2 working in typical desktop environments running standard Python distributions as well as in containers like docker. If we choose to add exception handling to this code later, one of our authors will do it. |
libreadline may not be loadable for many reasons, especially
in environments where a packager is using zipapp or PyOxidizer.
Avoid critical failure; degrade gracefully to operating without
libreadline and notify the user this has happened.
Related to #802