[Python-checkins] cpython (2.7): Issue #21855: Fixed the decimal module in unicode disabled build.

serhiy.storchaka python-checkins at python.org
Tue Oct 14 20:12:53 CEST 2014


https://hg.python.org/cpython/rev/108377d0e24f
changeset: 93052:108377d0e24f
branch: 2.7
parent: 93045:ed4098380799
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Oct 14 21:10:56 2014 +0300
summary:
 Issue #21855: Fixed the decimal module in unicode disabled build.
files:
 Lib/decimal.py | 5 ++++-
 Lib/test/test_decimal.py | 9 +++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Lib/decimal.py b/Lib/decimal.py
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -6035,7 +6035,10 @@
 format_dict['decimal_point'] = '.'
 
 # record whether return type should be str or unicode
- format_dict['unicode'] = isinstance(format_spec, unicode)
+ try:
+ format_dict['unicode'] = isinstance(format_spec, unicode)
+ except NameError:
+ format_dict['unicode'] = False
 
 return format_dict
 
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -31,7 +31,7 @@
 import unittest
 from decimal import *
 import numbers
-from test.test_support import (run_unittest, run_doctest,
+from test.test_support import (run_unittest, run_doctest, requires_unicode, u,
 is_resource_enabled, check_py3k_warnings)
 import random
 try:
@@ -595,11 +595,12 @@
 d = nc.create_decimal(prevdec)
 self.assertEqual(str(d), '5.00E+8')
 
+ @requires_unicode
 def test_unicode_digits(self):
 test_values = {
- u'\uff11': '1',
- u'\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372',
- u'-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400',
+ u(r'\uff11'): '1',
+ u(r'\u0660.\u0660\u0663\u0667\u0662e-\u0663') : '0.0000372',
+ u(r'-nan\u0c68\u0c6a\u0c66\u0c66') : '-NaN2400',
 }
 for input, expected in test_values.items():
 self.assertEqual(str(Decimal(input)), expected)
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /