Skip to content
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

Fix compiling error when missing gdbm version macros #7823

Merged
merged 3 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,11 @@ def collect_cc(info_add):

def collect_gdbm(info_add):
try:
import _gdbm
from _gdbm import _GDBM_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serhiy-storchaka will be happy of this change :-D To be honest, I only saw this comment after I merged my PR :-(

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):
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_dbm_gnu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
3 changes: 3 additions & 0 deletions Modules/_gdbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -687,6 +689,7 @@ PyInit__gdbm(void) {
Py_DECREF(obj);
goto error;
}
#endif

return m;

Expand Down