From: Jake Farrell Date: Tue, 26 Mar 2013 03:49:37 +0000 (-0400) Subject: Thrift-1806: Python generation always truncates __init__.py files X-Git-Tag: 0.9.1~153 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=2d26f18a12d20e2bc5063a34ff347558fa91517f;p=common%2Fthrift.git Thrift-1806: Python generation always truncates __init__.py files Client: Python Patch: Nathaniel Cook When generating python code the generator correctly creates _init.py file for each directory. If the __init_.py file has contents it is always overwritten. This usually isn't a problem unless using the -out flag, then there is a potential to erase non generated code. --- diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc index fd954c51..4a540f27 100644 --- a/compiler/cpp/src/generate/t_py_generator.cc +++ b/compiler/cpp/src/generate/t_py_generator.cc @@ -337,7 +337,7 @@ void t_py_generator::init_generator() { while (true) { // TODO: Do better error checking here. MKDIR(package_dir_.c_str()); - std::ofstream init_py((package_dir_+"/__init__.py").c_str()); + std::ofstream init_py((package_dir_+"/__init__.py").c_str(), std::ios_base::app); init_py.close(); if (module.empty()) { break;