Skip to content

Commit 49d2db9

Browse files
authored
[Python] Fix generating __init__.py for invalid path (#8810)
This tried to generate from a directories "MyGame/Sample/" for a empty path_ in M, MyGame & MyGame/Sample. Which is incorrect since we want to start with the first kPathSeparator `/` and not position 1.
1 parent 807b43c commit 49d2db9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/idl_gen_python.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,8 @@ class PythonGenerator : public BaseGenerator {
28842884
parser_.opts.one_file ? path_ : namer_.Directories(ns.components);
28852885
EnsureDirExists(directories);
28862886

2887-
for (size_t i = path_.size() + 1; i != std::string::npos;
2887+
for (size_t i = directories.find(kPathSeparator, path_.size());
2888+
i != std::string::npos;
28882889
i = directories.find(kPathSeparator, i + 1)) {
28892890
const std::string init_py =
28902891
directories.substr(0, i) + kPathSeparator + "__init__.py";

0 commit comments

Comments
 (0)