Mercurial > p > roundup > code
annotate roundup/anypy/cgi_.py @ 8586:31a8a6faa2fa
bug: Allow UsageError exception to use more specific error code
UsageError exception returned 400 error code but should return 405
when generated for a bad http method.
Modified error handler to use 400 error code if self.response_code was
less then 400. This should reproduce the standard error of 400 if one
was not specified and preserve any other explicitly set response code.
Also enhanced a test case to verify the 405 is returned.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 20 Apr 2026 03:09:30 -0400 |
| parents | 7c49a4267705 |
| children |
| rev | line source |
|---|---|
|
7767
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
1 # ruff: noqa: F401 - unused imports |
|
8499
7c49a4267705
bug: supress deprecation warning when importing cgi module
John Rouillard <rouilj@ieee.org>
parents:
7767
diff
changeset
|
2 import warnings |
|
7582
978285986b2c
fix: issue2551193 - Fix roundup for removal of cgi and cgitb ...
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
3 try: |
|
7767
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
4 # used for python2 and python 3 < 3.13 |
|
8499
7c49a4267705
bug: supress deprecation warning when importing cgi module
John Rouillard <rouilj@ieee.org>
parents:
7767
diff
changeset
|
5 with warnings.catch_warnings(): |
|
7c49a4267705
bug: supress deprecation warning when importing cgi module
John Rouillard <rouilj@ieee.org>
parents:
7767
diff
changeset
|
6 warnings.filterwarnings('ignore', category=DeprecationWarning) |
|
7c49a4267705
bug: supress deprecation warning when importing cgi module
John Rouillard <rouilj@ieee.org>
parents:
7767
diff
changeset
|
7 import cgi |
|
7767
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
8 from cgi import FieldStorage, MiniFieldStorage |
|
7582
978285986b2c
fix: issue2551193 - Fix roundup for removal of cgi and cgitb ...
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
9 except ImportError: |
|
7767
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
10 # use for python3 >= 3.13 |
|
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
11 from roundup.anypy.vendored import cgi |
|
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
12 from roundup.anypy.vendored.cgi import FieldStorage, MiniFieldStorage |
