Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1840c1ab
Commit
1840c1ab
authored
May 03, 2008
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport Raymond's changes in r60508 to Python 2.6.
'Context flags get set, not incremented'
parent
2b30ea06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
Doc/library/decimal.rst
Doc/library/decimal.rst
+2
-2
Lib/decimal.py
Lib/decimal.py
+4
-4
No files found.
Doc/library/decimal.rst
View file @
1840c1ab
...
@@ -100,7 +100,7 @@ decimal module are: :const:`Clamped`, :const:`InvalidOperation`,
...
@@ -100,7 +100,7 @@ decimal module are: :const:`Clamped`, :const:`InvalidOperation`,
:const:`Overflow`, and :const:`Underflow`.
:const:`Overflow`, and :const:`Underflow`.
For each signal there is a flag and a trap enabler. When a signal is
For each signal there is a flag and a trap enabler. When a signal is
encountered, its flag is
incremented from zero and
, then, if the trap enabler is
encountered, its flag is
set to one
, then, if the trap enabler is
set to one, an exception is raised. Flags are sticky, so the user needs to
set to one, an exception is raised. Flags are sticky, so the user needs to
reset them before monitoring a calculation.
reset them before monitoring a calculation.
...
@@ -1121,7 +1121,7 @@ Signals
...
@@ -1121,7 +1121,7 @@ Signals
Signals represent conditions that arise during computation. Each corresponds to
Signals represent conditions that arise during computation. Each corresponds to
one context flag and one context trap enabler.
one context flag and one context trap enabler.
The context flag is
incremented
whenever the condition is encountered. After the
The context flag is
set
whenever the condition is encountered. After the
computation, flags may be checked for informational purposes (for instance, to
computation, flags may be checked for informational purposes (for instance, to
determine whether a computation was exact). After checking the flags, be sure to
determine whether a computation was exact). After checking the flags, be sure to
clear all flags before starting the next computation.
clear all flags before starting the next computation.
...
...
Lib/decimal.py
View file @
1840c1ab
...
@@ -3593,7 +3593,7 @@ class Context(object):
...
@@ -3593,7 +3593,7 @@ class Context(object):
traps - If traps[exception] = 1, then the exception is
traps - If traps[exception] = 1, then the exception is
raised when it is caused. Otherwise, a value is
raised when it is caused. Otherwise, a value is
substituted in.
substituted in.
flags - When an exception is caused, flags[exception] is
incremented
.
flags - When an exception is caused, flags[exception] is
set
.
(Whether or not the trap_enabler is set)
(Whether or not the trap_enabler is set)
Should be reset by user of Decimal instance.
Should be reset by user of Decimal instance.
Emin - Minimum exponent
Emin - Minimum exponent
...
@@ -3661,16 +3661,16 @@ class Context(object):
...
@@ -3661,16 +3661,16 @@ class Context(object):
"""Handles an error
"""Handles an error
If the flag is in _ignored_flags, returns the default response.
If the flag is in _ignored_flags, returns the default response.
Otherwise, it
incremen
ts the flag, then, if the corresponding
Otherwise, it
se
ts the flag, then, if the corresponding
trap_enabler is set, it reaises the exception. Otherwise, it returns
trap_enabler is set, it reaises the exception. Otherwise, it returns
the default value after
incremen
ting the flag.
the default value after
set
ting the flag.
"""
"""
error
=
_condition_map
.
get
(
condition
,
condition
)
error
=
_condition_map
.
get
(
condition
,
condition
)
if
error
in
self
.
_ignored_flags
:
if
error
in
self
.
_ignored_flags
:
# Don't touch the flag
# Don't touch the flag
return
error
().
handle
(
self
,
*
args
)
return
error
().
handle
(
self
,
*
args
)
self
.
flags
[
error
]
+
=
1
self
.
flags
[
error
]
=
1
if
not
self
.
traps
[
error
]:
if
not
self
.
traps
[
error
]:
# The errors define how to handle themselves.
# The errors define how to handle themselves.
return
condition
().
handle
(
self
,
*
args
)
return
condition
().
handle
(
self
,
*
args
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment