-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Accountaz login/accountaz login/accountbugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.
Description
Describe the bug
There's a bug in the webbrowser module in newer python versions which affects the browser url opening when doing az login.
python bug report: https://bugs.python.org/msg322439
To Reproduce
$ az login
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "./virtualenv-az/lib/python3.7/site-packages/azure/cli/core/_profile.py", line 1033, in _get_authorization_code_worker
succ = open_page_in_browser(url)
File "./virtualenv-az/lib/python3.7/site-packages/azure/cli/core/util.py", line 266, in open_page_in_browser
return webbrowser.open(url, new=2) # 2 means: open in a new tab, if possible
File "/usr/lib64/python3.7/webbrowser.py", line 75, in open
register_standard_browsers()
File "/usr/lib64/python3.7/webbrowser.py", line 567, in register_standard_browsers
cmd = _synthesize(cmdline, -1)
File "/usr/lib64/python3.7/webbrowser.py", line 116, in _synthesize
register(browser, None, controller, update_tryorder)
TypeError: register() takes from 2 to 3 positional arguments but 4 were given
Expected behavior
It should open a browser tab as usual
Environment summary
I'm using virtualenv for the install
$ python --version
Python 3.7.0
$ az --version
azure-cli (2.0.41)
acr (2.0.28)
acs (2.1.3)
advisor (0.5.1)
ams (0.1.1)
appservice (0.1.36)
backup (1.1.2)
batch (3.2.4)
batchai (0.3.1)
billing (0.1.8)
cdn (0.0.14)
cloud (2.0.15)
cognitiveservices (0.1.13)
command-modules-nspkg (2.0.1)
configure (2.0.17)
consumption (0.3.1)
container (0.2.1)
core (2.0.41)
cosmosdb (0.1.21)
dla (0.1.0)
dls (0.0.22)
dms (0.0.1)
eventgrid (0.1.12)
eventhubs (0.1.3)
extension (0.1.0)
feedback (2.1.3)
find (0.2.11)
interactive (0.3.25)
iot (0.1.21)
keyvault (2.0.23)
lab (0.0.22)
monitor (0.1.8)
network (2.1.5)
nspkg (3.0.2)
profile (2.0.27)
rdbms (0.2.5)
redis (0.2.14)
reservations (0.2.1)
resource (2.0.32)
role (2.0.26)
servicebus (0.1.2)
servicefabric (0.0.12)
sql (2.0.27)
storage (2.0.35)
vm (2.0.35)
Python location './virtualenv-az/bin/python'
Extensions directory '/home/exfalso/.azure/cliextensions'
Python (Linux) 3.7.0 (default, Jul 15 2018, 10:44:58)
[GCC 8.1.1 20180531]
Legal docs and information: aka.ms/AzureCliLegal
Additional context
The bug can be worked around by catching the TypeError and simply retrying (the browsers are initialized at this point), like so:
def open_page_in_browser(url):
if sys.platform.lower() == 'darwin':
# handle 2 things:
# a. On OSX sierra, 'python -m webbrowser -t <url>' emits out "execution error: <url> doesn't
# understand the "open location" message"
# b. Python 2.x can't sniff out the default browser
import subprocess
return subprocess.Popen(['open', url])
import webbrowser
try:
return webbrowser.open(url, new=2) # 2 means: open in a new tab, if possible
except TypeError as err: # See https://bugs.python.org/msg322439. A simple retry works
return webbrowser.open(url, new=2)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Accountaz login/accountaz login/accountbugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.