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

Exceptions in ConfigParser don't set .args #48936

Closed
beazley mannequin opened this issue Dec 17, 2008 · 8 comments
Closed

Exceptions in ConfigParser don't set .args #48936

beazley mannequin opened this issue Dec 17, 2008 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@beazley
Copy link
Mannequin

beazley mannequin commented Dec 17, 2008

BPO 4686
Nosy @brettcannon, @voidspace, @ambv
Files
  • issue4686_py3k.diff: Patch for Py3k
  • 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/voidspace'
    closed_at = <Date 2010-07-26.13:35:48.728>
    created_at = <Date 2008-12-17.20:22:42.248>
    labels = ['type-bug', 'library']
    title = "Exceptions in ConfigParser don't set .args"
    updated_at = <Date 2012-01-23.16:31:49.058>
    user = 'https://bugs.python.org/beazley'

    bugs.python.org fields:

    activity = <Date 2012-01-23.16:31:49.058>
    actor = 'python-dev'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2010-07-26.13:35:48.728>
    closer = 'michael.foord'
    components = ['Library (Lib)']
    creation = <Date 2008-12-17.20:22:42.248>
    creator = 'beazley'
    dependencies = []
    files = ['18167']
    hgrepos = []
    issue_num = 4686
    keywords = ['patch']
    message_count = 8.0
    messages = ['77983', '111405', '111496', '111498', '111499', '111571', '111613', '151823']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'beazley', 'michael.foord', 'BreamoreBoy', 'lukasz.langa', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4686'
    versions = ['Python 3.2']

    @beazley
    Copy link
    Mannequin Author

    beazley mannequin commented Dec 17, 2008

    The ConfigParser module defines a variety of custom exceptions, many of
    which take more than one argument (e.g., InterpolationError,
    NoOptionError, etc.). However, none of these exceptions properly set
    the .args attribute. For example, shouldn't NoOptionError be defined
    as follows:

    class NoOptionError(Error):
        def __init__(self,option,section):
            Error.__init__(self,"No option %r in section: %r" %
                           (option,section))
            self.option = option
            self.section = section
            self.args = (option,section)      #!! Added this line

    This is kind of a minor point, but the missing args means that these
    exceptions don't work properly with programs that need to do fancy kinds
    of exception processing (i.e., catching errors and reraising them in a
    different context or process).

    I can't speak for Python 3.0, but it's my understanding that .args
    should always be set to the exception arguments.

    Don't ask how I came across this---it was the source of a really bizarre
    bug in something I was playing around with.

    @beazley beazley mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 17, 2008
    @ambv
    Copy link
    Contributor

    ambv commented Jul 24, 2010

    Sound argument. I've prepared a patch for Py3k that adds args for all exceptions. Unit tests were modified as to check whether the args are set correctly (which helped finding a couple of flaky assertions in the tests themselves :)).

    Brett, the code change is trivial. Tests aren't complicated as well. Should this change also be ported to py27-maint?

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 24, 2010

    Tests failed after patching test file, all passed after patching the code on Windows against 3.2. The patch looks simple and clean so I don't see why it can't be committed. As this is a behaviour issue the code should also be backported.

    @ambv
    Copy link
    Contributor

    ambv commented Jul 24, 2010

    Thanks, Mark. Should I do the backporting or do you have some technology/process for this?

    I can do the backport as well if it doesn't require SVN commit access. I would need some help because it would be my first backport :)

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 24, 2010

    Łukasz, no problem. It would be my first backport too! :) I think that it's best left to the committers as they've well used to doing things like this.

    @voidspace
    Copy link
    Contributor

    Committed revision 83150.

    Still needs backporting to 3.1, 2.7 and possibly even 2.6.

    @voidspace voidspace self-assigned this Jul 25, 2010
    @voidspace
    Copy link
    Contributor

    Patch doesn't apply cleanly to 3.1 or earlier. As it is *arguably* a new feature rather than a bugfix I'm closing the issue.

    I certainly wouldn't argue against someone else backporting though...

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 23, 2012

    New changeset 8e091e36fc80 by Łukasz Langa in branch '2.7':
    Fixes bpo-4686. Reverts redundant picklability code from r74544.
    http://hg.python.org/cpython/rev/8e091e36fc80

    @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