Skip to content

Commit

Permalink
Handle pre-Python 3.11 'MacOSXOSAScript' object has no attribute 'nam…
Browse files Browse the repository at this point in the history
…e' issue; fixes #790.
  • Loading branch information
emeryberger committed Mar 10, 2024
1 parent 3cca09c commit dd86728
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scalene/find_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def find_browser(browserClass=None) -> Optional[str]:
# Get the default browser object
browser = webbrowser.get(browserClass)
return browser.name if browser.name not in text_browsers else None
except AttributeError:
# https://github.com/plasma-umass/scalene/issues/790
# https://github.com/python/cpython/issues/105545
# MacOSXOSAScript._name was deprecated but for pre-Python 3.11,
# we need to refer to it as such to prevent this error:
# 'MacOSXOSAScript' object has no attribute 'name'
browser = webbrowser.get(browserClass)
return browser._name if browser._name not in text_browsers else None
except webbrowser.Error:
# Return None if there is an error in getting the browser
return None

0 comments on commit dd86728

Please sign in to comment.