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

Incorrect exception raising in dbm.open on non-existing DB #48179

Closed
hagen mannequin opened this issue Sep 22, 2008 · 5 comments
Closed

Incorrect exception raising in dbm.open on non-existing DB #48179

hagen mannequin opened this issue Sep 22, 2008 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@hagen
Copy link
Mannequin

hagen mannequin commented Sep 22, 2008

BPO 3929
Nosy @birkenfeld, @amauryfa
Files
  • dbm.patch
  • dbm-2.patch
  • 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 = None
    closed_at = <Date 2008-09-25.22:29:21.245>
    created_at = <Date 2008-09-22.10:07:57.936>
    labels = ['type-bug', 'library']
    title = 'Incorrect exception raising in dbm.open on non-existing DB'
    updated_at = <Date 2008-09-26.08:31:18.845>
    user = 'https://bugs.python.org/hagen'

    bugs.python.org fields:

    activity = <Date 2008-09-26.08:31:18.845>
    actor = 'hagen'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-09-25.22:29:21.245>
    closer = 'amaury.forgeotdarc'
    components = ['Library (Lib)']
    creation = <Date 2008-09-22.10:07:57.936>
    creator = 'hagen'
    dependencies = []
    files = ['11555', '11556']
    hgrepos = []
    issue_num = 3929
    keywords = ['patch', 'needs review']
    message_count = 5.0
    messages = ['73563', '73564', '73570', '73819', '73838']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'amaury.forgeotdarc', 'hagen']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue3929'
    versions = ['Python 3.0']

    @hagen
    Copy link
    Mannequin Author

    hagen mannequin commented Sep 22, 2008

    Opening a dbm database which doesn't exist without a "c" or "n" flag
    results in this exception:

    >>> import dbm
    >>> dbm.open("abc")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/MP.shadow/hagenf/local/src/py3k/Lib/dbm/__init__.py", line
    79, in open
        raise error("need 'c' or 'n' flag to open new db")
    TypeError: 'tuple' object is not callable

    "error" is a tuple of dbm's own exception class and IOError, but this
    doesn't seem to make sense in the present code and Python 3.0. The
    attached patch fixes the problem and adds a test for the correct
    exception being raised.

    @hagen hagen mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 22, 2008
    @amauryfa
    Copy link
    Member

    dbm.error is documented as a tuple, and I'd prefer not to change this:
    http://docs.python.org/dev/3.0/library/dbm.html#dbm.error
    Since it says that its first member is another dbm.error exception,
    we could simply raise error0

    Attached another patch, with the same test case.

    @birkenfeld
    Copy link
    Member

    Amaury's patch looks good.

    @amauryfa
    Copy link
    Member

    Did you know that...
    with python 2.x, "raise (x,y,z)" is equivalent to "raise x"!
    I could not find this in the documentation.

    Committed the patch to py3k as r66622.

    @hagen
    Copy link
    Mannequin Author

    hagen mannequin commented Sep 26, 2008

    I didn't know until I had googled this:

    http://mail.python.org/pipermail/python-3000/2007-March/005916.html

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 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 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants