mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-89902: Deprecate non-standard format specifier "N" for Decimal (GH-110508)
It was not documented and only supported in the C implementation.
This commit is contained in:
parent
6780d63ae5
commit
d96a8cdfe2
4 changed files with 29 additions and 0 deletions
|
@ -1222,6 +1222,23 @@ class FormatTest:
|
|||
self.assertEqual(get_fmt(Decimal('-1.5'), dotsep_wide, '020n'),
|
||||
'-0\u00b4000\u00b4000\u00b4000\u00b4001\u00bf5')
|
||||
|
||||
def test_deprecated_N_format(self):
|
||||
Decimal = self.decimal.Decimal
|
||||
h = Decimal('6.62607015e-34')
|
||||
if self.decimal == C:
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
r = format(h, 'N')
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
self.assertEqual(r, format(h, 'n').upper())
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
r = format(h, '010.3N')
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
self.assertEqual(r, format(h, '010.3n').upper())
|
||||
else:
|
||||
self.assertRaises(ValueError, format, h, 'N')
|
||||
self.assertRaises(ValueError, format, h, '010.3N')
|
||||
|
||||
|
||||
@run_with_locale('LC_ALL', 'ps_AF')
|
||||
def test_wide_char_separator_decimal_point(self):
|
||||
# locale with wide char separator and decimal point
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue