Issue 4686: Exceptions in ConfigParser don't set .args
Created on 2008-12-17 20:22 by beazley, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (8)
msg77983 - (view)
Author: David M. Beazley (beazley)
Date: 2008-12-17 20:22
Date: 2010-07-24 01:00
Date: 2010-07-24 18:24
Date: 2010-07-25 23:14
Date: 2010-07-26 13:35
Date: 2012-01-23 16:31
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.
msg111405 - (view)
Author: Łukasz Langa (lukasz.langa) *
Date: 2010-07-24 01:00
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?msg111496 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-24 18:18
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.msg111498 - (view) Author: Łukasz Langa (lukasz.langa) *
Date: 2010-07-24 18:24
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 :)msg111499 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-24 18:29
Ł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.msg111571 - (view) Author: Michael Foord (michael.foord) *
Date: 2010-07-25 23:14
Committed revision 83150. Still needs backporting to 3.1, 2.7 and possibly even 2.6.msg111613 - (view) Author: Michael Foord (michael.foord) *
Date: 2010-07-26 13:35
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...msg151823 - (view) Author: Roundup Robot (python-dev)
Date: 2012-01-23 16:31
New changeset 8e091e36fc80 by Łukasz Langa in branch '2.7': Fixes #4686. Reverts redundant picklability code from r74544. http://hg.python.org/cpython/rev/8e091e36fc80
History
Date
User
Action
Args
2022-04-11 14:56:42adminsetgithub: 48936
2012-01-23 16:31:49python-devsetnosy:
+ python-dev
messages: + msg151823
2010-07-26 13:35:48michael.foordsetstatus: open -> closed
messages: + msg111571
2010-07-24 18:29:15BreamoreBoysetmessages: + msg111499 2010-07-24 18:24:16lukasz.langasetmessages: + msg111498 2010-07-24 18:18:53BreamoreBoysetversions: + Python 3.1, Python 2.7
nosy: + BreamoreBoy
versions: + Python 3.2, - Python 2.6, Python 3.0, Python 3.1, Python 2.7
nosy: + brett.cannon, lukasz.langa
messages: + msg151823
2010-07-26 13:35:48michael.foordsetstatus: open -> closed
stage: commit review -> resolved
messages:
+ msg111613
versions:
- Python 2.6, Python 3.1, Python 2.7
messages: + msg111571
assignee: michael.foord
resolution: accepted
stage: patch review -> commit review
2010-07-24 18:29:15BreamoreBoysetmessages: + msg111499 2010-07-24 18:24:16lukasz.langasetmessages: + msg111498 2010-07-24 18:18:53BreamoreBoysetversions: + Python 3.1, Python 2.7
nosy: + BreamoreBoy
messages: + msg111496
stage: patch review
2010-07-24 01:00:43lukasz.langasetfiles: + issue4686_py3k.diffversions: + Python 3.2, - Python 2.6, Python 3.0, Python 3.1, Python 2.7
nosy: + brett.cannon, lukasz.langa
messages: + msg111405
keywords: + patch
2008-12-20 14:30:56loewissetversions: - Python 2.5, Python 2.4, Python 2.3, Python 2.2.3, Python 2.2.2, Python 2.2.1, Python 2.2, Python 2.1.2, Python 2.1.1, Python 2.5.3 2008-12-17 20:22:42beazleycreate