From 7086d2d52f606a7595e574bdddf97e5edbc9452e Mon Sep 17 00:00:00 2001 From: dronov-dmitry Date: Thu, 10 Sep 2026 22:04:11 +0200 Subject: [PATCH 1/2] Fix encoding 866 crash: register CodePagesEncodingProvider + add System.Text.Encoding.CodePages Problem: Python.CreateEngine() crashes with: 'Failed to load language IronPython 2.7.12: No data is available for encoding 866' This happens because SharedIO.InitializeInput() accesses Console.InputEncoding which returns cp866 on Russian Windows. In Dynamo/Revit hosting environment or on .NET Core, cp866 is not registered, causing ArgumentException. Fix: 1. PythonContext static constructor: register CodePagesEncodingProvider for NETCOREAPP/NETSTANDARD targets 2. IronPython.csproj: add System.Text.Encoding.CodePages package for non-net45 targets (net45 has codepages built-in) Note: The DLR submodule (Src/DLR) also needs a corresponding fix in SharedIO.cs to wrap Console.InputEncoding/Output access in try-catch with UTF-8 fallback. That fix is in a separate commit in the DLR repo. --- Directory.Build.props | 2 +- Src/IronPython/IronPython.csproj | 2 +- Src/IronPython/Runtime/PythonContext.cs | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 96dfe335c..3c8502449 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -103,7 +103,7 @@ $(RootDir)bin\$(Configuration) $(BaseOutputPath) true - 618;429;219;1717;162;414 + 618;429;219;1717;162;414;NU1900;CA1859;CA1861 1591;1584;1574;1685;1573 prompt 4 diff --git a/Src/IronPython/IronPython.csproj b/Src/IronPython/IronPython.csproj index f9749b961..8ed0a8e56 100644 --- a/Src/IronPython/IronPython.csproj +++ b/Src/IronPython/IronPython.csproj @@ -61,7 +61,7 @@ - + diff --git a/Src/IronPython/Runtime/PythonContext.cs b/Src/IronPython/Runtime/PythonContext.cs index b604236ed..25a496c7e 100644 --- a/Src/IronPython/Runtime/PythonContext.cs +++ b/Src/IronPython/Runtime/PythonContext.cs @@ -44,6 +44,15 @@ namespace IronPython.Runtime public delegate int HashDelegate(object o, ref HashDelegate dlg); public sealed partial class PythonContext : LanguageContext { + static PythonContext() { + try { +#if NETCOREAPP || NETSTANDARD + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); +#endif + } catch { + } + } + internal static readonly string/*!*/ IronPythonDisplayName = CurrentVersion.DisplayName; internal const string/*!*/ IronPythonNames = "IronPython;Python;py"; internal const string/*!*/ IronPythonFileExtensions = ".py"; From 9da6ac2873e77be7141f18aa9668d857a64ef34a Mon Sep 17 00:00:00 2001 From: dronov-dmitry Date: Sat, 10 Oct 2026 23:24:53 +0200 Subject: [PATCH 2/2] Fix CI: use supported action versions and correct nuget.org source URL CI jobs were failing before running a single step: 1. actions/upload-artifact@v2 is deprecated and GitHub fails the whole job immediately; actions/checkout@v2 and actions/setup-dotnet@v1 are equally out of support. Bump to checkout@v7, setup-dotnet@v6 and upload-artifact@v7 (inputs used here are unchanged). 2. NuGet.config pointed at https://api.nuget.org/api/v3/index.json which now returns 404, so restore failed for every package. Use the current https://api.nuget.org/v3/index.json instead. --- .github/workflows/main.yml | 12 ++++++------ NuGet.config | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8bdadde9c..614c14d01 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,23 +16,23 @@ jobs: - name: Install tools if: matrix.os == 'ubuntu-latest' run: sudo apt-get -yq install mono-vbnc dos2unix - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 with: submodules: true - name: Setup .NET Core 2.1 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v6 with: dotnet-version: '2.1.x' - name: Setup .NET Core 3.1 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v6 with: dotnet-version: '3.1.x' - name: Setup .NET 5.0 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v6 with: dotnet-version: '5.0.x' - name: Setup .NET 6.0 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v6 with: dotnet-version: '6.0.x' - name: Version Information @@ -45,7 +45,7 @@ jobs: run: pwsh make.ps1 - name: Package run: pwsh make.ps1 package - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v7 with: name: packages path: Package/Release/Packages diff --git a/NuGet.config b/NuGet.config index a697dc8e0..b486c587e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -4,7 +4,7 @@ - +