René's URL Explorer Experiment


Title: Match CPython's islower/isupper exactly by joshuamegnauth54 · Pull Request #7646 · RustPython/RustPython · GitHub

Open Graph Title: Match CPython's islower/isupper exactly by joshuamegnauth54 · Pull Request #7646 · RustPython/RustPython

X Title: Match CPython's islower/isupper exactly by joshuamegnauth54 · Pull Request #7646 · RustPython/RustPython

Description: This PR fixes a regression from my last islower/isupper patch. Python's Bytes doesn't assume an encoding, so methods like islower should only consider ASCII casing. I updated islower/isupper for UTF-8 and WTF-8 to match CPython exactly. The two functions now use the same properties as CPython and in the exact same way that CPython. I updated the unit tests to pass on Python 3.15. Unicode updates sometimes cause properties to shift. I previously tested everything on Python 3.14, but that lead to failures that I assumed were bugs but were actually due to Unicode differences. For example, U+0295 is a lower case letter in older Unicode versions but is NOT in newer versions. With Python 3.14: assert "\u0295".islower() assert not "\u0295".isupper() With Python 3.15 and RustPython: assert not "\u0295".islower() assert not "\u0295".isupper() assert not "\u0295".istitle() ^It's imperative to test with the latest Python because of Unicode differences. I, uh, spent like three hours trying to fix a bug that didn't exist because I was crosschecking the tests with Python 3.14... Oops. I bumped CI's Python version to 3.15 as well. Reverted because it's more complicated than I thought. Here is CPython's isupper implementation for comparison. CPython's core logic for islower (isupper is basically the same) /* Special case for empty strings */ if (length == 0) Py_RETURN_FALSE; cased = 0; for (i = 0; i < length; i++) { const Py_UCS4 ch = PyUnicode_READ(kind, data, i); if (Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) Py_RETURN_FALSE; else if (!cased && Py_UNICODE_ISLOWER(ch)) cased = 1; } return PyBool_FromLong(cased); RustPython's islower: let mut all_cased = false; for chunk in self.as_bytes().utf8_chunks().map(|c| c.valid()) { if chunk.chars().any(|c| { INVALID::for_char(c) || GeneralCategoryGroup::TitlecaseLetter.contains(GeneralCategory::for_char(c)) }) { return false; } if !all_cased && chunk.chars().any(VALID::for_char) { all_cased = true; } } all_cased They're the same now! 😁 Summary by CodeRabbit Bug Fixes Improved case-checking: text strings use Unicode casedness detection while byte/encoded checks use ASCII-only scanning, preventing misclassification for mixed/invalid byte sequences and certain rare or non-cased characters. Tests Updated and expanded tests for Unicode edge cases, version-dependent casing, non-cased scripts, and bytes case-checking with invalid/mixed sequences.

Open Graph Description: This PR fixes a regression from my last islower/isupper patch. Python's Bytes doesn't assume an encoding, so methods like islower should only consider ASCII casing. I updated islower/isuppe...

