File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,8 @@ def copy_structure_and_params(m):
365365
366366 # crack open the zip format to get at the main module code
367367 archive = zipfile.ZipFile(buffer)
368+ # check that we have no duplicate names
369+ self.assertEqual(len(set(archive.namelist())), len(archive.namelist()))
368370 main_module = archive.open('archive/code/archive.py')
369371 main_module_code = ""
370372 for line in main_module:
Original file line number Diff line number Diff line change @@ -607,10 +607,16 @@ void ScriptModuleSerializer::writeLibs(torch::ModelDef* model_def) {
607607
608608 // Write out the files. We still have to do this in converted_classes_ order,
609609 // to maintain dependency order.
610+ std::unordered_set<std::string> written_files;
610611 for (const auto & item : converted_classes_) {
611612 const ClassTypePtr& class_type = item.key ();
612613 const std::string filename =
613614 ImportExportHelpers::qualifierToPath (class_type->qualifier ());
615+ if (written_files.count (filename)) {
616+ continue ;
617+ }
618+ written_files.insert (filename);
619+
614620 const std::string& src = fileToSrc.at (filename).str ();
615621
616622 std::ostringstream lib_stream;
You can’t perform that action at this time.
0 commit comments