René's URL Explorer Experiment


Title: bytes: support keyword arguments in hex() by devyubin · Pull Request #8312 · RustPython/RustPython · GitHub

Open Graph Title: bytes: support keyword arguments in hex() by devyubin · Pull Request #8312 · RustPython/RustPython

X Title: bytes: support keyword arguments in hex() by devyubin · Pull Request #8312 · RustPython/RustPython

Description: This PR follows our AI policy Summary bytes/bytearray/memoryview's hex() rejected its sep and bytes_per_sep arguments when passed by keyword, even though CPython accepts them either positionally or by keyword. b'\xb9\x01\xef'.hex(sep=':', bytes_per_sep=2) # before: TypeError: Unexpected keyword argument sep # after: 'b9:01ef' # matches CPython Cause hex() took its arguments as bare OptionalArg method parameters, whose FromArgs only consumes positionals (take_positional()) and never keywords. The argument names were never registered, so sep= / bytes_per_sep= stayed in kwargs and tripped check_kwargs_empty. Fix Move the arguments into a #[derive(FromArgs)] struct (ByteInnerHexOptions) with #[pyarg(any, optional)] fields, which generates take_positional_keyword so both positional and keyword forms are accepted — matching CPython's positional-or-keyword signature (no / or * in its Argument Clinic definition). Applied consistently to bytes, bytearray, and memoryview; the computation still delegates to the existing inner.hex(...), so the error cases are preserved (None → TypeError, separator len != 1 → ValueError). Re-enables test_hex_separator_basics by removing its expectedFailure marker. Test Verified locally: cargo run -- -m test test_bytes -v → Tests result: SUCCESS (Ran 317 tests, OK (skipped=15, expected failures=18)) test_hex_separator_basics (BytesTest / ByteArrayTest) ... ok test_hex_separator_five_bytes / test_hex_separator_six_bytes / test_hex ... ok Assisted-by: Claude Code:claude-opus-4-8 Summary by CodeRabbit Improvements Standardized hexadecimal formatting options across bytes, bytearray, and memoryview. Consistent support for custom separators and configurable bytes-per-group formatting. Existing .hex() behavior remains unchanged while argument handling is more consistent across these types.

Open Graph Description: This PR follows our AI policy Summary bytes/bytearray/memoryview's hex() rejected its sep and bytes_per_sep arguments when passed by keyword, even though CPython accepts them either positional...

X Description: This PR follows our AI policy Summary bytes/bytearray/memoryview's hex() rejected its sep and bytes_per_sep arguments when passed by keyword, even though CPython accepts them either positi...

