]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-29854: test_readline logs versions (#2619)
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 7 Jul 2017 14:06:58 +0000 (16:06 +0200)
committerGitHub <noreply@github.com>
Fri, 7 Jul 2017 14:06:58 +0000 (16:06 +0200)
* test_readline logs the versions of libreadline when run in verbose
  mode
* Add also readline._READLINE_LIBRARY_VERSION

Lib/test/test_readline.py
Modules/readline.c

index cc3001a3796e2fa652fdb4e6ff42113c3467ab69..5c37286149442700c9c1a93b2efe30f5ed25a268 100644 (file)
@@ -9,13 +9,29 @@ import subprocess
 import sys
 import tempfile
 import unittest
-from test.support import import_module, unlink, temp_dir, TESTFN
+from test.support import import_module, unlink, temp_dir, TESTFN, verbose
 from test.support.script_helper import assert_python_ok
 
 # Skip tests if there is no readline module
 readline = import_module('readline')
 
-is_editline = readline.__doc__ and "libedit" in readline.__doc__
+if hasattr(readline, "_READLINE_LIBRARY_VERSION"):
+    is_editline = ("EditLine wrapper" in readline._READLINE_LIBRARY_VERSION)
+else:
+    is_editline = (readline.__doc__ and "libedit" in readline.__doc__)
+
+
+def setUpModule():
+    if verbose:
+        # Python implementations other than CPython may not have
+        # these private attributes
+        if hasattr(readline, "_READLINE_VERSION"):
+            print(f"readline version: {readline._READLINE_VERSION:#x}")
+            print(f"readline runtime version: {readline._READLINE_RUNTIME_VERSION:#x}")
+        if hasattr(readline, "_READLINE_LIBRARY_VERSION"):
+            print(f"readline library version: {readline._READLINE_LIBRARY_VERSION!r}")
+        print(f"use libedit emulation? {is_editline}")
+
 
 @unittest.skipUnless(hasattr(readline, "clear_history"),
                      "The history update test cannot be run because the "
index 6ba124742a3450e30092cc5a9b134ddd4360a0e4..7d32c21f42d63844840c907aac5450e02221529f 100644 (file)
@@ -1427,6 +1427,7 @@ PyInit_readline(void)
 
     PyModule_AddIntConstant(m, "_READLINE_VERSION", RL_READLINE_VERSION);
     PyModule_AddIntConstant(m, "_READLINE_RUNTIME_VERSION", rl_readline_version);
+    PyModule_AddStringConstant(m, "_READLINE_LIBRARY_VERSION", rl_library_version);
 
     return m;
 }