Skip to content

Commit f37b346

Browse files
committed
fix: issue2551193 - Fix roundup for removal of cgi and cgitb ...
standard python modules (and FieldStorage/MiniFieldStorage). Vendor cgi.py and modify imports. Details: roundup/anypy/cgi_.py import that accesses a working cgi.py. All imports dealing with cgi now use cgi_. roundup/anypy/vendored/cgi.py vendored version 2.6 of cgi.py from: https://pypi.org/project/legacy-cgi/ CHANGES.txt change note added COPYING.txt added license for cgi.py doc/rest.txt change example to use cgi_ doc/upgrading.txt doc removal and how to rework local code using cgi.py. frontends/roundup.cgi remove unneeded cgi import roundup/cgi/actions.py roundup/cgi/apache.py roundup/cgi/client.py roundup/cgi/templating.py roundup/cgi/TAL/TALGenerator.py test/db_test_base.py test/rest_common.py test/test_cgi.py remove import cgi and replace with from roundup.anypy.cgi_ import cgi test/test_actions.py test/test_templating.py modify import to get *FieldStorage test/test_admin.py test/test_hyperdbvals.py test/test_xmlrpc.py remove unneeded cgi import
1 parent e420438 commit f37b346

20 files changed

+1112
-15
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ Fixed:
2727
and 2.4.10 with its new schema filtering method. (John Rouillard)
2828
- multiple flake8 fixes (John Rouillard)
2929
- rename loop variable in 'for sendto in sendto:' (John Rouillard)
30+
- issue2551193 - Fix roundup for removal of cgi and cgitb standard
31+
python modules (and FieldStorage/MiniFieldStorage). Replaced imports
32+
from cgi to use roundup.anypy.cgi_ which will load the system cgi
33+
unless it is missing. Then it will load roundup.anypy.vendored.cgi
34+
and make *FieldStroage symbols available. Roundp uses its own
35+
cgitb.py and not the system cgitb.py. It looks like it's the
36+
precursor to the system cgitb.py. (John Rouillard)
3037

3138
Features:
3239

COPYING.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,59 @@ accompanying credits file.
113113

114114

115115
Note link for http://www.zope.com/Marks is dead.
116+
117+
Vendored cgi.py module
118+
----------------------
119+
120+
This module is licensed under the Python Software Foundation License
121+
Version 2 as it was extracted from the 3.12 Python distribution.
122+
123+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
124+
--------------------------------------------
125+
126+
1. This LICENSE AGREEMENT is between the Python Software Foundation
127+
("PSF"), and the Individual or Organization ("Licensee") accessing
128+
and otherwise using this software ("Python") in source or binary
129+
form and its associated documentation.
130+
131+
2. Subject to the terms and conditions of this License Agreement, PSF
132+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
133+
license to reproduce, analyze, test, perform and/or display
134+
publicly, prepare derivative works, distribute, and otherwise use
135+
Python alone or in any derivative version, provided, however, that
136+
PSF's License Agreement and PSF's notice of copyright, i.e.,
137+
"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
138+
2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
139+
2020, 2021, 2022 Python Software Foundation; All Rights Reserved"
140+
are retained in Python alone or in any derivative version prepared
141+
by Licensee.
142+
143+
3. In the event Licensee prepares a derivative work that is based on
144+
or incorporates Python or any part thereof, and wants to make the
145+
derivative work available to others as provided herein, then
146+
Licensee hereby agrees to include in any such work a brief summary
147+
of the changes made to Python.
148+
149+
4. PSF is making Python available to Licensee on an "AS IS" basis.
150+
PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY
151+
WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY
152+
REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
153+
PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY
154+
THIRD PARTY RIGHTS.
155+
156+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
157+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
158+
RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR
159+
ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
160+
161+
6. This License Agreement will automatically terminate upon a material
162+
breach of its terms and conditions.
163+
164+
7. Nothing in this License Agreement shall be deemed to create any
165+
relationship of agency, partnership, or joint venture between PSF
166+
and Licensee. This License Agreement does not grant permission to
167+
use PSF trademarks or trade name in a trademark sense to endorse or
168+
promote products or services of Licensee, or any third party.
169+
170+
8. By copying, installing or otherwise using Python, Licensee agrees
171+
to be bound by the terms and conditions of this License Agreement.

doc/rest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ section this code adds a new endpoint `/data/@permission/Developer`
17911791
that returns a list of users with the developer role::
17921792

17931793
from roundup.rest import Routing, RestfulInstance
1794-
from cgi import MiniFieldStorage
1794+
from roundup.anypy.cgi_ import MiniFieldStorage
17951795

17961796
class RestfulInstance(object):
17971797

doc/upgrading.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ details.
126126

127127
.. _`information on configuring the API rate limits`: rest.html#rate-limiting-api-failed-logins
128128

129+
Removal of cgi.py from Python (info)
130+
------------------------------------
131+
132+
The ``cgi.py`` module will be `removed starting with Python 3.13
133+
<https://peps.python.org/pep-0594/#cgi>`_. Roundup now `vendors a copy
134+
<https://pypi.org/project/legacy-cgi/>`_ of ``cgi.py`` and makes it
135+
and its storage objects available by importing from::
136+
137+
from roundup.anypy.cgi_ import cgi
138+
from roundup.anypy.cgi_ import FieldStorage, MiniFieldStorage
139+
140+
It is unlikey that you will care unless you have done some expert
141+
level Roundup customization. If you have, use one of the imports above
142+
if you plan on running on Python 3.13 (expected in 2024) or newer.
143+
129144
.. index:: Upgrading; 2.2.0 to 2.3.0
130145

131146
Migrating from 2.2.0 to 2.3.0

frontends/roundup.cgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ LOG = DevNull()
7373
# Set up the error handler
7474
#
7575
try:
76-
import traceback, cgi
76+
import traceback
7777
from roundup.cgi import cgitb
7878
except:
7979
print("Content-Type: text/plain\n")

roundup/anypy/cgi_.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
try:
2+
# used for python2 and python 3 < 3.13
3+
import cgi as cgi
4+
from cgi import FieldStorage, MiniFieldStorage
5+
except ImportError:
6+
# use for python3 >= 3.13
7+
from roundup.anypy.vendored import cgi
8+
from roundup.anypy.vendored.cgi import FieldStorage, MiniFieldStorage

0 commit comments

Comments
 (0)