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
48df2eb9
Commit
48df2eb9
authored
Jan 24, 2013
by
Eli Bendersky
Browse files
Options
Browse Files
Download
Plain Diff
merge heads
parents
aaa9780f
eb8c451b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
Lib/test/test_decimal.py
Lib/test/test_decimal.py
+4
-10
Modules/_decimal/_decimal.c
Modules/_decimal/_decimal.c
+7
-1
No files found.
Lib/test/test_decimal.py
View file @
48df2eb9
...
...
@@ -4971,22 +4971,16 @@ class CWhitebox(unittest.TestCase):
def
test_c_format
(
self
):
# Restricted input
Decimal
=
C
.
Decimal
InvalidOperation
=
C
.
InvalidOperation
Rounded
=
C
.
Rounded
localcontext
=
C
.
localcontext
HAVE_CONFIG_64
=
(
C
.
MAX_PREC
>
425000000
)
self
.
assertRaises
(
TypeError
,
Decimal
(
1
).
__format__
,
"=10.10"
,
[],
9
)
self
.
assertRaises
(
TypeError
,
Decimal
(
1
).
__format__
,
"=10.10"
,
9
)
self
.
assertRaises
(
TypeError
,
Decimal
(
1
).
__format__
,
[])
with
localcontext
()
as
c
:
c
.
traps
[
InvalidOperation
]
=
True
c
.
traps
[
Rounded
]
=
True
self
.
assertRaises
(
ValueError
,
Decimal
(
1
).
__format__
,
"<>=10.10"
)
maxsize
=
2
**
63
-
1
if
HAVE_CONFIG_64
else
2
**
31
-
1
self
.
assertRaises
(
InvalidOperation
,
Decimal
(
"1.23456789"
).
__format__
,
"=%d.1"
%
maxsize
)
self
.
assertRaises
(
ValueError
,
Decimal
(
1
).
__format__
,
"<>=10.10"
)
maxsize
=
2
**
63
-
1
if
HAVE_CONFIG_64
else
2
**
31
-
1
self
.
assertRaises
(
ValueError
,
Decimal
(
"1.23456789"
).
__format__
,
"=%d.1"
%
maxsize
)
def
test_c_integral
(
self
):
Decimal
=
C
.
Decimal
...
...
Modules/_decimal/_decimal.c
View file @
48df2eb9
...
...
@@ -3222,7 +3222,13 @@ dec_format(PyObject *dec, PyObject *args)
decstring
=
mpd_qformat_spec
(
MPD
(
dec
),
&
spec
,
CTX
(
context
),
&
status
);
if
(
decstring
==
NULL
)
{
dec_addstatus
(
context
,
status
);
if
(
status
&
MPD_Malloc_error
)
{
PyErr_NoMemory
();
}
else
{
PyErr_SetString
(
PyExc_ValueError
,
"format specification exceeds internal limits of _decimal"
);
}
goto
finish
;
}
result
=
PyUnicode_DecodeUTF8
(
decstring
,
strlen
(
decstring
),
NULL
);
...
...
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