X Description: This PR fixes a regression from my last islower/isupper patch. Python&#39;s Bytes doesn&#39;t assume an encoding, so methods like islower should only consider ASCII casing. I updated islowe...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:89cf939a-7114-0fe6-d744-b0012e6216c9
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA640:6973B:5BEA12:7A7873:6A613DD7
html-safe-nonce7324eaaf8e5d8b285c986395e10257d5e8bd90bebf971877214f602466c5915b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjQwOjY5NzNCOjVCRUExMjo3QTc4NzM6NkE2MTNERDciLCJ2aXNpdG9yX2lkIjoiMTY1ODEwMDMzNTc1MDc1Nzg0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacdb07f6a892eb8eccc87570476f0c0c19c29d467b059cba26776da9b135ccd484
hovercard-subject-tagpull_request:3559611571
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/7646/files
twitter:imagehttps://avatars.githubusercontent.com/u/48846352?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/48846352?s=400&v=4
og:image:altThis PR fixes a regression from my last islower/isupper patch. Python's Bytes doesn't assume an encoding, so methods like islower should only consider ASCII casing. I updated islower/isuppe...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None2b7a3d1e6770dc7153450d820fcfe9a7851c4cf2251dcc29c7ad3c5cd1b9e88b
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
release78cf9d43f120d1f03636ca22ab420bcbb1712804
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/7646/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7646%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%2F7646%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/7646/files
Reloadhttps://github.com/RustPython/RustPython/pull/7646/files
Reloadhttps://github.com/RustPython/RustPython/pull/7646/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7646/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 293 https://github.com/RustPython/RustPython/issues
Pull requests 103 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
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
joshuamegnauth54:improve-islower-isupperhttps://github.com/joshuamegnauth54/RustPython/tree/improve-islower-isupper
Conversation 16 https://github.com/RustPython/RustPython/pull/7646
Commits 1 https://github.com/RustPython/RustPython/pull/7646/commits
Checks 19 https://github.com/RustPython/RustPython/pull/7646/checks
Files changed https://github.com/RustPython/RustPython/pull/7646/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7646/files
Match CPython's islower/isupper exactly https://github.com/RustPython/RustPython/pull/7646/files#top
Show all changes 1 commit https://github.com/RustPython/RustPython/pull/7646/files
043dbc5 Match CPython's islower/isupper exactly joshuamegnauth54 Apr 21, 2026 https://github.com/RustPython/RustPython/pull/7646/commits/043dbc57207f30e27de5cc9bb62c420eec5fad21
Clear filters https://github.com/RustPython/RustPython/pull/7646/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7646/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7646/files
anystr.rs https://github.com/RustPython/RustPython/pull/7646/files#diff-dd35a1000e2e6c0e7e4310bf9339045337d1db8ef9795c3cd7f2dbbb8f3dd809
str.rs https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
_thread.rs https://github.com/RustPython/RustPython/pull/7646/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
builtin_str.py https://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
builtin_str_encode.py https://github.com/RustPython/RustPython/pull/7646/files#diff-5ab3866289df2b39546a541c9a60ddbe76dd2a107416d9047f5df0ba2daec504
crates/vm/src/anystr.rshttps://github.com/RustPython/RustPython/pull/7646/files#diff-dd35a1000e2e6c0e7e4310bf9339045337d1db8ef9795c3cd7f2dbbb8f3dd809
View file https://github.com/joshuamegnauth54/RustPython/blob/043dbc57207f30e27de5cc9bb62c420eec5fad21/crates/vm/src/anystr.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7646/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7646/files#diff-dd35a1000e2e6c0e7e4310bf9339045337d1db8ef9795c3cd7f2dbbb8f3dd809
https://github.com/RustPython/RustPython/pull/7646/files#diff-dd35a1000e2e6c0e7e4310bf9339045337d1db8ef9795c3cd7f2dbbb8f3dd809
https://github.com/RustPython/RustPython/pull/7646/files#diff-dd35a1000e2e6c0e7e4310bf9339045337d1db8ef9795c3cd7f2dbbb8f3dd809
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7646/files
https://github.com/RustPython/RustPython/pull/7646/files#diff-dd35a1000e2e6c0e7e4310bf9339045337d1db8ef9795c3cd7f2dbbb8f3dd809
crates/vm/src/builtins/str.rshttps://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
View file https://github.com/joshuamegnauth54/RustPython/blob/043dbc57207f30e27de5cc9bb62c420eec5fad21/crates/vm/src/builtins/str.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7646/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/7646/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
crates/vm/src/stdlib/_thread.rshttps://github.com/RustPython/RustPython/pull/7646/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
View file https://github.com/joshuamegnauth54/RustPython/blob/043dbc57207f30e27de5cc9bb62c420eec5fad21/crates/vm/src/stdlib/_thread.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7646/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7646/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
https://github.com/RustPython/RustPython/pull/7646/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
extra_tests/snippets/builtin_str.pyhttps://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
View file https://github.com/joshuamegnauth54/RustPython/blob/043dbc57207f30e27de5cc9bb62c420eec5fad21/extra_tests/snippets/builtin_str.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7646/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
https://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
https://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
https://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
https://github.com/RustPython/RustPython/pull/7646/files#diff-6f5712e86d81a34dbc4b8137f08f43eccb65ef4b7bd548bfd6de8cc723ce41e7
extra_tests/snippets/builtin_str_encode.pyhttps://github.com/RustPython/RustPython/pull/7646/files#diff-5ab3866289df2b39546a541c9a60ddbe76dd2a107416d9047f5df0ba2daec504
View file https://github.com/joshuamegnauth54/RustPython/blob/043dbc57207f30e27de5cc9bb62c420eec5fad21/extra_tests/snippets/builtin_str_encode.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7646/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7646/files#diff-5ab3866289df2b39546a541c9a60ddbe76dd2a107416d9047f5df0ba2daec504
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7646/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.