Mercurial > p > roundup > code
annotate roundup/anypy/urllib_.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 | b1024bf0d9f7 |
| children |
| rev | line source |
|---|---|
|
4362
74476eaac38a
more modernisation
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 |
|
74476eaac38a
more modernisation
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 try: |
|
4996
dfd0bcc947e5
Add comments about supported anypy python versions
John Kristensen <john@jerrykan.com>
parents:
4362
diff
changeset
|
3 # Python 3+ |
|
8575
b1024bf0d9f7
feature: add nonceless/tokenless CSRF protection
John Rouillard <rouilj@ieee.org>
parents:
8258
diff
changeset
|
4 from urllib.parse import parse_qs, quote, unquote, urlencode, urlparse, urlsplit, urlunparse |
|
5402
88dbacd11cd1
Python 3 preparation: update urllib / urllib2 / urlparse imports.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5121
diff
changeset
|
5 from urllib.request import urlopen |
|
6023
7b194e35d332
flak8 fixes: replace bare except with except ImportError
John Rouillard <rouilj@ieee.org>
parents:
5402
diff
changeset
|
6 except ImportError: |
|
4996
dfd0bcc947e5
Add comments about supported anypy python versions
John Kristensen <john@jerrykan.com>
parents:
4362
diff
changeset
|
7 # Python 2.5-2.7 |
|
7767
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7228
diff
changeset
|
8 from urllib import quote, unquote, urlencode # noqa: F401 |
|
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7228
diff
changeset
|
9 |
|
d5d7ecd31864
chore: sort imports w/ ruff.
John Rouillard <rouilj@ieee.org>
parents:
7228
diff
changeset
|
10 from urllib2 import urlopen # noqa: F401 |
|
8575
b1024bf0d9f7
feature: add nonceless/tokenless CSRF protection
John Rouillard <rouilj@ieee.org>
parents:
8258
diff
changeset
|
11 from urlparse import parse_qs, urlparse, urlsplit, urlunparse # noqa: F401 |