Opengraph URL: https://github.com/RustPython/RustPython/pull/8312

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5a7a87e7-fc1a-0570-e04c-76f450810fc0
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC5C8:114B09:955284:CA82BF:6A601011
html-safe-nonce9da9309b93d8ec8120caf980ae7b6c958538a14dfaa2153bfc032a13746f2e8f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUM4OjExNEIwOTo5NTUyODQ6Q0E4MkJGOjZBNjAxMDExIiwidmlzaXRvcl9pZCI6IjIwOTIzNjY4MTk4MDY0MTY5MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac139ad662db4137a0959c48948fef36538c731a391ec80fed1a3f020dc3c65649
hovercard-subject-tagpull_request:4081218705
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/RustPython/RustPython/pull/8312/files
twitter:imagehttps://avatars.githubusercontent.com/u/80163835?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/80163835?s=400&v=4
og:image:altThis PR follows our AI policy Summary bytes/bytearray/memoryview's hex() rejected its sep and bytes_per_sep arguments when passed by keyword, even though CPython accepts them either positional...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None48cb2ed2304f8ae5a4a05d6327faf70466c4c0d9dcbf7b9df76251ca9c669a90
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
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
releasecb0f10a384099e0765239a7cc220992cae52bdba
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/8312/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8312%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8312%2Ffiles
Sign up https://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=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/8312/files
Reloadhttps://github.com/RustPython/RustPython/pull/8312/files
Reloadhttps://github.com/RustPython/RustPython/pull/8312/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 294 https://github.com/RustPython/RustPython/issues
Pull requests 105 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
devyubinhttps://github.com/devyubin
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
devyubin:fix-bytes-hex-keyword-argshttps://github.com/devyubin/RustPython/tree/fix-bytes-hex-keyword-args
Conversation 6 https://github.com/RustPython/RustPython/pull/8312
Commits 2 https://github.com/RustPython/RustPython/pull/8312/commits
Checks 26 https://github.com/RustPython/RustPython/pull/8312/checks
Files changed https://github.com/RustPython/RustPython/pull/8312/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
bytes: support keyword arguments in hex() https://github.com/RustPython/RustPython/pull/8312/files#top
Show all changes 2 commits https://github.com/RustPython/RustPython/pull/8312/files
20c4fcc bytes: support keyword arguments in hex() devyubin Jul 18, 2026 https://github.com/RustPython/RustPython/pull/8312/commits/20c4fcc402433a5981e4fd3d72825fb9f8a35259
7f2670d bytes: unmark test_memoryview_hex_separator devyubin Jul 19, 2026 https://github.com/RustPython/RustPython/pull/8312/commits/7f2670d42bc5d64fd71de30987941dff422a0b1a
Clear filters https://github.com/RustPython/RustPython/pull/8312/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
test_bytes.py https://github.com/RustPython/RustPython/pull/8312/files#diff-58df2535f64e3dcfb0677a7f543924d976fd982b595f8e34902a73f3deae40eb
test_memoryview.py https://github.com/RustPython/RustPython/pull/8312/files#diff-d41c6bb40a1e03fea5a20d15c4077413e0ddde65651147922b625b03a66a2f16
bytearray.rs https://github.com/RustPython/RustPython/pull/8312/files#diff-bd8962db12555ddc9945c543b57069611c9b3f24f133fbf3a76c7c60fe1cfddd
bytes.rs https://github.com/RustPython/RustPython/pull/8312/files#diff-6b402f3feb41119eef6e230cb7efe615c9804a4ed5ce25dc9121ed85ed495343
memory.rs https://github.com/RustPython/RustPython/pull/8312/files#diff-83fe7bb7e7b6dd3b601eae76f14c31d467ad70f40cb4183de0e82f5af619c721
bytes_inner.rs https://github.com/RustPython/RustPython/pull/8312/files#diff-94a4e578864d9ec94d59e2b7f57ea8f5a67aa734d28847c8921202237f2156b7
Lib/test/test_bytes.pyhttps://github.com/RustPython/RustPython/pull/8312/files#diff-58df2535f64e3dcfb0677a7f543924d976fd982b595f8e34902a73f3deae40eb
View file https://github.com/RustPython/RustPython/blob/7f2670d42bc5d64fd71de30987941dff422a0b1a/Lib/test/test_bytes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8312/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8312/files#diff-58df2535f64e3dcfb0677a7f543924d976fd982b595f8e34902a73f3deae40eb
https://github.com/RustPython/RustPython/pull/8312/files#diff-58df2535f64e3dcfb0677a7f543924d976fd982b595f8e34902a73f3deae40eb
Lib/test/test_memoryview.pyhttps://github.com/RustPython/RustPython/pull/8312/files#diff-d41c6bb40a1e03fea5a20d15c4077413e0ddde65651147922b625b03a66a2f16
View file https://github.com/RustPython/RustPython/blob/7f2670d42bc5d64fd71de30987941dff422a0b1a/Lib/test/test_memoryview.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8312/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8312/files#diff-d41c6bb40a1e03fea5a20d15c4077413e0ddde65651147922b625b03a66a2f16
https://github.com/RustPython/RustPython/pull/8312/files#diff-d41c6bb40a1e03fea5a20d15c4077413e0ddde65651147922b625b03a66a2f16
crates/vm/src/builtins/bytearray.rshttps://github.com/RustPython/RustPython/pull/8312/files#diff-bd8962db12555ddc9945c543b57069611c9b3f24f133fbf3a76c7c60fe1cfddd
View file https://github.com/RustPython/RustPython/blob/7f2670d42bc5d64fd71de30987941dff422a0b1a/crates/vm/src/builtins/bytearray.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8312/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8312/files#diff-bd8962db12555ddc9945c543b57069611c9b3f24f133fbf3a76c7c60fe1cfddd
https://github.com/RustPython/RustPython/pull/8312/files#diff-bd8962db12555ddc9945c543b57069611c9b3f24f133fbf3a76c7c60fe1cfddd
https://github.com/RustPython/RustPython/pull/8312/files#diff-bd8962db12555ddc9945c543b57069611c9b3f24f133fbf3a76c7c60fe1cfddd
https://github.com/RustPython/RustPython/pull/8312/files#diff-bd8962db12555ddc9945c543b57069611c9b3f24f133fbf3a76c7c60fe1cfddd
crates/vm/src/builtins/bytes.rshttps://github.com/RustPython/RustPython/pull/8312/files#diff-6b402f3feb41119eef6e230cb7efe615c9804a4ed5ce25dc9121ed85ed495343
View file https://github.com/RustPython/RustPython/blob/7f2670d42bc5d64fd71de30987941dff422a0b1a/crates/vm/src/builtins/bytes.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8312/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8312/files#diff-6b402f3feb41119eef6e230cb7efe615c9804a4ed5ce25dc9121ed85ed495343
https://github.com/RustPython/RustPython/pull/8312/files#diff-6b402f3feb41119eef6e230cb7efe615c9804a4ed5ce25dc9121ed85ed495343
https://github.com/RustPython/RustPython/pull/8312/files#diff-6b402f3feb41119eef6e230cb7efe615c9804a4ed5ce25dc9121ed85ed495343
https://github.com/RustPython/RustPython/pull/8312/files#diff-6b402f3feb41119eef6e230cb7efe615c9804a4ed5ce25dc9121ed85ed495343
crates/vm/src/builtins/memory.rshttps://github.com/RustPython/RustPython/pull/8312/files#diff-83fe7bb7e7b6dd3b601eae76f14c31d467ad70f40cb4183de0e82f5af619c721
View file https://github.com/RustPython/RustPython/blob/7f2670d42bc5d64fd71de30987941dff422a0b1a/crates/vm/src/builtins/memory.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8312/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8312/files#diff-83fe7bb7e7b6dd3b601eae76f14c31d467ad70f40cb4183de0e82f5af619c721
https://github.com/RustPython/RustPython/pull/8312/files#diff-83fe7bb7e7b6dd3b601eae76f14c31d467ad70f40cb4183de0e82f5af619c721
https://github.com/RustPython/RustPython/pull/8312/files#diff-83fe7bb7e7b6dd3b601eae76f14c31d467ad70f40cb4183de0e82f5af619c721
crates/vm/src/bytes_inner.rshttps://github.com/RustPython/RustPython/pull/8312/files#diff-94a4e578864d9ec94d59e2b7f57ea8f5a67aa734d28847c8921202237f2156b7
View file https://github.com/RustPython/RustPython/blob/7f2670d42bc5d64fd71de30987941dff422a0b1a/crates/vm/src/bytes_inner.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8312/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8312/files#diff-94a4e578864d9ec94d59e2b7f57ea8f5a67aa734d28847c8921202237f2156b7
youknowonehttps://github.com/youknowone
Jul 19, 2026https://github.com/RustPython/RustPython/pull/8312/files#r3609922720
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
devyubinhttps://github.com/devyubin
Jul 20, 2026https://github.com/RustPython/RustPython/pull/8312/files#r3617141677
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
https://github.com/RustPython/RustPython/pull/8312/files#diff-94a4e578864d9ec94d59e2b7f57ea8f5a67aa734d28847c8921202237f2156b7
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8312/files
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.