py3: ensure the HTTP password manager returns strings, not bytes
The digest handler calls into the password manager on its own, and it apparently
expects strings. Perhaps the Basic authentication handler didn't hit this
because of its manual password fetch and format in retry_http_basic_auth().
The `pycompat.bytesurl()` on the user and password just above the first url.py
diff seems unnecessary, because the password proxy in ui is converting to bytes
IIUC.
--- a/mercurial/url.py Tue Feb 05 16:47:19 2019 -0500
+++ b/mercurial/url.py Tue Feb 05 17:02:40 2019 -0500
@@ -65,7 +65,7 @@
user, passwd = pycompat.bytesurl(user), pycompat.bytesurl(passwd)
if user and passwd:
self._writedebug(user, passwd)
- return (user, passwd)
+ return (pycompat.strurl(user), pycompat.strurl(passwd))
if not user or not passwd:
res = httpconnectionmod.readauthforuri(self.ui, authuri, user)
@@ -93,7 +93,7 @@
self.passwddb.add_password(realm, authuri, user, passwd)
self._writedebug(user, passwd)
- return (user, passwd)
+ return (pycompat.strurl(user), pycompat.strurl(passwd))
def _writedebug(self, user, passwd):
msg = _('http auth: user %s, password %s\n')
--- a/tests/test-http.t Tue Feb 05 16:47:19 2019 -0500
+++ b/tests/test-http.t Tue Feb 05 17:02:40 2019 -0500
@@ -225,9 +225,8 @@
> return opener
> EOF
- $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py || true
- abort: HTTP Error 403: bad user (py3 !)
- 5fed3813f7f5 (no-py3 !)
+ $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py
+ 5fed3813f7f5
#if no-reposimplestore
$ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
@@ -383,14 +382,13 @@
"GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
"GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
"GET /?cmd=capabilities HTTP/1.1" 401 - x-hgtest-authtype:Digest
- "GET /?cmd=capabilities HTTP/1.1" 403 - x-hgtest-authtype:Digest (py3 !)
- "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest (no-py3 !)
- "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
- "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
- "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
- "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
- "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
- "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
+ "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest
+ "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+ "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+ "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+ "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+ "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+ "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
"GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
"GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
"GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore !)
@@ -461,7 +459,6 @@
$ cat error.log
$ cat errors2.log
- $LOCALIP - - [$ERRDATE$] HG error: No hash found for user/realm "b'user'/mercurial" (glob) (py3 !)
check abort error reporting while pulling/cloning