Skip to content

Commit 20fe0fb

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 d26ded2 commit 20fe0fb

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
@@ -137,7 +137,11 @@ def is_stdlib_name(modname):
137137
return False
138138

139139
# six installs crap with no __file__
140-
modpath = os.path.abspath(getattr(module, '__file__', ''))
140+
path = getattr(module, '__file__', '')
141+
if path is None:
142+
path = ''
143+
144+
modpath = os.path.abspath(path)
141145
return is_stdlib_path(modpath)
142146

143147

0 commit comments

Comments
 (0)