8000 gh-110235: Raise `TypeError` for duplicate/unknown fields in PyStructSequence constructor by XuehaiPan · Pull Request #110258 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-110235: Raise TypeError for duplicate/unknown fields in PyStructSequence constructor #110258

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Refactor and simplify error handling
  • Loading branch information
XuehaiPan committed Oct 3, 2023
commit 8f216b85d3a82ad3a06e1e8ede783ab132c14093
4 changes: 3 additions & 1 deletion Objects/structseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ structseq_new_impl(PyTypeObject *type, PyObject *arg, PyObject *dict)
return NULL;
}
if (i < len) {
if (ob != NULL && res->ob_item[i] != NULL) {
// For i < len, the ob_item[i] is already set from sequence.
// If there is a value in the dict, raise an error.
if (ob != NULL) {
PyErr_Format(PyExc_TypeError,
"%.500s() got multiple values for field '%s'",
type->tp_name,
Expand Down
0