FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106078: Convert `_decimal` types to heap types by CharlieZhao95 · Pull Request #106079 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .tsv  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 20 additions & 1 deletion Lib/test/test_decimal.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
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)
Expand Down Expand Up @@ -5681,6 +5682,24 @@ def test_maxcontext_exact_arith(self):
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
Expand Down
Loading

Back | FazBrowse Home | New Git URL