Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d977e35

Browse files
committed
Also accept .so as an extension for module files.
1 parent 8c01158 commit d977e35

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

Lib/pydoc.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,10 @@ def stripid(text):
127127
def modulename(path):
128128
"""Return the Python module name for a given path, or None."""
129129
filename = os.path.basename(path)
130-
if lower(filename[-3:]) == '.py':
131-
return filename[:-3]
132-
elif lower(filename[-4:]) in ['.pyc', '.pyd', '.pyo']:
133-
return filename[:-4]
134-
elif lower(filename[-11:]) == 'module.so':
135-
return filename[:-11]
136-
elif lower(filename[-13:]) == 'module.so.1':
137-
return filename[:-13]
130+
for ending in ['.py', '.pyc', '.pyd', '.pyo',
131+
'module.so', 'module.so.1', '.so']:
132+
if len(filename) > len(ending) and filename[-len(ending):] == ending:
133+
return filename[:-len(ending)]
138134

139135
class DocImportError(Exception):
140136
"""Class for errors while trying to import something to document it."""

0 commit comments

Comments
 (0)