Scripting: Fix missing utf8 to unicode string conversion in swig file

So non ASCII7 chars in .py filenames were non working, especially on Windows.
Fixes #5507
https://gitlab.com/kicad/code/kicad/issues/5507
This commit is contained in:
jean-pierre charras 2021-02-21 11:38:10 +01:00
parent 8a12aa4e3a
commit 8beeb368d2
2 changed files with 17 additions and 6 deletions

View File

@ -277,7 +277,7 @@ bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit,
if( s_PcbEditFrame )
{
bool ok = s_PcbEditFrame->ExportVRML_File( aFullFileName, aMMtoWRMLunit,
aExport3DFiles, aUseRelativePaths,
aExport3DFiles, aUseRelativePaths,
aUsePlainPCB, a3D_Subdir, aXRef, aYRef );
return ok;
}

View File

@ -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 <miguelangel@nbee.es>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -67,21 +67,24 @@ NOT_LOADED_WIZARDS=""
"""
PLUGIN_DIRECTORIES_SEARCH=""
""" the trace of errors during execution of footprint wizards scripts
"""
the trace of errors during execution of footprint wizards scripts
Warning: strings (internally unicode) are returned as UTF-8 compatible C strings
"""
FULL_BACK_TRACE=""
def GetUnLoadableWizards():
global NOT_LOADED_WIZARDS
return NOT_LOADED_WIZARDS
return NOT_LOADED_WIZARDS.encode( 'UTF-8' )
def GetWizardsSearchPaths():
global PLUGIN_DIRECTORIES_SEARCH
return PLUGIN_DIRECTORIES_SEARCH
return PLUGIN_DIRECTORIES_SEARCH.encode( 'UTF-8' )
def GetWizardsBackTrace():
global FULL_BACK_TRACE
return FULL_BACK_TRACE
return FULL_BACK_TRACE.encode( 'UTF-8' )
def LoadPluginModule(Dirname, ModuleName, FileName):
@ -153,6 +156,7 @@ def LoadPlugins(bundlepath=None, userpath=None):
Initialise Scripting/Plugin python environment and load plugins.
Arguments:
Note: bundlepath and userpath are given utf8 encoded, to be compatible with asimple C string
bundlepath -- The path to the bundled scripts.
The bundled Plugins are relative to this path, in the
"plugins" subdirectory.
@ -184,6 +188,13 @@ def LoadPlugins(bundlepath=None, userpath=None):
import importlib
importlib.invalidate_caches()
"""
bundlepath and userpath are strings utf-8 encoded (compatible "C" strings).
So convert these utf8 encoding to unicode strings to avoid any encoding issue.
"""
bundlepath = bundlepath.decode( 'UTF-8' );
userpath = userpath.decode( 'UTF-8' );
config_path = pcbnew.SETTINGS_MANAGER.GetUserSettingsPath()
plugin_directories=[]