Skip to content

Commit 00c3566

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
bugfix: fix incorrect path slice in strict module loader
Summary: `path[:12]` takes the first 12 characters of the path instead of stripping `__init__.py` from the end. This meant `submodule_search_locations` for strict packages would always be wrong. Replaced with `os.path.dirname(path)` which is the standard idiom for getting the directory of a file. Reviewed By: yoney Differential Revision: D97805946 fbshipit-source-id: 55df9a1b93969b921348661a937919575c74f692
1 parent d7b192d commit 00c3566

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • cinderx/PythonLib/cinderx/compiler/strict

cinderx/PythonLib/cinderx/compiler/strict/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def source_to_code(
543543
# containing the "__init__.py").
544544
submodule_search_locations = None
545545
if path.endswith("__init__.py"):
546-
submodule_search_locations = [path[:12]]
546+
submodule_search_locations = [os.path.dirname(path)]
547547
# Usually _optimize will be -1 (which means "default to the value
548548
# of sys.flags.optimize"). But this default happens very deep in
549549
# Python's compiler (in PyAST_CompileObject), so if we just pass

0 commit comments

Comments
 (0)