Fix compiling error when missing gdbm version macros (GH-7823)
This commit is contained in:
parent
16eb3bcdb2
commit
b248e957a8
|
@ -527,11 +527,11 @@ def collect_cc(info_add):
|
||||||
|
|
||||||
def collect_gdbm(info_add):
|
def collect_gdbm(info_add):
|
||||||
try:
|
try:
|
||||||
import _gdbm
|
from _gdbm import _GDBM_VERSION
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return
|
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):
|
def collect_info(info):
|
||||||
|
|
|
@ -12,9 +12,8 @@ class TestGdbm(unittest.TestCase):
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
try:
|
try:
|
||||||
import _gdbm
|
from _gdbm import _GDBM_VERSION as version
|
||||||
version = _gdbm._GDBM_VERSION
|
except ImportError:
|
||||||
except (ImportError, AttributeError):
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print(f"gdbm version: {version}")
|
print(f"gdbm version: {version}")
|
||||||
|
|
|
@ -678,6 +678,8 @@ PyInit__gdbm(void) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(GDBM_VERSION_MAJOR) && defined(GDBM_VERSION_MINOR) && \
|
||||||
|
defined(GDBM_VERSION_PATCH)
|
||||||
PyObject *obj = Py_BuildValue("iii", GDBM_VERSION_MAJOR,
|
PyObject *obj = Py_BuildValue("iii", GDBM_VERSION_MAJOR,
|
||||||
GDBM_VERSION_MINOR, GDBM_VERSION_PATCH);
|
GDBM_VERSION_MINOR, GDBM_VERSION_PATCH);
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
|
@ -687,6 +689,7 @@ PyInit__gdbm(void) {
|
||||||
Py_DECREF(obj);
|
Py_DECREF(obj);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue