René's URL Explorer Experiment


Title: gh-110222: Add support of PyStructSequence in copy.replace() by XuehaiPan · Pull Request #110223 · python/cpython · GitHub

Open Graph Title: gh-110222: Add support of PyStructSequence in copy.replace() by XuehaiPan · Pull Request #110223 · python/cpython

X Title: gh-110222: Add support of PyStructSequence in copy.replace() by XuehaiPan · Pull Request #110223 · python/cpython

Description: Resolves #110222 The implementation in this PR is roughly equivalent to: class SomeStructSeq: def __replace__(self, /, **kwargs): if self.n_unamed_fields > 0: raise TypeError(f'__replace__() is not supported for {self.__class__} ' 'because it has unnamed field(s)') field_names = self._get_field_names() _, (tup, dct) = self.__reduce__() seq = list(tup) for i, name in field_names[:self.n_sequence_fields]: if name in kwargs: seq[i] = kwargs.pop(name) for name in field_names[self.n_sequence_fields:]: if name in kwargs: dct[name] = kwargs.pop(name) if kwargs: raise TypeError(f'Got unexpected field name(s): {list(kwargs)!r}') return self.__class__(seq, dct) Refactored: class SomeStructSeq: def __replace__(self, /, **kwargs): if self.n_unamed_fields > 0: raise TypeError(f'__replace__() is not supported for {self.__class__} ' 'because it has unnamed field(s)') clone = self._clone() field_names = self._get_field_names() if kwargs: for i, name in enumerate(field_names): if name in kwargs: clone[i] = kwargs.pop(name) if kwargs: raise TypeError(f'Got unexpected field name(s): {list(kwargs)!r}') return clone Issue: gh-110222

Open Graph Description: Resolves #110222 The implementation in this PR is roughly equivalent to: class SomeStructSeq: def __replace__(self, /, **kwargs): if self.n_unamed_fields > 0: raise TypeE...

X Description: Resolves #110222 The implementation in this PR is roughly equivalent to: class SomeStructSeq: def __replace__(self, /, **kwargs): if self.n_unamed_fields > 0: raise T...

