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 — `_overload_dummy` raises `NotImplementedError`, not `RuntimeError` by sobolevn · Pull Request #98351 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented Oct 17, 2022

Copy link
Copy Markdown
Member

Source:

cpython/Lib/typing.py

Lines 2536 to 2542 in eae7dad

def _overload_dummy(*args, **kwds):
"""Helper for @overload to raise when called."""
raise NotImplementedError(
"You should not call an overloaded function. "
"A series of @overload-decorated functions "
"outside a stub module should always be followed "
"by an implementation that is not @overload-ed.")

I've found this while looking for implicit abstract classes / methods in CPython.

Test was checking for RuntimeError, it is technically correct:

>>> NotImplementedError.__mro__
(<class 'NotImplementedError'>, <class 'RuntimeError'>, <class 'Exception'>, <class 'BaseException'>, <class 'object'>)

But, we can be more precise. It is a good thing.
I am going to skip creating an issue for this, it is like a typo-fix :)

Sorry, something went wrong.

Uh oh!

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

All reactions
@sobolevn
_overload_dummy raise NotImplementedError, not RuntimeError
6df37a2
@sobolevn
sobolevn requested review from Fidget-Spinner, JelleZijlstra and gvanrossum as code owners October 17, 2022 09:45
@bedevere-bot bedevere-bot added awaiting review tests Tests in the Lib/test dir labels Oct 17, 2022
@sobolevn sobolevn added skip issue skip news tests Tests in the Lib/test dir awaiting review and removed tests Tests in the Lib/test dir awaiting review labels Oct 17, 2022
@sobolevn sobolevn changed the title _overload_dummy raise NotImplementedError, not RuntimeError _overload_dummy raises NotImplementedError, not RuntimeError Oct 17, 2022
JelleZijlstra
JelleZijlstra approved these changes Oct 17, 2022
View reviewed changes

@JelleZijlstra JelleZijlstra 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.

Thanks for catching this!

I feel like RuntimeError is a better exception to throw than NotImplementedError here, but we've apparently always used NotImplementedError and it's not worth changing.

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 Oct 17, 2022
@JelleZijlstra JelleZijlstra self-assigned this Oct 17, 2022
@JelleZijlstra JelleZijlstra added needs backport to 3.11 only security fixes needs backport to 3.10 labels Oct 17, 2022
gvanrossum
gvanrossum approved these changes Oct 17, 2022
View reviewed changes
Fidget-Spinner
Fidget-Spinner approved these changes Oct 18, 2022
View reviewed changes
@JelleZijlstra
JelleZijlstra merged commit 1ca6647 into python:main Oct 20, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Oct 20, 2022
@miss-islington

miss-islington commented Oct 20, 2022

Copy link
Copy Markdown
Contributor

Thanks @sobolevn for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington

miss-islington commented Oct 20, 2022

Copy link
Copy Markdown
Contributor

Sorry, @sobolevn and @JelleZijlstra, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 1ca6647f22794f0a0c982ecb03e764db76d51087 3.10

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Oct 20, 2022

Copy link
Copy Markdown

GH-98470 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 Oct 20, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 20, 2022
@sobolevn @miss-islington
typing tests: _overload_dummy raises NotImplementedError, not `Ru…
9d80421
…ntimeError` (pythonGH-98351)

(cherry picked from commit 1ca6647)

Co-authored-by: Nikita Sobolev <[email protected]>
@JelleZijlstra JelleZijlstra removed the needs backport to 3.10 label Oct 20, 2022
@JelleZijlstra

JelleZijlstra commented Oct 20, 2022

Copy link
Copy Markdown
Member

These tests don't exist in 3.10.

All reactions

Sorry, something went wrong.

Uh oh!

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

miss-islington added a commit that referenced this pull request Oct 20, 2022
@miss-islington @sobolevn
typing tests: _overload_dummy raises NotImplementedError, not `Ru…
5f5fa4c
…ntimeError` (GH-98351)

(cherry picked from commit 1ca6647)

Co-authored-by: Nikita Sobolev <[email protected]>
carljm added a commit to carljm/cpython that referenced this pull request Oct 20, 2022
@carljm
Merge branch 'main' into typewatch
8bba5da
* main: (40 commits)
  pythongh-98461: Fix source location in comprehensions bytecode (pythonGH-98464)
  pythongh-98421: Clean Up PyObject_Print (pythonGH-98422)
  pythongh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments (pythonGH-98462)
  CODEOWNERS: Become a typing code owner (python#98480)
  [doc] Improve logging cookbook example. (pythonGH-98481)
  Add more tkinter.Canvas tests (pythonGH-98475)
  pythongh-95023: Added os.setns and os.unshare functions (python#95046)
  pythonGH-98363: Presize the list for batched() (pythonGH-98419)
  pythongh-98374: Suppress ImportError for invalid query for help() command. (pythongh-98450)
  typing tests: `_overload_dummy` raises `NotImplementedError`, not `RuntimeError` (python#98351)
  pythongh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (pythonGH-98412)
  pythongh-98257: Make _PyEval_SetTrace() reentrant (python#98258)
  pythongh-98414: py.exe launcher does not use defaults for -V:company/ option (pythonGH-98460)
  pythongh-98417: Store int_max_str_digits on the Interpreter State (pythonGH-98418)
  Doc: Remove title text from internal links (python#98409)
  [doc] Refresh the venv introduction documentation, and correct the statement about VIRTUAL_ENV (pythonGH-98350)
  Docs: Bump sphinx-lint and fix unbalanced inline literal markup (python#98441)
  pythongh-92886: Replace assertion statements in `handlers.BaseHandler` to support running with optimizations (`-O`) (pythonGH-93231)
  pythongh-92886: Fix tests that fail when running with optimizations (`-O`) in `_test_multiprocessing.py` (pythonGH-93233)
  pythongh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (pythonGH-93235)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@gvanrossum gvanrossum gvanrossum approved these changes
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes

Uh oh!

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

Assignees

@JelleZijlstra JelleZijlstra

Labels

skip issue skip news tests Tests in the Lib/test dir

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.

6 participants

@sobolevn @miss-islington @bedevere-bot @JelleZijlstra @gvanrossum @Fidget-Spinner
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.