mirror of
https://github.com/python/cpython.git
synced 2025-08-17 15:21:26 +00:00
Issue #11830: Remove unnecessary introspection code in the decimal module.
It was causing a failed import in the Turkish locale where the locale sensitive str.upper() method caused a name mismatch.
This commit is contained in:
parent
16f98b7658
commit
e4579c3380
2 changed files with 15 additions and 14 deletions
|
@ -1723,8 +1723,6 @@ class Decimal(object):
|
||||||
# here self was representable to begin with; return unchanged
|
# here self was representable to begin with; return unchanged
|
||||||
return Decimal(self)
|
return Decimal(self)
|
||||||
|
|
||||||
_pick_rounding_function = {}
|
|
||||||
|
|
||||||
# for each of the rounding functions below:
|
# for each of the rounding functions below:
|
||||||
# self is a finite, nonzero Decimal
|
# self is a finite, nonzero Decimal
|
||||||
# prec is an integer satisfying 0 <= prec < len(self._int)
|
# prec is an integer satisfying 0 <= prec < len(self._int)
|
||||||
|
@ -1791,6 +1789,17 @@ class Decimal(object):
|
||||||
else:
|
else:
|
||||||
return -self._round_down(prec)
|
return -self._round_down(prec)
|
||||||
|
|
||||||
|
_pick_rounding_function = dict(
|
||||||
|
ROUND_DOWN = '_round_down',
|
||||||
|
ROUND_UP = '_round_up',
|
||||||
|
ROUND_HALF_UP = '_round_half_up',
|
||||||
|
ROUND_HALF_DOWN = '_round_half_down',
|
||||||
|
ROUND_HALF_EVEN = '_round_half_even',
|
||||||
|
ROUND_CEILING = '_round_ceiling',
|
||||||
|
ROUND_FLOOR = '_round_floor',
|
||||||
|
ROUND_05UP = '_round_05up',
|
||||||
|
)
|
||||||
|
|
||||||
def fma(self, other, third, context=None):
|
def fma(self, other, third, context=None):
|
||||||
"""Fused multiply-add.
|
"""Fused multiply-add.
|
||||||
|
|
||||||
|
@ -3708,18 +3717,6 @@ _numbers.Number.register(Decimal)
|
||||||
|
|
||||||
##### Context class #######################################################
|
##### Context class #######################################################
|
||||||
|
|
||||||
|
|
||||||
# get rounding method function:
|
|
||||||
rounding_functions = [name for name in Decimal.__dict__.keys()
|
|
||||||
if name.startswith('_round_')]
|
|
||||||
for name in rounding_functions:
|
|
||||||
# name is like _round_half_even, goes to the global ROUND_HALF_EVEN value.
|
|
||||||
globalname = name[1:].upper()
|
|
||||||
val = globals()[globalname]
|
|
||||||
Decimal._pick_rounding_function[val] = name
|
|
||||||
|
|
||||||
del name, val, globalname, rounding_functions
|
|
||||||
|
|
||||||
class _ContextManager(object):
|
class _ContextManager(object):
|
||||||
"""Context manager class to support localcontext().
|
"""Context manager class to support localcontext().
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,10 @@ Library
|
||||||
- Issue #4877: Fix a segfault in xml.parsers.expat while attempting to parse
|
- Issue #4877: Fix a segfault in xml.parsers.expat while attempting to parse
|
||||||
a closed file.
|
a closed file.
|
||||||
|
|
||||||
|
- Issue #11830: Remove unnecessary introspection code in the decimal module.
|
||||||
|
It was causing a failed import in the Turkish locale where the locale
|
||||||
|
sensitive str.upper() method caused a name mismatch.
|
||||||
|
|
||||||
- Issue #8428: Fix a race condition in multiprocessing.Pool when terminating
|
- Issue #8428: Fix a race condition in multiprocessing.Pool when terminating
|
||||||
worker processes: new processes would be spawned while the pool is being
|
worker processes: new processes would be spawned while the pool is being
|
||||||
shut down. Patch by Charles-François Natali.
|
shut down. Patch by Charles-François Natali.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue