Skip to content

Commit 591e542

Browse files
committed
Handle modules with __file__ property being None
It's been discovered that some modules have the `__file__` property being set as `None`. An example of a such module is `backports`. Providing `None` to `os.path.abspath()` causes an exception: `TypeError: expected str, bytes or os.PathLike object, not NoneType` Related to #946
1 parent cca651d commit 591e542

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mitogen/master.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ def is_stdlib_name(modname):
148148
return False
149149

150150
# six installs crap with no __file__
151-
modpath = os.path.abspath(getattr(module, '__file__', ''))
151+
path = getattr(module, '__file__', '')
152+
if path is None:
153+
path = ''
154+
155+
modpath = os.path.abspath(path)
152156
return is_stdlib_path(modpath)
153157

154158

0 commit comments

Comments
 (0)