Skip to content

Commit

Permalink
Update after review
Browse files Browse the repository at this point in the history
  • Loading branch information
BCSharp committed Dec 27, 2024
1 parent c360095 commit 265b163
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions Src/IronPython/Modules/_io.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,13 @@ public static partial class PythonIOModule {

private static int O_EXCL => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 0x400 : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 0x800 : 0x80;

[PythonHidden(PlatformsAttribute.PlatformFamily.Windows)]
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
private static int O_CLOEXEC => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 0x1000000 : 0x80000;

[PythonHidden(PlatformsAttribute.PlatformFamily.Unix)]
[SupportedOSPlatform("windows")]
private static int O_BINARY => 0x8000;

[PythonHidden(PlatformsAttribute.PlatformFamily.Unix)]
[SupportedOSPlatform("windows")]
private static int O_NOINHERIT => 0x80;

Expand Down
2 changes: 1 addition & 1 deletion Src/Scripts/generate_os_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def generate_O_flags(cw, flagvalues, access):
if codes[darwin_idx] is None:
hidden_on += ["PlatformID.MacOSX"]
supported_on.discard(systems[darwin_idx])
if hidden_on:
if hidden_on and (access == 'public' or access == 'protected' or access == 'protected internal'):
cw.write(f"[PythonHidden({', '.join(hidden_on)})]")
if len(supported_on) != len(systems):
for s in sorted(supported_on):
Expand Down
5 changes: 3 additions & 2 deletions Tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# The .NET Foundation licenses this file to you under the Apache 2.0 License.
# See the LICENSE file in the project root for more information.

import errno
import os
import sys
import unittest
import _thread

CP16623_LOCK = _thread.allocate_lock()

from iptest import IronPythonTestCase, is_cli, is_cpython, is_netcoreapp, is_posix, is_linux, is_osx, is_windows, run_test, skipUnlessIronPython
from iptest import IronPythonTestCase, is_cli, is_cpython, is_netcoreapp, is_posix, is_windows, run_test, skipUnlessIronPython

class FileTest(IronPythonTestCase):

Expand Down Expand Up @@ -701,7 +702,7 @@ def test_errors(self):

with self.assertRaises(OSError) as cm:
open('path_too_long' * 100)
self.assertEqual(cm.exception.errno, (63 if is_osx else 36 if is_linux else 22) if is_netcoreapp and not is_posix or sys.version_info >= (3,6) else 2)
self.assertEqual(cm.exception.errno, (errno.ENAMETOOLONG if is_posix else errno.EINVAL) if is_netcoreapp and not is_posix or sys.version_info >= (3,6) else errno.ENOENT)

def test_write_bytes(self):
fname = self.temp_file
Expand Down

0 comments on commit 265b163

Please sign in to comment.