From 4d9829ec8be91e94ae586b59f1a8105d14d1d672 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 28 Apr 2021 14:02:47 +0200 Subject: [PATCH] Fix some issues related to python scripts: - make PadArray.py compatible python2/3 - fix a wxWidgets warning in pcbnew_scripting_helpers.cpp shown in some cases --- pcbnew/python/plugins/PadArray.py | 6 +++++- pcbnew/swig/pcbnew_scripting_helpers.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pcbnew/python/plugins/PadArray.py b/pcbnew/python/plugins/PadArray.py index 60a6e93971..9edbb18c2b 100644 --- a/pcbnew/python/plugins/PadArray.py +++ b/pcbnew/python/plugins/PadArray.py @@ -212,7 +212,11 @@ class PadGridArray(PadArray): @param py: pitch in y-direction @param centre: array centre point """ - super(PadGridArray, self).__init__(pad) + + try: + super().__init__(pad) + except TypeError: + super(PadGridArray, self).__init__(pad) self.nx = int(nx) self.ny = int(ny) diff --git a/pcbnew/swig/pcbnew_scripting_helpers.cpp b/pcbnew/swig/pcbnew_scripting_helpers.cpp index 8718b04ce4..17c37c5530 100644 --- a/pcbnew/swig/pcbnew_scripting_helpers.cpp +++ b/pcbnew/swig/pcbnew_scripting_helpers.cpp @@ -45,6 +45,8 @@ #include #include #include +#include + static PCB_EDIT_FRAME* s_PcbEditFrame = NULL; @@ -124,6 +126,10 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat ) pro.MakeAbsolute(); wxString projectPath = pro.GetFullPath(); + // Ensure the "C" locale is temporary set, before reading any file + // It also avoid wxWidget alerts about locale issues, later, when using Python 3 + LOCALE_IO dummy; + PROJECT* project = GetSettingsManager()->GetProject( projectPath ); if( !project )