Steps to replicate the issue (include links if applicable):
- checkout pywikibot/core.git to 77482f4bab1822c7b604f7d1a4787ad2742ec991
- pytest tests/http_tests.py::TestHttpStatus::test_follow_redirects
What happens?:
Different results on different platforms.
On MacOS 12.6.1, Python 3.9.13:
E AssertionError: '//en.wikipedia.org/wiki/Main_Page' not found in 'https://en.wikipedia.org/wiki/Main%20Page'
On debian 11.7 (bullseye), Python 3.9.2, the test passes.
On both platforms, running curl manually on the command line shows a two-step redirect:
http://en.wikipedia.org/wiki/Main%20Page -> https://en.wikipedia.org/wiki/Main%20Page https://en.wikipedia.org/wiki/Main%20Page -> https://en.wikipedia.org/wiki/Main_Page
If I run this on MacOS:
r = requests.get('http://en.wikipedia.org/wiki/Main%20Page') print(len(r.history)) print(r.url)
it prints what I would expect:
2 https://en.wikipedia.org/wiki/Main_Page
but single-stepping through the test code in the debugger, after:
response = session.request(method, uri, headers=headers, auth=auth, timeout=timeout, **kwargs)
in pywikibot/comms/http.py, I get:
len(response.history) 1 response.url 'https://en.wikipedia.org/wiki/Main%20Page'
Unclear at this point why it's not doing the 2nd redirect. I'll keep digging.