This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unable to use lowercase hexadecimal digits for percent encoding
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: E Kawashima, christian.heimes, e-kwsm, orsenthil, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-04-28 18:14 by e-kwsm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19766 closed E Kawashima, 2020-04-28 18:37
Messages (14)
msg367551 - (view) Author: Eisuke Kawashima (e-kwsm) * Date: 2020-04-28 18:14
RFC 3986 (https://tools.ietf.org/html/rfc3986#section-2.1) allows lower hexadecimal digits for percent encoding, but urllib.parse.quote and its variants convert into only UPPERCASE digits [A-F].

I will create a PR for fix.
msg367994 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-05-03 20:58
I opened a pull request with an invalid bpo issue number so I unlinked it. Then a completely unrelated PR was is shown as linked by me, but I didn't do that. Unlinking that as well.
msg367996 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-05-03 21:14
PRs keep getting linked to this issue under my name, without me doing anything.
msg367998 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-03 22:10
I think that may be happening because you are still refering to this issue in the title of
https://github.com/python/cpython/pull/19888?

Not sure how the linkage is made, but if this keeps happening you may open an issue in the core-workflow repo in the Python org.
msg367999 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-03 22:11
In the title -> in the description
msg368000 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-05-03 23:18
After Serhiy unlinked the linked PR, it did not happen again, so it may have been an one-off hiccup. I updated the description GH-19888 nevertheless.
msg368017 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-04 08:23
What is wrong with the current behavior? Why does the case of hexadecimal digits matter?

There are no options to repr() to control the case of hexadecimal digits in <object object at 0x7f7a16dc4580> and '\ufffe', and I doubt there are such options in other functions producing hexadecimals. So it is a very uncommon request.
msg368439 - (view) Author: Eisuke Kawashima (e-kwsm) * Date: 2020-05-08 14:06
I require lower hex digits for percent encoding, which is allowed by the RFC.  Small modifications of the codes can achieve it.
msg368441 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-05-08 14:27
I'm -0 on the new argument. Why do you require a lower case string here?
msg368443 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-08 14:50
But they are not required, right?
msg368444 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-05-08 14:52
No, they are not required. RFC 3986 recommends upper case and says that upper and lower case percent encoding are equivalent:

   The uppercase hexadecimal digits 'A' through 'F' are equivalent to
   the lowercase digits 'a' through 'f', respectively.  If two URIs
   differ only in the case of hexadecimal digits used in percent-encoded
   octets, they are equivalent.  For consistency, URI producers and
   normalizers should use uppercase hexadecimal digits for all percent-
   encodings.
msg368455 - (view) Author: Eisuke Kawashima (e-kwsm) * Date: 2020-05-08 19:15
> Why do you require a lower case string here?

Well, I want to use urllib.parse.quote to escape special characters, such as ()[]#*/\, in filenames, and for visibility lower hex digits are preferable.
PR 19766 does not break compatibility.
msg368477 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-05-08 22:43
There is no need to add a new flag to quote. You can easily archive your goal with a simple regular expression substitution:

>>> import re, urllib.parse
>>> s = urllib.parse.quote("Example|#?")
>>> s
'Example%7C%23%3F'
>>> re.sub("%[0-9A-F]{2}", lambda q: q.group(0).lower(), s)
'Example%7c%23%3f'
msg368509 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-05-09 10:30
Concur with Christian. Heh, I was going to propose the same.
History
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84606
2020-05-09 10:30:42serhiy.storchakasetstatus: open -> closed
resolution: rejected
messages: + msg368509

stage: patch review -> resolved
2020-05-08 22:43:57christian.heimessetmessages: + msg368477
2020-05-08 19:15:58e-kwsmsetmessages: + msg368455
2020-05-08 14:52:45christian.heimessetmessages: + msg368444
2020-05-08 14:50:27serhiy.storchakasetmessages: + msg368443
2020-05-08 14:27:09christian.heimessetnosy: + christian.heimes
messages: + msg368441
2020-05-08 14:06:32e-kwsmsetmessages: + msg368439
2020-05-04 14:56:59lys.nikolaousetnosy: - lys.nikolaou
2020-05-04 08:23:44serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg368017
2020-05-03 23:18:29lys.nikolaousetmessages: + msg368000
2020-05-03 22:11:43pablogsalsetmessages: + msg367999
2020-05-03 22:10:43pablogsalsetnosy: + pablogsal
messages: + msg367998
2020-05-03 21:19:28serhiy.storchakasetpull_requests: - pull_request19201
2020-05-03 21:14:33lys.nikolaousetmessages: + msg367996
2020-05-03 21:11:16lys.nikolaousetpull_requests: + pull_request19201
2020-05-03 20:58:22lys.nikolaousetpull_requests: - pull_request19200
2020-05-03 20:58:03lys.nikolaousetmessages: + msg367994
2020-05-03 20:42:18lys.nikolaousetpull_requests: + pull_request19200
2020-05-03 20:31:28lys.nikolaousetpull_requests: - pull_request19198
2020-05-03 20:30:32lys.nikolaousetnosy: + lys.nikolaou
pull_requests: + pull_request19198
2020-05-01 23:23:03terry.reedysetnosy: + orsenthil
2020-04-28 18:37:14E Kawashimasetkeywords: + patch
nosy: + E Kawashima

pull_requests: + pull_request19087
stage: patch review
2020-04-28 18:14:11e-kwsmcreate