[Python-checkins] Fix compiling error when missing gdbm version macros (GH-7823)
Xiang Zhang
webhook-mailer at python.org
Wed Jun 20 09:23:33 EDT 2018
https://github.com/python/cpython/commit/b248e957a818e268cfb221f3b94b37bc5672456a
commit: b248e957a818e268cfb221f3b94b37bc5672456a
branch: master
author: Xiang Zhang <angwerzx at 126.com>
committer: GitHub <noreply at github.com>
date: 2018-06-20T21:23:30+08:00
summary:
Fix compiling error when missing gdbm version macros (GH-7823)
files:
M Lib/test/pythoninfo.py
M Lib/test/test_dbm_gnu.py
M Modules/_gdbmmodule.c
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 3958764a6ae9..f058185c2f80 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -527,11 +527,11 @@ def collect_cc(info_add):
def collect_gdbm(info_add):
try:
- import _gdbm
+ from _gdbm import _GDBM_VERSION
except ImportError:
return
- info_add('gdbm.GDBM_VERSION', '.'.join(map(str, _gdbm._GDBM_VERSION)))
+ info_add('gdbm.GDBM_VERSION', '.'.join(map(str, _GDBM_VERSION)))
def collect_info(info):
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
index 49f91705b5b8..c96eff5a319e 100644
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -12,9 +12,8 @@ class TestGdbm(unittest.TestCase):
def setUpClass():
if support.verbose:
try:
- import _gdbm
- version = _gdbm._GDBM_VERSION
- except (ImportError, AttributeError):
+ from _gdbm import _GDBM_VERSION as version
+ except ImportError:
pass
else:
print(f"gdbm version: {version}")
diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c
index a68cf029429a..10560040e446 100644
--- a/Modules/_gdbmmodule.c
+++ b/Modules/_gdbmmodule.c
@@ -678,6 +678,8 @@ PyInit__gdbm(void) {
goto error;
}
+#if defined(GDBM_VERSION_MAJOR) && defined(GDBM_VERSION_MINOR) && \
+ defined(GDBM_VERSION_PATCH)
PyObject *obj = Py_BuildValue("iii", GDBM_VERSION_MAJOR,
GDBM_VERSION_MINOR, GDBM_VERSION_PATCH);
if (obj == NULL) {
@@ -687,6 +689,7 @@ PyInit__gdbm(void) {
Py_DECREF(obj);
goto error;
}
+#endif
return m;
More information about the Python-checkins
mailing list