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-104773: PEP 594: Remove the imghdr module by vstinner · Pull Request #104777 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented May 23, 2023 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Remove the Lib/test/imghdrdata/ directory.
  • Copy 5 pictures (gif, png, ppm, pgm, xbm) from removed Lib/test/imghdrdata/ to a new Lib/test/tkinterdata/ directory.
  • Issue: PEP 594: Remove stdlib modules scheduled for deletion in Python 3.13 #104773

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label May 23, 2023
@bedevere-bot bedevere-bot mentioned this pull request May 23, 2023
PEP 594: Remove stdlib modules scheduled for deletion in Python 3.13 #104773
Closed
19 tasks done
@vstinner

vstinner commented May 23, 2023

Copy link
Copy Markdown
Member Author

The Docs CI job fails with:

Could not import extension sphinx.builders.epub3 (exception: No module named 'imghdr')

Oh. It seems like the Sphinx EPUB builder requires the removed imghdr module.

cc @JulienPalard @deronnax

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@hugovk

hugovk commented May 23, 2023

Copy link
Copy Markdown
Member

Sphinx used to depend on imghdr, but no longer does as of Sphinx 6.2.0:

  • imghdr is deprecated and slated for removal in Python 3.13 sphinx-doc/sphinx#10440 (comment)
  • sphinx-doc/sphinx@a502e75
  • https://github.com/sphinx-doc/sphinx/releases/tag/v6.2.0

Therefore we'll need to start using Sphinx 6.2.0 for Python 3.13.

cc @AA-Turner @CAM-Gerlach.

All reactions

Sorry, something went wrong.

Uh oh!

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

@JulienPalard

JulienPalard commented May 23, 2023

Copy link
Copy Markdown
Member

Therefore we'll need to start using Sphinx 6.2.0 for Python 3.13.

@doko42 would it be managable from a Debian packaging point of view?

Do we have some contacts with other distribs?

I remember the last bump of needs_sphinx raised a lot of concerns.

All reactions

Sorry, something went wrong.

Uh oh!

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

@hugovk

hugovk commented May 23, 2023

Copy link
Copy Markdown
Member

@encukou Is requiring Sphinx 6.2.0 for Python 3.13 okay for Red Hat?

All reactions

Sorry, something went wrong.

Uh oh!

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

@hugovk
hugovk self-requested a review May 23, 2023 09:44
hugovk
hugovk reviewed May 23, 2023
View reviewed changes

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

Avoid new Sphinx warnings:

diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 7a479c6e56..9b33155c5a 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -1735,7 +1735,7 @@ Modules
   +---------------------+---------------------+---------------------+---------------------+---------------------+
   | :mod:`audioop`      | :mod:`crypt`        | :mod:`nis`          | :mod:`sndhdr`       | :mod:`uu`           |
   +---------------------+---------------------+---------------------+---------------------+---------------------+
-  | :mod:`cgi`          | :mod:`imghdr`       | :mod:`nntplib`      | :mod:`spwd`         | :mod:`xdrlib`       |
+  | :mod:`cgi`          | :mod:`!imghdr`      | :mod:`nntplib`      | :mod:`spwd`         | :mod:`xdrlib`       |
   +---------------------+---------------------+---------------------+---------------------+---------------------+
   | :mod:`cgitb`        | :mod:`mailcap`      | :mod:`ossaudiodev`  | :mod:`sunau`        |                     |
   +---------------------+---------------------+---------------------+---------------------+---------------------+
diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
index 14b6425cea..d13036f6fd 100644
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -1252,7 +1252,7 @@ Oberkirch in :issue:`21800`.)
 imghdr
 ------
 
-The :func:`~imghdr.what` function now recognizes the
+The :func:`!imghdr.what` function now recognizes the
 `OpenEXR <https://www.openexr.com>`_ format
 (contributed by Martin Vignali and Claudiu Popa in :issue:`20295`),
 and the `WebP <https://en.wikipedia.org/wiki/WebP>`_ format

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/whatsnew/3.12.rst Outdated
* :mod:`chunk`
* :mod:`crypt`
* :mod:`imghdr`
* ``imghdr``

@hugovk hugovk May 23, 2023

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.

Suggested change
* ``imghdr``
* :mod:`!imghdr`

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/whatsnew/3.13.rst
`filetype <https://pypi.org/project/filetype/>`_,
`puremagic <https://pypi.org/project/puremagic/>`_,
or `python-magic <https://pypi.org/project/python-magic/>`_ instead.
(Contributed by Victor Stinner in :gh:`104773`.)

@hugovk hugovk May 23, 2023

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.

Reference the PEP.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Misc/NEWS.d/next/Library/2023-05-23-02-13-11.gh-issue-104773.JNiEjv.rst Outdated
Remove the ``imghdr`` module, deprecated in Python 3.11: use the projects
`filetype <https://pypi.org/project/filetype/>`_, `puremagic
<https://pypi.org/project/puremagic/>`_, or `python-magic
<https://pypi.org/project/python-magic/>`_ instead. Patch by Victor Stinner.

@hugovk hugovk May 23, 2023

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.

Reference the PEP.

Sorry, something went wrong.

Uh oh!

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

All reactions
@encukou

encukou commented May 23, 2023

Copy link
Copy Markdown
Member

Is requiring Sphinx 6.2.0 for Python 3.13 okay for Red Hat?

Yes. It's OK for Fedora. (And RHEL will follow Fedora after some time.)

