mirror of https://github.com/python/cpython
gh-106078: Convert `_decimal` types to heap types (#106079)
- Establish global state struct - Convert static types to heap types and add them to global state: * PyDecContextManager_Type * PyDecContext_Type * PyDecSignalDictMixin_Type * PyDec_Type - Add to global state: * PyDecSignalDict_Type * DecimalTuple Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend@python.org>
This commit is contained in:
parent
0e24499129
commit
fb0d9b9ac1
|
@ -34,7 +34,8 @@ import numbers
|
|||
import locale
|
||||
from test.support import (is_resource_enabled,
|
||||
requires_IEEE_754, requires_docstrings,
|
||||
requires_legacy_unicode_capi, check_sanitizer)
|
||||
requires_legacy_unicode_capi, check_sanitizer,
|
||||
check_disallow_instantiation)
|
||||
from test.support import (TestFailed,
|
||||
run_with_locale, cpython_only,
|
||||
darwin_malloc_err_warning, is_emscripten)
|
||||
|
@ -5681,6 +5682,24 @@ class CWhitebox(unittest.TestCase):
|
|||
self.assertEqual(Decimal(4) / 2, 2)
|
||||
self.assertEqual(Decimal(400) ** -1, Decimal('0.0025'))
|
||||
|
||||
def test_c_immutable_types(self):
|
||||
SignalDict = type(C.Context().flags)
|
||||
SignalDictMixin = SignalDict.__bases__[0]
|
||||
ContextManager = type(C.localcontext())
|
||||
types = (
|
||||
SignalDictMixin,
|
||||
ContextManager,
|
||||
C.Decimal,
|
||||
C.Context,
|
||||
)
|
||||
for tp in types:
|
||||
with self.subTest(tp=tp):
|
||||
with self.assertRaisesRegex(TypeError, "immutable"):
|
||||
tp.foo = 1
|
||||
|
||||
def test_c_disallow_instantiation(self):
|
||||
ContextManager = type(C.localcontext())
|
||||
check_disallow_instantiation(self, ContextManager)
|
||||
|
||||
@requires_docstrings
|
||||
@requires_cdecimal
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -375,10 +375,6 @@ Modules/_datetimemodule.c - PyDateTime_IsoCalendarDateType -
|
|||
Modules/_datetimemodule.c - PyDateTime_TZInfoType -
|
||||
Modules/_datetimemodule.c - PyDateTime_TimeType -
|
||||
Modules/_datetimemodule.c - PyDateTime_TimeZoneType -
|
||||
Modules/_decimal/_decimal.c - PyDecContextManager_Type -
|
||||
Modules/_decimal/_decimal.c - PyDecContext_Type -
|
||||
Modules/_decimal/_decimal.c - PyDecSignalDictMixin_Type -
|
||||
Modules/_decimal/_decimal.c - PyDec_Type -
|
||||
Modules/xxmodule.c - Null_Type -
|
||||
Modules/xxmodule.c - Str_Type -
|
||||
Modules/xxmodule.c - Xxo_Type -
|
||||
|
@ -389,8 +385,6 @@ Modules/xxsubtype.c - spamlist_type -
|
|||
## non-static types - initialized once
|
||||
|
||||
## heap types
|
||||
Modules/_decimal/_decimal.c - DecimalTuple -
|
||||
Modules/_decimal/_decimal.c - PyDecSignalDict_Type -
|
||||
Modules/_tkinter.c - PyTclObject_Type -
|
||||
Modules/_tkinter.c - Tkapp_Type -
|
||||
Modules/_tkinter.c - Tktt_Type -
|
||||
|
@ -428,6 +422,7 @@ Modules/_datetimemodule.c - us_per_hour -
|
|||
Modules/_datetimemodule.c - us_per_day -
|
||||
Modules/_datetimemodule.c - us_per_week -
|
||||
Modules/_datetimemodule.c - seconds_per_day -
|
||||
Modules/_decimal/_decimal.c - global_state -
|
||||
Modules/_decimal/_decimal.c - basic_context_template -
|
||||
Modules/_decimal/_decimal.c - current_context_var -
|
||||
Modules/_decimal/_decimal.c - default_context_template -
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 4.
|
Loading…
Reference in New Issue