Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Remove return code type check. #573

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

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

phst
Copy link
Contributor

@phst phst commented Nov 18, 2021

Only floating-point objects have an is_integer
method (cf. https://docs.python.org/3.10/library/stdtypes.html#typesnumeric),
so this will actually raise an AttributeError whenever the main function
returns an integer or None. sys.exit works just fine with any argument type,
so there’s no need to check anything. The example at
https://packaging.python.org/specifications/entry-points/#use-for-scripts also
doesn’t contain a type check.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Does not include precompiled binaries, eg. .par files. See CONTRIBUTING.md for info
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Only floating-point objects have an is_integer
method (cf. https://docs.python.org/3.10/library/stdtypes.html#typesnumeric),
so this will actually raise an AttributeError whenever the main function
returns an integer or None.  sys.exit works just fine with any argument type,
so there’s no need to check anything.  The example at
https://packaging.python.org/specifications/entry-points/#use-for-scripts also
doesn’t contain a type check.
@phst phst requested review from brandjon and lberki as code owners November 18, 2021 16:42
@google-cla google-cla bot added the cla: yes label Nov 18, 2021
@thundergolfer thundergolfer requested review from thundergolfer and removed request for brandjon and lberki November 19, 2021 00:30
Copy link

@thundergolfer thundergolfer left a comment

Choose a reason for hiding this comment

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

Happy with this change

https://github.com/python/cpython/blob/main/Python/sysmodule.c#L837 lays out the argument handling of sys.exit nicely. Non-integer is handled, and treated as exit(1).

@thundergolfer thundergolfer merged commit 288df22 into bazel-contrib:main Nov 23, 2021
@phst phst deleted the entrypoint-retcode branch November 23, 2021 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.