Skip to content
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

bpo-39200: Correct the error message for range() empty constructor #17813

Merged
merged 4 commits into from Jan 5, 2020

Conversation

@pablogsal
Copy link
Member

pablogsal commented Jan 3, 2020

@pablogsal pablogsal force-pushed the pablogsal:bpo-39200 branch from 3b628b2 to 7a5723d Jan 3, 2020
Copy link
Member

corona10 left a comment

For me, this is more correct :)

Copy link
Member

serhiy-storchaka left a comment

Would be nice to add tests.

Objects/rangeobject.c Outdated Show resolved Hide resolved
@serhiy-storchaka

This comment has been minimized.

Copy link
Member

serhiy-storchaka commented Jan 3, 2020

Other option - just use PyArg_UnpackTuple(args, "range", 1, 3, &start, &stop, &step) and check if stop == NULL.

@pablogsal

This comment has been minimized.

Copy link
Member Author

pablogsal commented Jan 3, 2020

Other option - just use PyArg_UnpackTuple(args, "range", 1, 3, &start, &stop, &step) and check if stop == NULL.

I have implemented the switch statement as we would need to do the dance with step and start anyway and I find the switch statement a bit more clear.

@pablogsal

This comment has been minimized.

Copy link
Member Author

pablogsal commented Jan 3, 2020

Would be nice to add tests.

Done in eb9e784

@pablogsal pablogsal force-pushed the pablogsal:bpo-39200 branch 2 times, most recently from e73eab4 to eb9e784 Jan 3, 2020
@pablogsal

This comment has been minimized.

Copy link
Member Author

pablogsal commented Jan 3, 2020

Btw, as a bonus the constructor of range is anecdotally faster:

master

./python.exe -m pyperf timeit "range(1,3,4)"
.....................
Mean +- std dev: 893 ns +- 44 ns

patched

./python.exe -m pyperf timeit "range(1,3,4)"
.....................
Mean +- std dev: 822 ns +- 14 ns

Copy link
Member

corona10 left a comment

@pablogsal I left comments on test code :)

Lib/test/test_range.py Outdated Show resolved Hide resolved
Lib/test/test_range.py Outdated Show resolved Hide resolved
@pablogsal pablogsal force-pushed the pablogsal:bpo-39200 branch from eb9e784 to f8c70ad Jan 4, 2020
Objects/rangeobject.c Outdated Show resolved Hide resolved
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_range.py Outdated Show resolved Hide resolved
Lib/test/test_range.py Outdated Show resolved Hide resolved
Objects/rangeobject.c Outdated Show resolved Hide resolved
Objects/rangeobject.c Outdated Show resolved Hide resolved
Objects/rangeobject.c Outdated Show resolved Hide resolved
@pablogsal pablogsal merged commit 4b66fa6 into python:master Jan 5, 2020
9 checks passed
9 checks passed
Docs
Details
Windows (x86)
Details
Windows (x64)
Details
macOS
Details
Ubuntu
Details
Azure Pipelines PR #20200104.13 succeeded
Details
bedevere/issue-number Issue number 39200 found
Details
bedevere/news News entry found in Misc/NEWS.d
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@pablogsal pablogsal deleted the pablogsal:bpo-39200 branch Jan 5, 2020
gousaiyang added a commit to gousaiyang/cpython that referenced this pull request Jan 8, 2020
@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jan 10, 2020

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒🤖

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jan 10, 2020
…ythonGH-17813)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 4b66fa6)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jan 10, 2020

GH-17940 is a backport of this pull request to the 3.8 branch.

@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jan 10, 2020

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒🤖

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jan 10, 2020
…ythonGH-17813)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 4b66fa6)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jan 10, 2020

GH-17942 is a backport of this pull request to the 3.7 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.