Mercurial > p > roundup > code
diff roundup/rest.py @ 8580:5cba36e42b8f
chore: refactor replace urlparse with urlsplit and use urllib_
Python docs recommend use of urlsplit() rather than
urlparse(). urlsplit() is a little faster and doesn't try to split the
path into path and params using the rules from an obsolete RFC.
actions.py, demo.py, rest.py, client.py
Replace urlparse() with urlsplit()
actions.py
urlsplit() produces a named tuple with one fewer elements (no
.param). So fixup calls to urlunparse() so they have the proper
number of elements in the tuple.
also merge url filtering for param and path.
demo.py, rest.py:
Replace imports from urlparse/urllib.parse with
roundup.anypy.urllib_ so we use the same interface throughout the
code base.
test/test_cgi.py:
Since actions.py filtering for invali urls not split by path/param,
fix tests for improperly quoted url's.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 19 Apr 2026 22:58:59 -0400 |
| parents | 9c3ec0a5c7fc |
| children |
line wrap: on
line diff
--- a/roundup/rest.py Sun Apr 19 22:51:54 2026 -0400 +++ b/roundup/rest.py Sun Apr 19 22:58:59 2026 -0400 @@ -21,13 +21,10 @@ except ImportError: JSONDecodeError = ValueError -try: - from urllib.parse import urlparse -except ImportError: - from urlparse import urlparse from roundup import actions, date, hyperdb from roundup.anypy.strings import b2s, bs2b, is_us, u2s +from roundup.anypy.urllib_ import urlsplit from roundup.cgi.exceptions import NotFound, PreconditionFailed, Unauthorised from roundup.exceptions import Reject, UsageError from roundup.i18n import _ @@ -2341,7 +2338,7 @@ # only json or xml valid at this time. # header (Accept: application/json, application/xml) # default (application/json) - ext_type = os.path.splitext(urlparse(uri).path)[1][1:] + ext_type = os.path.splitext(urlsplit(uri).path)[1][1:] # Check to see if the extension matches a value in # self.__accepted_content_type. In the future other output
