From 9bc73df080fdf766537a9266ba24171a2963d9f4 Mon Sep 17 00:00:00 2001 From: Adam Haberlach Date: Wed, 29 Mar 2023 20:59:40 -0700 Subject: [PATCH] Add handling of TypeError case to is_native (#588) This should address https://github.com/plasma-umass/scalene/issues/587 which has more information, but basically the check for native fails on at least my system because package.__file__ exists, but is None, so os.path.dirname() returns a TypeError. --- scalene/scalene_analysis.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scalene/scalene_analysis.py b/scalene/scalene_analysis.py index 87d83721a..26b8c67f4 100644 --- a/scalene/scalene_analysis.py +++ b/scalene/scalene_analysis.py @@ -31,6 +31,9 @@ def is_native(package_name: str) -> bool: except AttributeError: # No __file__, meaning it's built-in. Let's call it native. result = True + except TypeError: + # __file__ is there, but empty (os.path.dirname() returns TypeError). Let's call it native. + result = True except ModuleNotFoundError: # This module is not installed; fail gracefully. result = False