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
6e467049
Commit
6e467049
authored
Nov 10, 2012
by
Stefan Krah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept Unicode legacy strings in the Decimal constructor.
parent
6b0bdab4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
Lib/test/test_decimal.py
Lib/test/test_decimal.py
+10
-1
Modules/_decimal/_decimal.c
Modules/_decimal/_decimal.c
+3
-1
No files found.
Lib/test/test_decimal.py
View file @
6e467049
...
...
@@ -35,7 +35,7 @@ import locale
from
test.support
import
(
run_unittest
,
run_doctest
,
is_resource_enabled
,
requires_IEEE_754
)
from
test.support
import
(
check_warnings
,
import_fresh_module
,
TestFailed
,
run_with_locale
)
run_with_locale
,
cpython_only
)
import
random
import
time
import
warnings
...
...
@@ -574,6 +574,15 @@ class ExplicitConstructionTest(unittest.TestCase):
# embedded NUL
self
.
assertRaises
(
InvalidOperation
,
Decimal
,
"12
\
u0000
3"
)
@
cpython_only
def
test_from_legacy_strings
(
self
):
import
_testcapi
Decimal
=
self
.
decimal
.
Decimal
context
=
self
.
decimal
.
Context
()
s
=
_testcapi
.
unicode_legacy_string
(
'9.999999'
)
self
.
assertEqual
(
str
(
Decimal
(
s
)),
'9.999999'
)
self
.
assertEqual
(
str
(
context
.
create_decimal
(
s
)),
'9.999999'
)
def
test_explicit_from_tuples
(
self
):
Decimal
=
self
.
decimal
.
Decimal
...
...
Modules/_decimal/_decimal.c
View file @
6e467049
...
...
@@ -1892,7 +1892,9 @@ numeric_as_ascii(const PyObject *u, int strip_ws)
Py_ssize_t
j
,
len
;
int
d
;
assert
(
PyUnicode_IS_READY
(
u
));
if
(
PyUnicode_READY
(
u
)
==
-
1
)
{
return
NULL
;
}
kind
=
PyUnicode_KIND
(
u
);
data
=
PyUnicode_DATA
(
u
);
...
...
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