]> git.phdru.name Git - dotfiles.git/commitdiff
lib/python/init.py: Protect `readline.read_init_file()`
authorOleg Broytman <phd@phdru.name>
Sun, 11 Jan 2026 03:11:20 +0000 (06:11 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 11 Jan 2026 03:11:20 +0000 (06:11 +0300)
PyPy3 doesn't implement it.

lib/python/init.py

index bd1842c7fc524297d7e1ba82122078c9d36ccb16..ce7f1f48d536df57281acc7806f0ff186f050396 100644 (file)
@@ -25,12 +25,13 @@ def init():
     try:
         import rlcompleter  # noqa: need for completion
         import readline
-        initfile = os.environ.get('INPUTRC') \
-            or os.path.expanduser('~/.inputrc')
-        warnings.filterwarnings(
-            'ignore', 'readline.read_init_file() not implemented',
-            category=UserWarning)
-        readline.read_init_file(initfile)
+        if hasattr(readline, 'read_init_file'):  # PyPy3 doesn't have it
+            initfile = os.environ.get('INPUTRC') \
+                or os.path.expanduser('~/.inputrc')
+            warnings.filterwarnings(
+                'ignore', 'readline.read_init_file() not implemented',
+                category=UserWarning)
+            readline.read_init_file(initfile)
 
         # if 'libedit' in readline.__doc__:
         #     readline.parse_and_bind("bind ^I rl_complete")