Skip to content

objrange: Allow return of non-small ints. #17685

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Jul 15, 2025

Summary

Closes #17684.

Testing

I wrote new tests & ran the unix coverage tests locally.

Trade-offs and Alternatives

Given that values between the "small int" range and "machine int" range never worked with range(), maybe non "small int"
range() arguments should be rejected instead. However, this would be a bit contradictory as you expect to have ranges with elements up to sys.maxsize at least.

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.44%. Comparing base (5e9189d) to head (8a31551).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17685   +/-   ##
=======================================
  Coverage   98.44%   98.44%           
=======================================
  Files         171      171           
  Lines       22204    22205    +1     
=======================================
+ Hits        21859    21860    +1     
  Misses        345      345           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:   +10 +0.005% 
   unix x64:   +48 +0.006% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:   +12 +0.003% VIRT_RV32

jepler added 2 commits July 15, 2025 16:55
Signed-off-by: Jeff Epler <jepler@gmail.com>
The magnitude of range() arguments is not restricted to "small"
ints, but includes "machine ints" which fit inside a register
but can only be represented as "long integer" objects in Python.

Signed-off-by: Jeff Epler <jepler@gmail.com>
@jepler jepler changed the title tests: Test extremes of range() objrange: Allow return of non-small ints. Jul 15, 2025
@bsdphk
Copy link

bsdphk commented Jul 15, 2025

This PR works in the code where #17684 was found.

Thanks a lot!

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

range() returns wrong results across 1<<31
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy