Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-110222: Add support of PyStructSequence in copy.replace() #110223

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 30 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6af4757
Add support of PyStructSequence in copy.replace()
XuehaiPan Oct 2, 2023
1960d8d
Correct error message for `namedtuple._replace`
XuehaiPan Oct 2, 2023
5ee97a8
📜🤖 Added by blurb_it.
blurb-it[bot] Oct 2, 2023
e8e6be4
Add test for `copy.replace()` for struct sequence objects
XuehaiPan Oct 2, 2023
43324a4
Move test for `copy.replace(structseq)` to test_structseq.py
XuehaiPan Oct 2, 2023
9e6cd98
Fix refcnt for temp variables
XuehaiPan Oct 2, 2023
350a3d0
Change copy.replace() to raise TypeError for unkown fields for named …
XuehaiPan Oct 2, 2023
c4655ca
Make copy.replace() to raise TypeError for PyStructSequence with unna…
XuehaiPan Oct 2, 2023
a9dba93
Revert copy.replace() to raise ValueError for unkown fields for named…
XuehaiPan Oct 2, 2023
83fd01b
Change comment in tests
XuehaiPan Oct 2, 2023
73e5e65
Add more tests for PyStructSequence with invisible fields
XuehaiPan Oct 2, 2023
7abaf64
Change test function names to match code style
XuehaiPan Oct 2, 2023
26eedbc
Refactor implementation with copy and replacement
XuehaiPan Oct 2, 2023
d74b449
Fix missing assertHasAttr
XuehaiPan Oct 2, 2023
5186c35
Fix test cases
XuehaiPan Oct 2, 2023
0f74efa
Fix error handling
XuehaiPan Oct 2, 2023
43a81b0
Remove unused variable
XuehaiPan Oct 2, 2023
d90e5ae
Cast return type to `PyObject*`
XuehaiPan Oct 2, 2023
287f8b0
Merge branch 'main' into copy-replace-structseq
XuehaiPan Oct 2, 2023
5722773
Update news entry
XuehaiPan Oct 2, 2023
c23165b
Prefer ++i over i++
XuehaiPan Oct 2, 2023
38f331b
Limit the length of typename to 500 in error message
XuehaiPan Oct 3, 2023
30758ba
Merge branch 'main' into copy-replace-structseq
XuehaiPan Oct 3, 2023
2a6259c
Prefer PyDict_GET_SIZE over PyDict_Size
XuehaiPan Oct 3, 2023
a6b0292
Apply suggestions from code review
XuehaiPan Oct 3, 2023
d76bb4e
Apply suggestions from code review
XuehaiPan Oct 3, 2023
3ae391f
Update test code style
XuehaiPan Oct 3, 2023
3664109
Merge branch 'main' into copy-replace-structseq
XuehaiPan Oct 3, 2023
4a606ad
Apply suggestions from code review
serhiy-storchaka Oct 3, 2023
8504345
Merge branch 'main' into copy-replace-structseq
XuehaiPan Oct 3, 2023
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
Apply suggestions from code review
  • Loading branch information
XuehaiPan committed Oct 3, 2023
commit d76bb4e1b044cf4be0bf618e336e735e6523f88a
6 changes: 3 additions & 3 deletions Objects/structseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ structseq_replace(PyStructSequence *self, PyObject *args, PyObject *kwargs)

result = (PyStructSequence *) PyStructSequence_New(Py_TYPE(self));
if (!result) {
goto error;
return NULL;
}

if (kwargs != NULL) {
Expand All @@ -406,7 +406,7 @@ structseq_replace(PyStructSequence *self, PyObject *args, PyObject *kwargs)
if (!key) {
goto error;
}
PyObject *ob = _PyDict_Pop(kwargs, key, self->ob_item[i]); // borrowed
PyObject *ob = _PyDict_Pop(kwargs, key, self->ob_item[i]);
Py_DECREF(key);
if (!ob) {
goto error;
Expand Down Expand Up @@ -434,7 +434,7 @@ structseq_replace(PyStructSequence *self, PyObject *args, PyObject *kwargs)
return (PyObject *)result;

error:
Py_XDECREF(result);
Py_DECREF(result);
return NULL;
}

Expand Down