Opengraph URL: https://github.com/python/cpython/pull/110223

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8117b8e8-75d3-b678-6959-fc54a4fd2b0b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA1BA:1ED25A:96D7:D332:6B005FF3
html-safe-nonceaee8de76466866dbdc4a6356ba9788cda26a96312eb0e892ba5417cbd2feb05a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUJBOjFFRDI1QTo5NkQ3OkQzMzI6NkIwMDVGRjMiLCJ2aXNpdG9yX2lkIjoiNzQ1NTA0NDMwNjc4OTc1MjgxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6c57c7e0208e42132e828c68494cf7355baa8db6e8143f66f0e0cc3610a856e2
hovercard-subject-tagpull_request:1538178409
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/110223/files
twitter:imagehttps://avatars.githubusercontent.com/u/16078332?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/16078332?s=400&v=4
og:image:altResolves #110222 The implementation in this PR is roughly equivalent to: class SomeStructSeq: def __replace__(self, /, **kwargs): if self.n_unamed_fields > 0: raise TypeE...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None29be975efff6507a5d135de9c7d634cf7ff8f0c55222a64386ab3202209aaf73
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseeacd927ba6112e3b01ba99c762bd699a4a4f5df7
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/110223/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F110223%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F110223%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/110223/files
Reloadhttps://github.com/python/cpython/pull/110223/files
Reloadhttps://github.com/python/cpython/pull/110223/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
serhiy-storchakahttps://github.com/serhiy-storchaka
python:mainhttps://github.com/python/cpython/tree/main
XuehaiPan:copy-replace-structseqhttps://github.com/XuehaiPan/cpython/tree/copy-replace-structseq
Conversation 21 https://github.com/python/cpython/pull/110223
Commits 30 https://github.com/python/cpython/pull/110223/commits
Checks 0 https://github.com/python/cpython/pull/110223/checks
Files changed https://github.com/python/cpython/pull/110223/files
Please reload this pagehttps://github.com/python/cpython/pull/110223/files
gh-110222: Add support of PyStructSequence in copy.replace() https://github.com/python/cpython/pull/110223/files#top
Show all changes 30 commits https://github.com/python/cpython/pull/110223/files
6af4757 Add support of PyStructSequence in copy.replace() XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/6af4757e133933c3909635608b2da8a54edb8b6a
1960d8d Correct error message for `namedtuple._replace` XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/1960d8dea412f1ce1433b8edcee2fbc5541f71da
5ee97a8 📜🤖 Added by blurb_it. blurb-it[bot] Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/5ee97a8d6173db5afe6473c03f7267fe43b11a13
e8e6be4 Add test for `copy.replace()` for struct sequence objects XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/e8e6be484d29124c4fa75ea91cca6a7b260ba247
43324a4 Move test for `copy.replace(structseq)` to test_structseq.py XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/43324a4bcbccc9d4a9d7e48bdbddfab5c54c7907
9e6cd98 Fix refcnt for temp variables XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/9e6cd98d428981b485127ca0e1fe4a0bc43b9bfe
350a3d0 Change copy.replace() to raise TypeError for unkown fields for named … XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/350a3d04fa62f27f053c0d06944cb7ef6e416185
c4655ca Make copy.replace() to raise TypeError for PyStructSequence with unna… XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/c4655cabb32533a2bf382433de860eb3a811663c
a9dba93 Revert copy.replace() to raise ValueError for unkown fields for named… XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/a9dba93357e583b4c9bcc2832a73683b7c31b417
83fd01b Change comment in tests XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/83fd01b1fd6cce307eaa711fad11e3b536494f15
73e5e65 Add more tests for PyStructSequence with invisible fields XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/73e5e65cf801460508bf787770a0d95dc68aa809
7abaf64 Change test function names to match code style XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/7abaf649deef9372d3a5f98afe86b2643f41647e
26eedbc Refactor implementation with copy and replacement XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/26eedbc8518d7e0faad5cb4ae2172817e8c1b735
d74b449 Fix missing assertHasAttr XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/d74b44984c4253c6ea4771893ffba314704360b7
5186c35 Fix test cases XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/5186c35d1a6b638c5d9718d958d2ea87d24c7e52
0f74efa Fix error handling XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/0f74efaad22897726026587b348065335dc70ae9
43a81b0 Remove unused variable XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/43a81b0417b28ccdb73f54b5c1ae02e1d58621f8
d90e5ae Cast return type to `PyObject*` XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/d90e5ae22b9fbf1d0d6221533680eae708f65268
287f8b0 Merge branch 'main' into copy-replace-structseq XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/287f8b0395182b2d9e8d3354af70801a0789e316
5722773 Update news entry XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/57227732e2d74aef339cccf31ea9841e91898bcf
c23165b Prefer ++i over i++ XuehaiPan Oct 2, 2023 https://github.com/python/cpython/pull/110223/commits/c23165b9c72255f9351334f64010a635a01c7103
38f331b Limit the length of typename to 500 in error message XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/38f331b86fda80054a15d606a95ee4d426f9df3c
30758ba Merge branch 'main' into copy-replace-structseq XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/30758ba80f65a73e2c56b392991463b603e5f933
2a6259c Prefer PyDict_GET_SIZE over PyDict_Size XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/2a6259c171c23f0659387d8df0f1994a6ef18cfb
a6b0292 Apply suggestions from code review XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/a6b029266f8b57790677228dcd74ad392217a9a4
d76bb4e Apply suggestions from code review XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/d76bb4e1b044cf4be0bf618e336e735e6523f88a
3ae391f Update test code style XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/3ae391f35ab7691e9a2ac10697fcb744a08451b8
3664109 Merge branch 'main' into copy-replace-structseq XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/3664109594a75140ea2f262a646d4b4a7da984bf
4a606ad Apply suggestions from code review serhiy-storchaka Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/4a606ade1dcb5a2a35c9870aa07bb56101fe60ed
8504345 Merge branch 'main' into copy-replace-structseq XuehaiPan Oct 3, 2023 https://github.com/python/cpython/pull/110223/commits/85043450024a0392db8d16f8f9f73195506471d4
Clear filters https://github.com/python/cpython/pull/110223/files
Please reload this pagehttps://github.com/python/cpython/pull/110223/files
Please reload this pagehttps://github.com/python/cpython/pull/110223/files
test_structseq.py https://github.com/python/cpython/pull/110223/files#diff-4a637803c745f86a5ed3a3bb336b12697a2635ab209994b8c989b8cfae0085ef
2023-10-02-15-07-28.gh-issue-110222.zl_oHh.rst https://github.com/python/cpython/pull/110223/files#diff-7d3d596823df5f22dc9d92e706816bed1972fe3dbb6362c5a965e57fafaaa2b5
structseq.c https://github.com/python/cpython/pull/110223/files#diff-6088e5bc32426d02181ea56f5c4acbfc2fef3094c476b8081b22772fe205ccbd
Lib/test/test_structseq.pyhttps://github.com/python/cpython/pull/110223/files#diff-4a637803c745f86a5ed3a3bb336b12697a2635ab209994b8c989b8cfae0085ef
View file https://github.com/XuehaiPan/cpython/blob/85043450024a0392db8d16f8f9f73195506471d4/Lib/test/test_structseq.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/110223/{{ revealButtonHref }}
https://github.com/python/cpython/pull/110223/files#diff-4a637803c745f86a5ed3a3bb336b12697a2635ab209994b8c989b8cfae0085ef
https://github.com/python/cpython/pull/110223/files#diff-4a637803c745f86a5ed3a3bb336b12697a2635ab209994b8c989b8cfae0085ef
Misc/NEWS.d/next/Library/2023-10-02-15-07-28.gh-issue-110222.zl_oHh.rsthttps://github.com/python/cpython/pull/110223/files#diff-7d3d596823df5f22dc9d92e706816bed1972fe3dbb6362c5a965e57fafaaa2b5
View file https://github.com/XuehaiPan/cpython/blob/85043450024a0392db8d16f8f9f73195506471d4/Misc/NEWS.d/next/Library/2023-10-02-15-07-28.gh-issue-110222.zl_oHh.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/110223/{{ revealButtonHref }}
Objects/structseq.chttps://github.com/python/cpython/pull/110223/files#diff-6088e5bc32426d02181ea56f5c4acbfc2fef3094c476b8081b22772fe205ccbd
View file https://github.com/XuehaiPan/cpython/blob/85043450024a0392db8d16f8f9f73195506471d4/Objects/structseq.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/110223/{{ revealButtonHref }}
https://github.com/python/cpython/pull/110223/files#diff-6088e5bc32426d02181ea56f5c4acbfc2fef3094c476b8081b22772fe205ccbd
https://github.com/python/cpython/pull/110223/files#diff-6088e5bc32426d02181ea56f5c4acbfc2fef3094c476b8081b22772fe205ccbd
https://github.com/python/cpython/pull/110223/files#diff-6088e5bc32426d02181ea56f5c4acbfc2fef3094c476b8081b22772fe205ccbd
https://github.com/python/cpython/pull/110223/files#diff-6088e5bc32426d02181ea56f5c4acbfc2fef3094c476b8081b22772fe205ccbd
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.