GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Move around example in to_bytes() to avoid confusion by skirpichev · Pull Request #101595 · python/cpython

Conversation

@skirpichev

@skirpichev skirpichev commented Feb 6, 2023

Copy link
Copy Markdown
Member

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

arhadthedev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@skirpichev
Fix typo in the int.to_bytes() docs, now it shows an OverflowError
3c3571a
@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Feb 6, 2023
@arhadthedev arhadthedev added the skip issue label Feb 6, 2023
@arhadthedev

arhadthedev commented Feb 6, 2023

Copy link
Copy Markdown
Member

Can confirm that a paragraph don't try to convert a value greater than 255 or you'll get an OverflowError incorrectly has a non-throwing example.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@arhadthedev arhadthedev changed the title Fix typo in the int.to_bytes() docs, now it shows an OverflowError Fix an incorrect example in the int.to_bytes() docs, now it shows an OverflowError Feb 6, 2023
@mdickinson

mdickinson commented Feb 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I suspect the intent of the example was to support the

The default values can be used to conveniently turn an integer into a single byte object.

statement rather than the

... don't try to convert a value greater than 255 ...

statement.

Maybe @warsaw can confirm or deny?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev

skirpichev commented Feb 6, 2023

Copy link
Copy Markdown
Member Author

Anyway, across the docs a pattern "don't do this and that or you'll get XYZ:" usually coming with a doctest, where you actually get XYZ...

Maybe we should just drop this example? The text is clear enough.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev

skirpichev commented Mar 4, 2023

Copy link
Copy Markdown
Member Author

@mdickinson , probably you can decide, nobody else do care.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev
Merge branch 'main' into to_bytes-docs
a72bea3
@mdickinson

mdickinson commented Mar 4, 2023

Copy link
Copy Markdown
Member

I don't think the example should be changed here. If we want to reduce confusion, how about just moving things around so that the example immediately follows the "The default values can be used to conveniently turn an integer into a single byte object." statement?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

skirpichev added 2 commits March 4, 2023 14:09
@skirpichev
Merge branch 'main' into to_bytes-docs
52aee02
@skirpichev
Move around example in to_bytes() to avoid confusion with remark abou…
fb579b0
…t exception
@skirpichev

skirpichev commented Mar 4, 2023

Copy link
Copy Markdown
Member Author

If we want to reduce confusion

That was the point.

how about just moving things around

Does make sense for me. See an attempt.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev skirpichev changed the title Fix an incorrect example in the int.to_bytes() docs, now it shows an OverflowError Move around example in to_bytes() to avoid confusion Mar 5, 2023
mdickinson
mdickinson approved these changes Mar 5, 2023
View reviewed changes

@mdickinson mdickinson left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Mar 5, 2023
@mdickinson mdickinson added the needs backport to 3.11 only security fixes label Mar 5, 2023
@mdickinson
mdickinson merged commit 5da379c into python:main Mar 5, 2023
@miss-islington

miss-islington commented Mar 5, 2023

Copy link
Copy Markdown
Contributor

Thanks @skirpichev for the PR, and @mdickinson for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label Mar 5, 2023
@bedevere-bot

bedevere-bot commented Mar 5, 2023

Copy link
Copy Markdown

GH-102434 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Mar 5, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 5, 2023
@skirpichev @miss-islington
Move around example in to_bytes() to avoid confusion (pythonGH-101595)
0cd4d9b
Moves an example to be closer to the sentence that refers to it.
(cherry picked from commit 5da379c)

Co-authored-by: Sergey B Kirpichev <[email protected]>
@skirpichev
skirpichev deleted the to_bytes-docs branch March 5, 2023 09:40
mdickinson pushed a commit that referenced this pull request Mar 5, 2023
@miss-islington @skirpichev
[3.11] Move around example in to_bytes() to avoid confusion (GH-101595)…
caff048
… (#102434)

Move around example in to_bytes() to avoid confusion (GH-101595)

Moves an example to be closer to the sentence that refers to it.
(cherry picked from commit 5da379c)

Co-authored-by: Sergey B Kirpichev <[email protected]>
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 6, 2023
@skirpichev @hugovk
Move around example in to_bytes() to avoid confusion (python#101595)
dde16c4
Moves an example to be closer to the sentence that refers to it.
carljm added a commit to carljm/cpython that referenced this pull request Mar 6, 2023
@carljm
Merge branch 'main' into nodeaddict
33dda2a
* main: (21 commits)
  pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472)
  pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455)
  pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467)
  pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667)
  pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664)
  pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665)
  pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445)
  pythonGH-102341: Improve the test function for pow (python#102342)
  Fix unused classes in a typing test (pythonGH-102437)
  pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318)
  pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426)
  Move around example in to_bytes() to avoid confusion (python#101595)
  pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421)
  pythongh-96821: Add config option `--with-strict-overflow` (python#96823)
  pythongh-101992: update pstlib module documentation (python#102133)
  pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699)
  pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417)
  pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303)
  pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180)
  pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896)
  ...
carljm added a commit to carljm/cpython that referenced this pull request Mar 7, 2023
@carljm
Merge branch 'main' into inlinecomp2
ecb313c
* main: (37 commits)
  pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472)
  pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455)
  pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467)
  pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667)
  pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664)
  pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665)
  pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445)
  pythonGH-102341: Improve the test function for pow (python#102342)
  Fix unused classes in a typing test (pythonGH-102437)
  pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318)
  pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426)
  Move around example in to_bytes() to avoid confusion (python#101595)
  pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421)
  pythongh-96821: Add config option `--with-strict-overflow` (python#96823)
  pythongh-101992: update pstlib module documentation (python#102133)
  pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699)
  pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417)
  pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303)
  pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180)
  pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@mdickinson mdickinson mdickinson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@skirpichev @arhadthedev @mdickinson @miss-islington @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.