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 — gh-91896: Revert some very noisy DeprecationWarnings for `ByteString` by AlexWaygood · Pull Request #104424 · python/cpython

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented May 12, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Emitting a DeprecationWarning every time ByteString is accessed or imported from collections.abc or typing is too noisy, as it effectively forbids anybody from doing from collections.abc import * or from typing import * if they want to avoid DeprecationWarnings. from typing import *, in particular, appears to be a common idiom so this looks as though it would be too disruptive. This was an error on my part; I'm sorry for the code churn here.

This PR reverts most of #104294, most of #104422, and all of #104416.

  • Issue: Deprecate and schedule removal of collections.abc.ByteString and typing.ByteString #91896

📚 Documentation preview 📚: https://cpython-previews--104424.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@AlexWaygood
Revert some very noisy DeprecationWarnings for ByteString
8718b98
@AlexWaygood
AlexWaygood requested review from Fidget-Spinner, JelleZijlstra, gvanrossum and rhettinger as code owners May 12, 2023 14:58
@bedevere-bot bedevere-bot added the awaiting core review label May 12, 2023
@bedevere-bot bedevere-bot mentioned this pull request May 12, 2023
Deprecate and schedule removal of collections.abc.ByteString and typing.ByteString #91896
Closed
@AlexWaygood AlexWaygood added skip news 3.12 only security fixes labels May 12, 2023
JelleZijlstra
JelleZijlstra approved these changes May 12, 2023
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!

I tried to think of ideas to do this better and couldn't think of anything:

  • Remove ByteString from __all__ for 3.12: this would be a backward compatibility break
  • Change the import * code to suppress DeprecationWarnings: way too magical
  • In the module __getattr__, somehow detect that we're being called from import *: no idea how to do that elegantly

Sorry, something went wrong.

Uh oh!

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

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels May 12, 2023
@AlexWaygood

AlexWaygood commented May 12, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Yeah, it's pretty frustrating that there isn't a better way of doing this :(

And this only happens because collections.abc and typing are following "best practices" and defining __all__. from ast import * doesn't cause any deprecation warnings to be emitted, even after 376137f, because ast doesn't define __all__, so the * import just looks at what's in globals(), and the module-level __getattr__ method is never triggered.

It feels somewhat perverse that defining __all__ makes life more difficult here :(

Fidget-Spinner reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

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

@AlexWaygood
AlexWaygood requested a review from hauntsaninja May 12, 2023 15:17
AlexWaygood
AlexWaygood commented May 12, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

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

AlexWaygood added 2 commits May 12, 2023 17:46
@AlexWaygood
Update Doc/whatsnew/3.12.rst
1afc689
@AlexWaygood
Merge branch 'main' into too-noisy
1a769be
@AlexWaygood
AlexWaygood merged commit c527eb1 into python:main May 13, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label May 13, 2023
@AlexWaygood
AlexWaygood deleted the too-noisy branch May 13, 2023 08:55
carljm added a commit to carljm/cpython that referenced this pull request May 15, 2023
@carljm
Merge branch 'main' into supermon
343867a
* main: (29 commits)
  pythongh-101819: Fix _io clinic input for unused base class method stubs (python#104418)
  pythongh-101819: Isolate `_io` (python#101948)
  Bump mypy from 1.2.0 to 1.3.0 in /Tools/clinic (python#104501)
  pythongh-104494: Update certain Tkinter pack/place tests for Tk 8.7 errors (python#104495)
  pythongh-104050: Run mypy on `clinic.py` in CI (python#104421)
  pythongh-104490: Consistently define phony make targets (python#104491)
  pythongh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined (python#104473)
  pythongh-104487: PYTHON_FOR_REGEN must be minimum Python 3.10 (python#104488)
  pythongh-101282: move BOLT config after PGO (pythongh-104493)
  pythongh-104469 Convert _testcapi/float.c to use AC (pythongh-104470)
  pythongh-104456: Fix ref leak in _ctypes.COMError (python#104457)
  pythongh-98539: Make _SSLTransportProtocol.abort() safe to call when closed (python#104474)
  pythongh-104337: Clarify random.gammavariate doc entry  (python#104410)
  Minor improvements to typing docs (python#104465)
  pythongh-87092: avoid gcc warning on uninitialized struct field in assemble.c (python#104460)
  pythonGH-71383: IDLE - Document testing subsets of modules (python#104463)
  pythongh-104454: Fix refleak in AttributeError_reduce (python#104455)
  pythongh-75710: IDLE - add docstrings and comments to editor module (python#104446)
  pythongh-91896: Revert some very noisy DeprecationWarnings for `ByteString` (python#104424)
  Add a mention of PYTHONBREAKPOINT to breakpoint() docs (python#104430)
  ...
carljm added a commit to carljm/cpython that referenced this pull request May 15, 2023
@carljm
Merge branch 'main' into cached_property_docs
452d9f5
* main: (204 commits)
  pythongh-101819: Fix _io clinic input for unused base class method stubs (python#104418)
  pythongh-101819: Isolate `_io` (python#101948)
  Bump mypy from 1.2.0 to 1.3.0 in /Tools/clinic (python#104501)
  pythongh-104494: Update certain Tkinter pack/place tests for Tk 8.7 errors (python#104495)
  pythongh-104050: Run mypy on `clinic.py` in CI (python#104421)
  pythongh-104490: Consistently define phony make targets (python#104491)
  pythongh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined (python#104473)
  pythongh-104487: PYTHON_FOR_REGEN must be minimum Python 3.10 (python#104488)
  pythongh-101282: move BOLT config after PGO (pythongh-104493)
  pythongh-104469 Convert _testcapi/float.c to use AC (pythongh-104470)
  pythongh-104456: Fix ref leak in _ctypes.COMError (python#104457)
  pythongh-98539: Make _SSLTransportProtocol.abort() safe to call when closed (python#104474)
  pythongh-104337: Clarify random.gammavariate doc entry  (python#104410)
  Minor improvements to typing docs (python#104465)
  pythongh-87092: avoid gcc warning on uninitialized struct field in assemble.c (python#104460)
  pythonGH-71383: IDLE - Document testing subsets of modules (python#104463)
  pythongh-104454: Fix refleak in AttributeError_reduce (python#104455)
  pythongh-75710: IDLE - add docstrings and comments to editor module (python#104446)
  pythongh-91896: Revert some very noisy DeprecationWarnings for `ByteString` (python#104424)
  Add a mention of PYTHONBREAKPOINT to breakpoint() docs (python#104430)
  ...
@AlexWaygood AlexWaygood mentioned this pull request Sep 16, 2025
Revert "gh-118803: Remove ByteString from typing and collections.abc (#118804)" #138990
Merged
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 Awaiting requested review from gvanrossum
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@hauntsaninja hauntsaninja Awaiting requested review from hauntsaninja

Uh oh!

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

Assignees

No one assigned

Labels

3.12 only security fixes 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.

3 participants

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