[Python-Dev] PEP 415: Implementing PEP 409 differently (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Tue Feb 28 17:42:47 CET 2012
- Previous message: [Python-Dev] PEP 415: Implementing PEP 409 differently
- Next message: [Python-Dev] New-style formatting in the logging module (was Re: cpython (3.2): Issue #14123: Explicitly mention that old style % string formatting has caveats)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Big +1.
Indeed, this whole Ellipsis approach is just an awful hack.
- Yury
On 2012-02-26, at 8:30 PM, Benjamin Peterson wrote:
PEP: 415 Title: Implementing PEP 409 differently Version: RevisionRevisionRevision Last-Modified: DateDateDate Author: Benjamin Peterson <benjamin at python.org> Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 26-Feb-2012 Post-History: 26-Feb-2012
Abstract ======== PEP 409 allows PEP 3134 exception contexts and causes to be suppressed when the exception is printed. This is done using the
raise exc from None
syntax. This PEP proposes to implement context and cause suppression differently. Rationale ========= PEP 409 changes_cause_
to beEllipsis
by default. Then if_cause_
is set toNone
byraise exc from None
, no context or cause will be printed should the exception be uncaught. The main problem with this scheme is it complicates the role of_cause_
._cause_
should indicate the cause of the exception not whether_context_
should be printed or not. This use of_cause_
is also not easily extended in the future. For example, we may someday want to allow the programmer to select which of_context_
and_cause_
will be printed. The PEP 409 implementation is not amendable to this. The use ofEllipsis
is a hack. Before PEP 409,Ellipsis
was used exclusively in extended slicing. Extended slicing has nothing to do with exceptions, so it's not clear to someone inspecting an exception object why_cause_
should be set toEllipsis
. UsingEllipsis
by default for_cause_
makes it asymmetrical with_context_
. Proposal ======== A new attribute onBaseException
,_suppresscontext_
, will be introduced. Theraise exc from None
syntax will causeexc._suppresscontext_
to be set toTrue
. Exception printing code will check for the attribute to determine whether context and cause will be printed._cause_
will return to its original purpose and values. There is precedence for_suppresscontext_
with theprintlineandfile
exception attribute. Patches ======= There is a patch onIssue 14133
. References ========== .. issue 14133: http://bugs.python.org/issue6210 Copyright ========= This document has been placed in the public domain.
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/yselivanov.ml%40gmail.com
- Previous message: [Python-Dev] PEP 415: Implementing PEP 409 differently
- Next message: [Python-Dev] New-style formatting in the logging module (was Re: cpython (3.2): Issue #14123: Explicitly mention that old style % string formatting has caveats)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]