diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 1c47611985..597a6fac07 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1503,8 +1503,15 @@ void PCB_EDIT_FRAME::PythonSyncEnvironmentVariables() #if defined( KICAD_SCRIPTING ) const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables(); + // Set the environment variables for python scripts + // note: the strint will be encoded UTF8 for python env for( auto& var : vars ) pcbnewUpdatePythonEnvVar( var.first, var.second.GetValue() ); + + // Because the env vars can de modifed by the python scripts (rewritten in UTF8), + // regenerate them (in unicode) for our normal environment + for( auto& var : vars ) + wxSetEnv( var.first, var.second.GetValue() ); #endif } @@ -1515,6 +1522,10 @@ void PCB_EDIT_FRAME::PythonSyncProjectName() wxString evValue; wxGetEnv( PROJECT_VAR_NAME, &evValue ); pcbnewUpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue ); + + // Because PROJECT_VAR_NAME can be modifed by the python scripts (rewritten in UTF8), + // regenerate it (in unicode) for our normal environment + wxSetEnv( PROJECT_VAR_NAME, evValue ); #endif }