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

gh-89452: Prefer gdbm-compat over ndbm #92208

Merged
merged 1 commit into from
May 3, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gdbm-compat is now preferred over ndbm if both are available on the system.
This allows avoiding the problematic ndbm.h on macOS.
8 changes: 4 additions & 4 deletions Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
/* Some Linux systems install gdbm/ndbm.h, but not ndbm.h. This supports
* whichever configure was able to locate.
*/
#if defined(USE_NDBM)
#include <ndbm.h>
static const char which_dbm[] = "GNU gdbm"; /* EMX port of GDBM */
#elif defined(USE_GDBM_COMPAT)
#if defined(USE_GDBM_COMPAT)
#ifdef HAVE_GDBM_NDBM_H
#include <gdbm/ndbm.h>
#elif HAVE_GDBM_DASH_NDBM_H
Expand All @@ -24,6 +21,9 @@
#error "No gdbm/ndbm.h or gdbm-ndbm.h available"
#endif
static const char which_dbm[] = "GNU gdbm";
#elif defined(USE_NDBM)
#include <ndbm.h>
static const char which_dbm[] = "GNU gdbm";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the now stale comment about the OS/2 "EMX port" that was added over 20 years ago.

#elif defined(USE_BERKDB)
#ifndef DB_DBM_HSEARCH
#define DB_DBM_HSEARCH 1
Expand Down
4 changes: 2 additions & 2 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,7 @@ AC_CHECK_HEADERS([db.h], [
AC_MSG_CHECKING(for --with-dbmliborder)
AC_ARG_WITH(dbmliborder,
AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
[], [with_dbmliborder=ndbm:gdbm:bdb])
[], [with_dbmliborder=gdbm:ndbm:bdb])

have_gdbm_dbmliborder=no
as_save_IFS=$IFS
Expand All @@ -3865,7 +3865,7 @@ for db in $with_dbmliborder; do
done
IFS=$as_save_IFS
AS_VAR_IF([with_dbmliborder], [error], [
AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (ndbm:gdbm:bdb)])
AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (gdbm:ndbm:bdb)])
])
AC_MSG_RESULT($with_dbmliborder)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ def detect_dbm_gdbm(self):
if dbm_args:
dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":")
else:
dbm_order = "ndbm:gdbm:bdb".split(":")
dbm_order = "gdbm:ndbm:bdb".split(":")
dbmext = None
for cand in dbm_order:
if cand == "ndbm":
Expand Down