From 6e35d56760df870af855f9e4d07d4d6d39cc15c9 Mon Sep 17 00:00:00 2001 From: fliiiix Date: Fri, 28 Nov 2025 16:05:00 +0100 Subject: [PATCH] [Python] Fix generating __init__.py for invalid path 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. --- src/idl_gen_python.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/idl_gen_python.cpp b/src/idl_gen_python.cpp index 4c48b21b17d..03a49a5c489 100644 --- a/src/idl_gen_python.cpp +++ b/src/idl_gen_python.cpp @@ -2884,7 +2884,8 @@ class PythonGenerator : public BaseGenerator { parser_.opts.one_file ? path_ : namer_.Directories(ns.components); EnsureDirExists(directories); - for (size_t i = path_.size() + 1; i != std::string::npos; + for (size_t i = directories.find(kPathSeparator, path_.size()); + i != std::string::npos; i = directories.find(kPathSeparator, i + 1)) { const std::string init_py = directories.substr(0, i) + kPathSeparator + "__init__.py";