From 49d2db93a709a0d8cc23cad68a121526122e684c Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 1 Dec 2025 00:30:55 +0100 Subject: [PATCH] [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. --- 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 8bfcd5856..a7feb044a 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";