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
ce2ec49d
Commit
ce2ec49d
authored
Aug 26, 2014
by
Stefan Krah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 22090: Fix '%' formatting for infinities and NaNs.
parent
ec9d547e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
Lib/decimal.py
Lib/decimal.py
+2
-0
Lib/test/test_decimal.py
Lib/test/test_decimal.py
+5
-0
No files found.
Lib/decimal.py
View file @
ce2ec49d
...
...
@@ -3665,6 +3665,8 @@ class Decimal(object):
if
self
.
_is_special
:
sign
=
_format_sign
(
self
.
_sign
,
spec
)
body
=
str
(
self
.
copy_abs
())
if
spec
[
'type'
]
==
'%'
:
body
+=
'%'
return
_format_align
(
sign
,
body
,
spec
)
# a type of None defaults to 'g' or 'G', depending on context
...
...
Lib/test/test_decimal.py
View file @
ce2ec49d
...
...
@@ -823,6 +823,11 @@ class DecimalFormatTest(unittest.TestCase):
# issue 6850
(
'a=-7.0'
,
'0.12345'
,
'aaaa0.1'
),
# issue 22090
(
'<^+15.20%'
,
'inf'
,
'<<+Infinity%<<<'
),
(
'
\
x07
>,%'
,
'sNaN1234567'
,
'sNaN1234567%'
),
(
'=10.10%'
,
'NaN123'
,
' NaN123%'
),
]
for
fmt
,
d
,
result
in
test_values
:
self
.
assertEqual
(
format
(
Decimal
(
d
),
fmt
),
result
)
...
...
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