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

Commit980aa20

Browse files
committed
Address review
1 parentf64b60b commit980aa20

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

‎Lib/test/test_ast/test_ast.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def cleanup():
9494

9595
delast.AST._fields
9696

97-
msg='AST has nofields'
97+
msg="type object 'ast.AST' has noattribute '_fields'"
9898
# Both examples used to crash:
99-
withself.assertRaisesRegex(TypeError,msg):
99+
withself.assertRaisesRegex(AttributeError,msg):
100100
ast.AST(arg1=123)
101-
withself.assertRaisesRegex(TypeError,msg):
101+
withself.assertRaisesRegex(AttributeError,msg):
102102
ast.AST()
103103

104104
deftest_AST_garbage_collection(self):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix a crash in:mod:`ast` when``_fields`` attribute is deleted.
1+
Fix a crash in:mod:`ast` whenthe:attr:`ast.AST._fields` attribute is deleted.

‎Parser/asdl_c.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,13 +884,9 @@ def visitModule(self, mod):
884884
Py_ssize_t i, numfields = 0;
885885
int res = -1;
886886
PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
887-
if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
888-
goto cleanup;
889-
}
887+
888+
fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
890889
if (fields == NULL) {
891-
PyErr_Format(PyExc_TypeError,
892-
"%.400s has no fields",
893-
_PyType_Name(Py_TYPE(self)));
894890
goto cleanup;
895891
}
896892

‎Python/Python-ast.c‎

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp