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-109096: Deprecate `http.server.CGIHTTPRequestHandler` by gpshead · Pull Request #109387 · python/cpython

Conversation

@gpshead

@gpshead gpshead commented Sep 13, 2023 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

So far I haven't found any practical users of this 1990s era functionality. Given we don't encourage the use of http.server as anyones main serving stack and that using the old CGI child process and environment method fell out of favor ages ago... Lets see if we can deprecate it.

  • Issue: test_httpservers causes os.fork DeprecationWarning, can we deprecate CGIHTTPRequestHandler? #109096

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@gpshead
Deprecate http.server.CGIHTTPRequestHandler.
6ea9d69
@bedevere-app bedevere-app Bot mentioned this pull request Sep 13, 2023
test_httpservers causes os.fork DeprecationWarning, can we deprecate CGIHTTPRequestHandler? #109096
Closed
@gpshead gpshead added 3.13 only security fixes tests Tests in the Lib/test dir stdlib Standard Library Python modules in the Lib/ directory labels Sep 13, 2023
@vstinner

vstinner commented Sep 15, 2023

Copy link
Copy Markdown
Member

Since the cgi module was removed in Python 3.13, it makes sense to deprecate CGIHTTPRequestHandler.

wsgiref has BaseCGIHandler, CGIHandler and IISCGIHandler classes. Are they still relevant nowadays? WSGI isn't suppose to replace CGI?

wsgiref.simple_ref uses env['GATEWAY_INTERFACE'] = 'CGI/1.1'. Is it WSGI or CGI? I'm confused :-(

All reactions

Sorry, something went wrong.

Uh oh!

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

@gpshead

gpshead commented Sep 15, 2023

Copy link
Copy Markdown
Member Author

WSGI used much of the original CGI web server to application interfaces to make migrating from old CGI scripts child processes to in-server-process WSGI calls easy. https://peps.python.org/pep-3333/#specification-details

All reactions

Sorry, something went wrong.

Uh oh!

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

@gpshead
satisfy older sphinx?
fd3dbe5
@gpshead gpshead added the docs Documentation in the Doc dir label Sep 15, 2023
serhiy-storchaka
serhiy-storchaka reviewed Sep 15, 2023
View reviewed changes
Comment thread Doc/library/http.server.rst Resolved

Uh oh!

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

JelleZijlstra
JelleZijlstra reviewed Sep 15, 2023
View reviewed changes
Comment thread Doc/library/http.server.rst Resolved

Uh oh!

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

Comment thread Doc/library/http.server.rst Resolved

Uh oh!

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

@gpshead
appease Older Sphinx?
24ebc80
JelleZijlstra
JelleZijlstra reviewed Sep 15, 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.

Couple of wording suggestions. Deprecating CGI sounds like a good idea

Sorry, something went wrong.

Uh oh!

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

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/http/server.py Resolved

Uh oh!

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

Comment thread Lib/http/server.py Resolved

Uh oh!

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

Comment thread Doc/library/http.server.rst Resolved

Uh oh!

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

gpshead and others added 3 commits September 15, 2023 12:49
@gpshead @JelleZijlstra
docstring fixup.
d1f0c73
Co-authored-by: Jelle Zijlstra <[email protected]>
@gpshead @JelleZijlstra
docstring typo fixup
3e3a5d3
Co-authored-by: Jelle Zijlstra <[email protected]>
@gpshead @JelleZijlstra
Update Doc/library/http.server.rst
e1e9b22
Co-authored-by: Jelle Zijlstra <[email protected]>
JelleZijlstra
JelleZijlstra reviewed Sep 15, 2023
View reviewed changes
Comment thread Doc/library/http.server.rst Resolved

Uh oh!

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

@gpshead @JelleZijlstra
unindent for older sphinx
0c44758
Co-authored-by: Jelle Zijlstra <[email protected]>
vstinner
vstinner reviewed Sep 15, 2023
View reviewed changes

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

Can you please document the deprecation at https://docs.python.org/dev/whatsnew/3.13.html#deprecated and the future removal at https://docs.python.org/dev/whatsnew/3.13.html#pending-removal-in-python-3-15 ?

Sorry, something went wrong.

Uh oh!

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

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@gpshead
gpshead marked this pull request as ready for review September 15, 2023 20:32
@bedevere-app bedevere-app Bot added the awaiting review label Sep 15, 2023
@gpshead gpshead self-assigned this Sep 15, 2023
gpshead added 2 commits September 15, 2023 13:43
@gpshead
what's new entries.
7cd0b6f
@gpshead
Merge branch 'main' into deprecate/CGI
d95be85
vstinner
vstinner approved these changes Sep 15, 2023
View reviewed changes

@vstinner vstinner 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. I dislike the _self hack in the test but it's not a big deal.

Sorry, something went wrong.

Uh oh!

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

JelleZijlstra and gpshead reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Sep 15, 2023
@gpshead

gpshead commented Sep 15, 2023

Copy link
Copy Markdown
Member Author

I dislike the _self hack in the test but it's not a big deal.

Agreed. If it weren't in test code set to be deleted in two years I'd have refactored further.

All reactions

Sorry, something went wrong.

Uh oh!

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

@gpshead
gpshead merged commit 59073c9 into python:main Sep 15, 2023
@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 15, 2023
@gpshead
gpshead deleted the deprecate/CGI branch September 15, 2023 21:26
@bedevere-bot

bedevere-bot commented Sep 15, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL7 3.x has failed when building commit 59073c9.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/179/builds/5489) and take a look at the build logs.
  4. Check if the failure is related to this commit (59073c9) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/179/builds/5489

Failed tests:

  • test_tools

Failed subtests:

  • test_freeze_simple_script - test.test_tools.test_freeze.TestFreeze.test_freeze_simple_script

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1004, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1100, in get_code
  File "<frozen importlib._bootstrap_external>", line 1199, in get_data
TypeError: descriptor 'close' for '_io.BufferedReader' objects doesn't apply to a '_io.FileIO' object


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/threading.py", line 1059, in _bootstrap_inner
    self.run()
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/threading.py", line 996, in run
    self._target(*self._args, **self._kwargs)
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/test/test_interpreters.py", line 483, in task
    interp = interpreters.create()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/test/support/interpreters.py", line 25, in create
    id = _interpreters.create(isolated=isolated)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: interpreter creation failed
k


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/test/test_tools/test_freeze.py", line 28, in test_freeze_simple_script
    outdir, scriptfile, python = helper.prepare(script, outdir)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Tools/freeze/test/freeze.py", line 146, in prepare
    copy_source_tree(srcdir, SRCDIR)
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Tools/freeze/test/freeze.py", line 95, in copy_source_tree
    shutil.copytree(oldroot, newroot, ignore=ignore_non_src)
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/shutil.py", line 588, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/shutil.py", line 542, in _copytree
    raise Error(errors)
shutil.Error: [('/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/build/test_python_16368æ/@test_16368_tmpæ-tardir/extractall_ctrl/ustar/fifotype', '/tmp/test_python_f41cjpzy/tmp92oau7y2/cpython/build/test_python_16368æ/@test_16368_tmpæ-tardir/extractall_ctrl/ustar/fifotype', '`/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/build/test_python_16368æ/@test_16368_tmpæ-tardir/extractall_ctrl/ustar/fifotype` is a named pipe'), ('/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/build/test_python_16368æ/@test_16368_tmpæ-tardir/extractall_none/ustar/fifotype', '/tmp/test_python_f41cjpzy/tmp92oau7y2/cpython/build/test_python_16368æ/@test_16368_tmpæ-tardir/extractall_none/ustar/fifotype', '`/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/build/test_python_16368æ/@test_16368_tmpæ-tardir/extractall_none/ustar/fifotype` is a named pipe')]
All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Sep 15, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL8 3.x has failed when building commit 59073c9.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/509/builds/4921) and take a look at the build logs.
  4. Check if the failure is related to this commit (59073c9) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/509/builds/4921

Failed tests:

  • test.test_asyncio.test_subprocess

Failed subtests:

  • test_subprocess_consistent_callbacks - test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_subprocess_consistent_callbacks

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/test/test_asyncio/test_subprocess.py", line 788, in test_subprocess_consistent_callbacks
    self.loop.run_until_complete(main())
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z/build/Lib/test/test_asyncio/test_subprocess.py", line 780, in main
    self.assertEqual(events, [
AssertionError: Lists differ: ['process_exited', ('pipe_data_received', 1, b'stdout')] != [('pipe_data_received', 1, b'stdout'), ('p[95 chars]ted']
All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot

bedevere-bot commented Sep 15, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot PPC64LE Fedora Stable LTO + PGO 3.x has failed when building commit 59073c9.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/101/builds/3754) and take a look at the build logs.
  4. Check if the failure is related to this commit (59073c9) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/101/builds/3754

Failed tests:

  • test_venv

Failed subtests:

  • test_zippath_from_non_installed_posix - test.test_venv.BasicTest.test_zippath_from_non_installed_posix

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/test/test_venv.py", line 580, in test_zippath_from_non_installed_posix
    shutil.copytree(fn, os.path.join(libdir, name))
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/shutil.py", line 588, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/shutil.py", line 542, in _copytree
    raise Error(errors)
shutil.Error: [('/home/buildbot/buildarea/3.x.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/test/test_json/__pycache__/test_float.cpython-313.pyc.140735984064752', '/tmp/test_python_jv6l7pxc/tmpviaat877/lib/python3.13/test/test_json/__pycache__/test_float.cpython-313.pyc.140735984064752', "[Errno 2] No such file or directory: '/home/buildbot/buildarea/3.x.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/test/test_json/__pycache__/test_float.cpython-313.pyc.140735984064752'")]
All reactions

Sorry, something went wrong.

Uh oh!

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

csm10495 pushed a commit to csm10495/cpython that referenced this pull request Sep 28, 2023
@gpshead @JelleZijlstra @csm10495
pythongh-109096: Deprecate http.server.CGIHTTPRequestHandler (pytho…
99d114e
…n#109387)

Deprecate `http.server.CGIHTTPRequestHandler`.

Co-authored-by: Jelle Zijlstra <[email protected]>
@Peterl777

Peterl777 commented Oct 19, 2023

Copy link
Copy Markdown

Only just came across this. As a teacher of Python, where I usually only have access to core Python (no internet access), I have found the CGIHTTPRequestHandler really useful for teaching basic web processes. I can't go to a fully-fledged web framework. CGI is really useful for students to get the whole POST/run/output process with minimal effort and maximal engagement.
Disappointed about this deprecation.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 19, 2023

Copy link
Copy Markdown
Member

Only just came across this. As a teacher of Python, where I usually only have access to core Python (no internet access)

You can provide Python with a old (non deprecated) copy of CGIHTTPRequestHandler to your students.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Peterl777

Peterl777 commented Oct 20, 2023

Copy link
Copy Markdown

Yes, that would work. But often I can't bring any external code in either; they've got core Python and that's all I can work with.

All reactions

Sorry, something went wrong.

Uh oh!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@vstinner vstinner vstinner approved these changes

Uh oh!

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

Assignees

@gpshead gpshead

Labels

3.13 only security fixes docs Documentation in the Doc dir stdlib Standard Library Python modules in the Lib/ directory 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

@gpshead @vstinner @bedevere-bot @Peterl777 @JelleZijlstra @serhiy-storchaka
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.