Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.13] gh-106287: Do not write objects after an unmarshalling error (GH-132715)#143833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletionsLib/test/test_marshal.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -406,6 +406,26 @@ def test_deterministic_sets(self):
_, dump_1, _ = assert_python_ok(*args, PYTHONHASHSEED="1")
self.assertEqual(dump_0, dump_1)

def test_unmarshallable(self):
# Check no crash after encountering unmarshallable objects.
# See https://github.com/python/cpython/issues/106287.
fset = frozenset([int])
code = compile("a = 1", "<string>", "exec")
code = code.replace(co_consts=(1, fset, None))
cases = (('tuple', (fset,)),
('list', [fset]),
('set', fset),
('dict key', {fset: 'x'}),
('dict value', {'x': fset}),
('dict key & value', {fset: fset}),
('slice', slice(fset, fset)),
('code', code))
for name, arg in cases:
with self.subTest(name, arg=arg):
with self.assertRaisesRegex(ValueError, "unmarshallable object"):
marshal.dumps((arg, memoryview(b'')))


LARGE_SIZE = 2**31
pointer_size = 8 if sys.maxsize > 0xFFFFFFFF else 4

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Skip writing objects during marshalling once a failure has occurred.
4 changes: 4 additions & 0 deletionsPython/marshal.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -362,6 +362,10 @@ w_object(PyObject *v, WFILE *p)
{
char flag = '\0';

if (p->error != WFERR_OK) {
return;
}

p->depth++;

if (p->depth > MAX_MARSHAL_STACK_DEPTH) {
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp