René's URL Explorer Experiment


Title: Convert `reverse` by truth value in `sorted()` and `list.sort()` by jseop-lim · Pull Request #9926 · RustPython/RustPython · GitHub

Open Graph Title: Convert `reverse` by truth value in `sorted()` and `list.sort()` by jseop-lim · Pull Request #9926 · RustPython/RustPython

X Title: Convert `reverse` by truth value in `sorted()` and `list.sort()` by jseop-lim · Pull Request #9926 · RustPython/RustPython

Description: Part of #9913 (item 16) This PR follows our AI policy Summary SortOptions binds reverse as a Rust bool, whose conversion accepts only int instances, so sorted() and list.sort() reject any other object. CPython converts it with PyObject_IsTrue. AS-IS >>> sorted([1, 2, 3], reverse=None) TypeError: Expected type bool, not NoneType >>> sorted([1, 2, 3], reverse="x") TypeError: Expected type bool, not str TO-BE >>> sorted([1, 2, 3], reverse=None) [1, 2, 3] >>> sorted([1, 2, 3], reverse="x") [3, 2, 1] (matching CPython 3.15.2) Changes In crates/vm/src/builtins/list.rs, bind SortOptions::reverse as an object and convert it by truth value in PyList::sort, so sorted() reads its iterable first, as CPython does. The text signatures of sorted and list.sort are unchanged. Extend extra_tests/snippets/builtin_list.py with sorted() and list.sort() given an object whose __bool__ returns True, sorted() given an empty list, and a __bool__ that raises given with a list and with None as the iterable. Test plan Built and run on macOS aarch64 against upstream/main 7abccf0, using the CI feature set --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc,ucd_3_2_0, plus threading, compared with CPython 3.15.2. The extended extra_tests/snippets/builtin_list.py fails on an unpatched build of that commit (TypeError: Expected type bool, not Truthy) and passes with the patch and under CPython 3.15.2. reverse given None, a str, 0.0 and an object whose __bool__ raises gives the same result as CPython 3.15.2, the last one propagating the exception. sorted(It(), key=key, reverse=K()) calls __iter__, __bool__ and key in CPython's order, and sorted(None, reverse=...) raises the TypeError for None before __bool__ runs. rustpython -m test test_sort test_list test_builtin: 246 run, 15 skipped, all pass, as on the unpatched build. cargo fmt --check clean, cargo clippy -p rustpython-vm -p rustpython-stdlib --all-targets adds no warning, and the pre-commit hooks other than cspell and prettier pass on both changed files. I used Claude Code (claude-fable-5-2) to draft the analysis, the patch and this description; Claude Code ran the commands above; I reviewed the diff and their output.

Open Graph Description: Part of #9913 (item 16) This PR follows our AI policy Summary SortOptions binds reverse as a Rust bool, whose conversion accepts only int instances, so sorted() and list.sort() reject any other o...

X Description: Part of #9913 (item 16) This PR follows our AI policy Summary SortOptions binds reverse as a Rust bool, whose conversion accepts only int instances, so sorted() and list.sort() reject any other o...

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

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:fa4601cd-cd1b-9524-a245-57b86fbffbcb
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB710:14700E:338CE30:417CA32:6B01D7F9
html-safe-noncee75c335cb3493de63e92a3d8140bca670c25fb842c95b0aeeec9a14fb9d481c6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzEwOjE0NzAwRTozMzhDRTMwOjQxN0NBMzI6NkIwMUQ3RjkiLCJ2aXNpdG9yX2lkIjoiNTM3NjM3MzYwNjg5OTExMTkyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8ad49a6a9719a160666c96175e4f706e7a805c13860d01aa6cf8704e64fa720c
hovercard-subject-tagpull_request:5361512370
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/9926/files
twitter:imagehttps://avatars.githubusercontent.com/u/86508420?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/86508420?s=400&v=4
og:image:altPart of #9913 (item 16) This PR follows our AI policy Summary SortOptions binds reverse as a Rust bool, whose conversion accepts only int instances, so sorted() and list.sort() reject any other o...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/9926/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9926%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%2FRustPython%2FRustPython%2Fpull%2F9926%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=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/9926/files
Reloadhttps://github.com/RustPython/RustPython/pull/9926/files
Reloadhttps://github.com/RustPython/RustPython/pull/9926/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests132 (132)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
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
jseop-limhttps://github.com/jseop-lim
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
jseop-lim:fix/sort-reverse-truthinesshttps://github.com/jseop-lim/RustPython/tree/fix/sort-reverse-truthiness
Conversation 3 https://github.com/RustPython/RustPython/pull/9926
Commits 1 https://github.com/RustPython/RustPython/pull/9926/commits
Checks 20 https://github.com/RustPython/RustPython/pull/9926/checks
Files changed 2 https://github.com/RustPython/RustPython/pull/9926/files
Convert reverse by truth value in sorted() and list.sort() https://github.com/RustPython/RustPython/pull/9926/files#top
Show all changes 1 commit https://github.com/RustPython/RustPython/pull/9926/files
28c266d Convert `reverse` by truth value in `sorted()` and `list.sort()` jseop-lim Nov 17, 2026 https://github.com/RustPython/RustPython/pull/9926/commits/28c266d6e6f69b9435a5f340fbffe82aa34a4f03
Clear filters https://github.com/RustPython/RustPython/pull/9926/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9926/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9926/files
list.rs https://github.com/RustPython/RustPython/pull/9926/files#diff-986ff77d786ffa03f6bd07be740a9700539c8eed99bcdff88a999a011269f240
builtin_list.py https://github.com/RustPython/RustPython/pull/9926/files#diff-bfcc3e046c1f1e5e6c4444055872e48144c05521cda26f8b2fc632c9099ec9ca
crates/vm/src/builtins/list.rshttps://github.com/RustPython/RustPython/pull/9926/files#diff-986ff77d786ffa03f6bd07be740a9700539c8eed99bcdff88a999a011269f240
View file https://github.com/RustPython/RustPython/blob/28c266d6e6f69b9435a5f340fbffe82aa34a4f03/crates/vm/src/builtins/list.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9926/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9926/files#diff-986ff77d786ffa03f6bd07be740a9700539c8eed99bcdff88a999a011269f240
youknowonehttps://github.com/youknowone
Nov 18, 2026https://github.com/RustPython/RustPython/pull/9926/files#r4607928893
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9926/files
https://github.com/RustPython/RustPython/pull/9926/files#diff-986ff77d786ffa03f6bd07be740a9700539c8eed99bcdff88a999a011269f240
https://github.com/RustPython/RustPython/pull/9926/files#diff-986ff77d786ffa03f6bd07be740a9700539c8eed99bcdff88a999a011269f240
https://github.com/RustPython/RustPython/pull/9926/files#diff-986ff77d786ffa03f6bd07be740a9700539c8eed99bcdff88a999a011269f240
extra_tests/snippets/builtin_list.pyhttps://github.com/RustPython/RustPython/pull/9926/files#diff-bfcc3e046c1f1e5e6c4444055872e48144c05521cda26f8b2fc632c9099ec9ca
View file https://github.com/RustPython/RustPython/blob/28c266d6e6f69b9435a5f340fbffe82aa34a4f03/extra_tests/snippets/builtin_list.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9926/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9926/files#diff-bfcc3e046c1f1e5e6c4444055872e48144c05521cda26f8b2fc632c9099ec9ca
https://github.com/RustPython/RustPython/pull/9926/files#diff-bfcc3e046c1f1e5e6c4444055872e48144c05521cda26f8b2fc632c9099ec9ca
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9926/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.