homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Exceptions in ConfigParser don't set .args
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: BreamoreBoy, beazley, brett.cannon, lukasz.langa, michael.foord, python-dev
Priority: normal Keywords: patch

Created on 2008年12月17日 20:22 by beazley, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue4686_py3k.diff lukasz.langa, 2010年07月24日 01:00 Patch for Py3k
Messages (8)
msg77983 - (view) Author: David M. Beazley (beazley) Date: 2008年12月17日 20:22
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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) (Python triager) 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

stage: commit review -> resolved
messages: + msg111613
versions: - Python 2.6, Python 3.1, Python 2.7
2010年07月25日 23:14:48michael.foordsetversions: + Python 2.6
messages: + msg111571

assignee: michael.foord
resolution: accepted
stage: patch review -> commit review
2010年07月25日 22:42:13lukasz.langasetnosy: + michael.foord
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.diff
versions: + 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

AltStyle によって変換されたページ (->オリジナル) /