All reactions

Sorry, something went wrong.

Uh oh!

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

@AA-Turner

AA-Turner commented May 23, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Avoid new Sphinx warnings:

diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
index 14b6425cea..d13036f6fd 100644
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -1252,7 +1252,7 @@ Oberkirch in :issue:`21800`.)
 imghdr
 ------
 
-The :func:`~imghdr.what` function now recognizes the
+The :func:`!imghdr.what` function now recognizes the
...

We should likely prefer :func:`~!imghdr.what` to keep the rendered HTML showing only what.

A

All reactions

Sorry, something went wrong.

Uh oh!

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

AA-Turner
AA-Turner reviewed May 23, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.13.rst Outdated
Removed
=======

* Remove the ``imghdr`` module, deprecated in Python 3.11: use the projects

@AA-Turner AA-Turner May 23, 2023

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.

Suggested change
* Remove the ``imghdr`` module, deprecated in Python 3.11: use the projects
* Remove the :mod:`!imghdr` module, deprecated in Python 3.11: use the projects

Sorry, something went wrong.

Uh oh!

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

All reactions
AA-Turner
AA-Turner reviewed May 23, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-05-23-02-13-11.gh-issue-104773.JNiEjv.rst Outdated
@@ -0,0 +1,4 @@
Remove the ``imghdr`` module, deprecated in Python 3.11: use the projects

@AA-Turner AA-Turner May 23, 2023

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.

Suggested change
Remove the ``imghdr`` module, deprecated in Python 3.11: use the projects
Remove the :mod:`!imghdr` module, deprecated in Python 3.11: use the projects

Sorry, something went wrong.

Uh oh!

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

All reactions
@AA-Turner

AA-Turner commented May 23, 2023

Copy link
Copy Markdown
Member

OpenSUSE is using Sphinx 7 for Python 3.12 builds

Debian and Ubuntu are the only remaining distributions from the list we checked last time.

A

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner mentioned this pull request May 23, 2023
Require Sphinx 6.2 to build Python 3.13 documentation #104818
Closed
@vstinner

vstinner commented May 23, 2023

Copy link
Copy Markdown
Member Author

I created issue #104818 "Require Sphinx 6.2 to build Python 3.13 documentation". I propose to discuss updating Sphinx (or not) there.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner marked this pull request as draft May 24, 2023 12:56
@bedevere-bot bedevere-bot removed the awaiting core review label May 24, 2023
@vstinner vstinner changed the title gh-104773: PEP 594: Remove the imghdr module WIP (blocked by Sphinx): gh-104773: PEP 594: Remove the imghdr module May 24, 2023
@vstinner
vstinner force-pushed the remove_imghdr branch from e39d2ed to d2d6d86 Compare May 25, 2023 16:33
@vstinner

vstinner commented May 25, 2023

Copy link
Copy Markdown
Member Author

I rebased the PR on the main branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner force-pushed the remove_imghdr branch from d2d6d86 to b5dd54d Compare May 26, 2023 12:55
@vstinner vstinner changed the title WIP (blocked by Sphinx): gh-104773: PEP 594: Remove the imghdr module gh-104773: PEP 594: Remove the imghdr module May 26, 2023
@vstinner
vstinner marked this pull request as ready for review May 26, 2023 12:56
@bedevere-bot bedevere-bot added the awaiting core review label May 26, 2023
vstinner added 3 commits May 26, 2023 15:00
@vstinner
pythongh-104773: PEP 594: Remove the imghdr module
06b091c
* Remove the Lib/test/imghdrdata/ directory.
* Copy 5 pictures (gif, png, ppm, pgm, xbm) from removed
  Lib/test/imghdrdata/ to a new Lib/test/tkinterdata/ directory.
@vstinner
Upgrade Sphinx
e503fbb
* Update Sphinx from 4.5 to 6.2 in Doc/requirements.txt.
@vstinner
Add a comment explaining Sphinx 6.2 version
7b2c914
@vstinner
vstinner force-pushed the remove_imghdr branch from 21ae588 to 7b2c914 Compare May 26, 2023 13:00
@vstinner
vstinner enabled auto-merge (squash) May 26, 2023 13:14
hugovk
hugovk approved these changes May 26, 2023
View reviewed changes

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

Looks good, we can use Sphinx 6.2 for the "normal" docs build and for doctest (both use requirements.txt), and still support 3.2 in Doc/requirements-oldest-sphinx.txt.

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 core review labels May 26, 2023
@vstinner

vstinner commented May 26, 2023

Copy link
Copy Markdown
Member Author

Looks good, we can use Sphinx 6.2 for the "normal" docs build and for doctest (both use requirements.txt), and still support 3.2 in Doc/requirements-oldest-sphinx.txt.

Right. I only upgraded Sphinx in the GHA "Doctest" job. It seems like increasing the minimum Sphinx version to build the documentation is not strictly required to remove the imghdr module.

I prefer to decorelate the imghdr removal and increase the minimum Sphinx version to build the Python documentation. So far, still supporting Sphinx 3.2 makes it possible to build Python 3.13 documentation on Debian Stable: #104818 (comment)

hugovk reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit e399f46 into python:main May 26, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label May 26, 2023
@vstinner
vstinner deleted the remove_imghdr branch May 26, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner left review comments
@hugovk hugovk hugovk approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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

@vstinner @hugovk @JulienPalard @encukou @AA-Turner @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.