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

Importing anydbm generates exception if _bsddb unavailable #38426

Closed
vargish mannequin opened this issue May 2, 2003 · 8 comments
Closed

Importing anydbm generates exception if _bsddb unavailable #38426

vargish mannequin opened this issue May 2, 2003 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@vargish
Copy link
Mannequin

vargish mannequin commented May 2, 2003

BPO 731501
Nosy @loewis, @freddrake, @smontanaro
Files
  • bsddb185.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/smontanaro'
    closed_at = <Date 2005-05-23.01:38:01.000>
    created_at = <Date 2003-05-02.17:56:07.000>
    labels = ['library']
    title = 'Importing anydbm generates exception if _bsddb unavailable'
    updated_at = <Date 2005-05-23.01:38:01.000>
    user = 'https://bugs.python.org/vargish'

    bugs.python.org fields:

    activity = <Date 2005-05-23.01:38:01.000>
    actor = 'skip.montanaro'
    assignee = 'skip.montanaro'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2003-05-02.17:56:07.000>
    creator = 'vargish'
    dependencies = []
    files = ['871']
    hgrepos = []
    issue_num = 731501
    keywords = []
    message_count = 8.0
    messages = ['15823', '15824', '15825', '15826', '15827', '15828', '15829', '15830']
    nosy_count = 4.0
    nosy_names = ['loewis', 'fdrake', 'skip.montanaro', 'vargish']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue731501'
    versions = ['Python 2.3']

    @vargish
    Copy link
    Mannequin Author

    vargish mannequin commented May 2, 2003

    The anydbm module attempts to import the dbhash module,
    which fails if there is no BSD DB module available.

    Relevant portion of backtrace:

    File "/diska/netsite-docs/cgi-bin/waisdb2.py", line
    124, in _getsystemsdbm
    dbsrc = anydbm.open(self.dbfile)
    File
    "/usr/local/python-2.3b1/lib/python2.3/anydbm.py", line
    82, in open
    mod = __import__(result)
    File
    "/usr/local/python-2.3b1/lib/python2.3/dbhash.py", line
    5, in ?
    import bsddb
    File
    "/usr/local/python-2.3b1/lib/python2.3/bsddb/init.py",
    line 40, in ?
    import _bsddb
    ImportError: No module named _bsddb

    Tests that explicitly use "import dbm" rather than
    anydbm are successful on this system.

    @vargish vargish mannequin closed this as completed May 2, 2003
    @vargish vargish mannequin assigned smontanaro May 2, 2003
    @vargish vargish mannequin added the stdlib Python modules in the Lib dir label May 2, 2003
    @vargish vargish mannequin closed this as completed May 2, 2003
    @vargish vargish mannequin assigned smontanaro May 2, 2003
    @vargish vargish mannequin added the stdlib Python modules in the Lib dir label May 2, 2003
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 3, 2003

    Logged In: YES
    user_id=21627

    I think this is not a bug. open() has determined that this
    is a bsddb file, but bsddb is not supported on the system.

    Or did you mean to suggest that opening the very same file
    with dbm would be successful?

    @smontanaro
    Copy link
    Contributor

    Logged In: YES
    user_id=44345

    I believe the attached patch does what's necessary to get this to work again.
    It does a few things:

    • setup.py builds the bsddb185 under the right (restrictive) circumstances.
      /usr/include/db.h must exist and HASHVERSION must be 2. In this case
      the bsddb185 module will be built without any extra includes, libraries
      or #defines, forcing whatever is present in /usr/include/db.h and libc to
      be used to build the module.

    • whichdb.py detects the older hash file format and returns "bsddb185".

    • bsddbmodule.c grows an extra undocumented attribute, "open".

    The last two changes avoid having to change dbhash.py in complicated
    ways to distinguish between new and old file versions. The format-
    detecting mess remains isolated to whichdb.py.

    Using this setup I was successfully able to open /etc/pwd.db on my
    system using anydbm.open(), which I was unable to do previously. I can
    also still open a more recent hash file created with anydbm.open. Finally,
    new files created with anydbm.open are in the later format.

    Please give it a try.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 5, 2003

    Logged In: YES
    user_id=21627

    I can't actually test the patch, but it looks good to me.
    Please apply!

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 5, 2003

    Logged In: YES
    user_id=21627

    Actually, you probably need to check whether
    /usr/lib/libdb.* is present, and link with that as well if
    it is.

    If you are uncertain whether this is the right library, I
    see no way except to run a test program, at configure time,
    that creates a database and determines whether this really
    is a DB 1.85 database. Alternatively, the test program might
    try to invoke db_version. If the function is available, it
    is DB x, x>=2 (DB1 apparently has no version indication
    function).

    @smontanaro
    Copy link
    Contributor

    Logged In: YES
    user_id=44345

    Assigned to Fred for doc review - I added a couple notes to libbsddb.tex
    and libundoc.tex in lieu of actually creating a separate bsddb185 section
    which I felt would have given people the mistaken idea that the module is
    available for general use. Still, I thought there should be some mention in
    the docs.

    Library detection probably needs a little tweakage as well.

    @freddrake
    Copy link
    Member

    Logged In: YES
    user_id=3066

    The doc changes look mostly fine to me (and I've changed
    what didn't; a small cosmetic nit).

    I'm just amazed we're still spending time tweaking BSD DB; I
    don't think that's ever "just worked" for me without digging
    around for a version of the underlying library that worked
    with Python.

    @smontanaro
    Copy link
    Contributor

    Logged In: YES
    user_id=44345

    ancient history i just never closed

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants