Skip to content

Commit 275cc39

Browse files
authored
Make msvcrt Windows-only (#1708)
1 parent f3490bc commit 275cc39

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

Src/IronPython.Modules/msvcrt.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Numerics;
1212
using System.Reflection;
1313
using System.Runtime.InteropServices;
14+
using System.Runtime.Versioning;
1415

1516
using Microsoft.Scripting.Runtime;
1617

@@ -24,6 +25,7 @@
2425
[assembly: PythonModule("msvcrt", typeof(IronPython.Modules.PythonMsvcrt), PlatformsAttribute.PlatformFamily.Windows)]
2526
namespace IronPython.Modules {
2627
[PythonType("msvcrt")]
28+
[SupportedOSPlatform("windows")]
2729
public class PythonMsvcrt {
2830
public const string __doc__ = "Functions from the Microsoft Visual C Runtime.";
2931

@@ -76,10 +78,6 @@ private static bool TryGetFileHandle(Stream stream, out object handle) {
7678
handle = ((PipeStream)stream).SafePipeHandle.DangerousGetHandle().ToPython();
7779
return true;
7880
}
79-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
80-
handle = GetFileHandleUnix();
81-
if (handle != null) return true;
82-
}
8381
#endif
8482

8583
// if all else fails try reflection
@@ -91,14 +89,6 @@ private static bool TryGetFileHandle(Stream stream, out object handle) {
9189

9290
handle = null;
9391
return false;
94-
95-
// Isolate Mono.Unix from the rest of the method so that we don't try to load the Mono.Unix assembly on Windows.
96-
object GetFileHandleUnix() {
97-
if (stream is Mono.Unix.UnixStream) {
98-
return ((Mono.Unix.UnixStream)stream).Handle;
99-
}
100-
return null;
101-
}
10292
}
10393

10494
[Documentation(@"get_osfhandle(fd) -> file handle

0 commit comments

Comments
 (0)