ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

[Android] PlatformNotSupportedException when importing non-builtin modules

Open Mewnojs opened this issue 2 years ago • 1 comments

Prerequisites

The issue tracker is used to report bugs and request new features, NOT to ask questions.

Questions should be posted in Discussions or to the users mailing list which can be accessed at https://ironpython.groups.io/g/users.

  • [✓] Are you running the latest version?
  • [✓] Are you reporting to the correct repository?
  • [✓] Did you perform a cursory search?

Description

PlatformNotSupportedException prevents any module from being imported.

Steps to Reproduce

  1. Target Android .Net 6 (MAUI)
  2. var aPythonEngine = Python.CreateEngine();
  3. aPythonEngine.Execute("import foobar");

Expected behavior: No error if "foobar" is in the search path and valid; "No module named 'foobar'" if it does not exist

Actual behavior: Throwing System.PlatformNotSupportedException: Operation is not supported on this platform. at IronPython.Modules.PythonNT.stat(String path, IDictionary2 kwargs) at ...

Workaround: Hooking OperatingSystem.IsOSPlatform(string) and let it return true when the argument is "Linux", then the issue magically disappears. Everything else seem to work fine with android (As long as you redirected your stdin).

Versions

3.4.0

Mewnojs avatar Apr 10 '23 09:04 Mewnojs

The breaking change as a cause of this issue: dotnet/runtime#51052

Mewnojs avatar May 19 '23 10:05 Mewnojs