@@ -84,8 +84,10 @@ def get_basename(path):
84
84
sage: from sage.doctest.sources import get_basename
85
85
sage: from sage.env import SAGE_SRC
86
86
sage: import os
87
- sage: get_basename(os.path.join(SAGE_SRC,'sage','doctest','sources.py'))
87
+ sage: get_basename(os.path.join(SAGE_SRC, 'sage', 'doctest', 'sources.py'))
88
88
'sage.doctest.sources'
89
+ sage: get_basename(os.path.join(SAGE_SRC, 'sage', 'structure', 'element.pxd'))
90
+ 'sage.structure.element.pxd'
89
91
"""
90
92
if path is None :
91
93
return None
@@ -111,10 +113,14 @@ def get_basename(path):
111
113
# it goes.
112
114
while is_package_or_sage_namespace_package_dir (root ):
113
115
root = os .path .dirname (root )
114
- fully_qualified_path = os .path .splitext (path [len (root ) + 1 :])[ 0 ]
116
+ fully_qualified_path , ext = os .path .splitext (path [len (root ) + 1 :])
115
117
if os .path .split (path )[1 ] == '__init__.py' :
116
118
fully_qualified_path = fully_qualified_path [:- 9 ]
117
- return fully_qualified_path .replace (os .path .sep , '.' )
119
+ basename = fully_qualified_path .replace (os .path .sep , '.' )
120
+ if ext in ['.pxd' , '.pxi' ]:
121
+ # disambiguate from .pyx with the same basename
122
+ basename += ext
123
+ return basename
118
124
119
125
120
126
class DocTestSource ():
0 commit comments