URL has an invalid label.
Package:
requests
45920

Exception Class:
InvalidURL
Raise code
# non-ASCII characters. This allows users to automatically get the correct IDNA
# behaviour. For strings containing only ASCII characters, we need to also verify
# it doesn't start with a wildcard (*), before allowing the unencoded hostname.
if not unicode_is_ascii(host):
try:
host = self._get_idna_encoded_host(host)
except UnicodeError:
raise InvalidURL('URL has an invalid label.')
elif host.startswith(u'*'):
raise InvalidURL('URL has an invalid label.')
# Carefully reconstruct the network location
netloc = auth or ''
if netloc:
netloc += '@'
Links to the raise (2)
https://github.com/psf/requests/blob/f6d43b03fbb9a1e75ed63a9aa15738a8fce99b50/requests/models.py#L403 https://github.com/psf/requests/blob/f6d43b03fbb9a1e75ed63a9aa15738a8fce99b50/requests/models.py#L405See also in the other packages (2)
(❌️ No answer)
pipenv/url-has-an-invalid-label/
(❌️ No answer)
pip/url-has-an-invalid-label/
Ways to fix
Summary: Make sure your ulr does not start with a wildcard '*'.
Code to reproduce (WRONG)
import requests
# url cannot start with wildcard '*'
req = requests.Request('GET', 'https://*fixexception.com')
r = req.prepare()
Working Version (FIXED)
import requests
# there is no wildcard now
req = requests.Request('GET', 'https://fixexception.com')
r = req.prepare()
print(r)
Add a possible fix
Please authorize to post fix