From 986b90424b66bc891e2629bc620e79684fa052ee Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 27 Apr 2018 14:03:33 +0200 Subject: [PATCH] Fix an issue in LoadPlugins(bundlepath=None) python method (Windows specific). For some obscure (for me) reason, the path separators in bundlepath are seen as escape seq, and the path can be incorrectly handled (when \n or \r are found in this string). it happens only for this path, not for other paths in LoadPlugins. For bundlepath parameter, unix separator is now used. Fixes: lp:1766879 https://bugs.launchpad.net/kicad/+bug/1766879 --- pcbnew/swig/python_scripting.cpp | 11 +++++++++-- scripting/kicadplugins.i | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pcbnew/swig/python_scripting.cpp b/pcbnew/swig/python_scripting.cpp index 2fd02bc123..f3ced963a5 100644 --- a/pcbnew/swig/python_scripting.cpp +++ b/pcbnew/swig/python_scripting.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -450,7 +450,14 @@ wxString PyScriptingPath() wxFileName scriptPath( path ); scriptPath.MakeAbsolute(); - return scriptPath.GetFullPath(); + // Convert '\' to '/' in path, because later python script read \n or \r + // as escaped sequence, and create issues. Moreover, python uses unix notation in paths + // in many cases. + // It can happen on Windows. + path = scriptPath.GetFullPath(); + path.Replace( '\\', '/' ); + + return path; } wxString PyPluginsPath() diff --git a/scripting/kicadplugins.i b/scripting/kicadplugins.i index ddb9b01d8b..1da74d05e0 100644 --- a/scripting/kicadplugins.i +++ b/scripting/kicadplugins.i @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -168,9 +168,11 @@ def LoadPlugins(bundlepath=None): Initialise Scripting/Plugin python environment and load plugins. Arguments: - scriptpath -- The path to the bundled scripts. + bundlepath -- The path to the bundled scripts. The bunbled Plugins are relative to this path, in the "plugins" subdirectory. + WARNING: bundlepath must use '/' as path separator, and not '\' + because it creates issues (\n and \r are seen as escaped seq) NOTE: These are all of the possible "default" search paths for kicad python scripts. These paths will ONLY be added to the python