Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete O_flags used for file open #1853

Merged
merged 2 commits into from
Dec 27, 2024

Conversation

BCSharp
Copy link
Member

@BCSharp BCSharp commented Dec 26, 2024

Includes part of the solution for #1225.

Copy link
Contributor

@slozier slozier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -54,6 +55,19 @@ 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)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having PythonHidden on a private seems kind of odd but I guess it doesn't hurt...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it doesn't hurt, but the less verbosity the better. I assume the same applies to internal, though I see there are a few PythonHidden that are internal already in the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, I wonder why we'd have them on internal members. Maybe something that was public at some point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for example at ByteArray.UnsafeByteList. It was established 5 years ago as internal, but 4 years ago you added PythonHidden in #1000. Do you remember why?

Copy link
Contributor

@slozier slozier Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't say I remember, but looking at #693 I changed Bytes.GetUnsafeByteArray (which was public) to a public property and then in a follow up commit made it internal. I guess I forgot to remove the PythonHidden when I did this. ByteArray.UnsafeByteList is probably a copy/paste...

@@ -701,7 +701,7 @@ def test_errors(self):

with self.assertRaises(OSError) as cm:
open('path_too_long' * 100)
self.assertEqual(cm.exception.errno, (36 if is_posix else 22) if is_netcoreapp and not is_posix or sys.version_info >= (3,6) else 2)
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I mind the explicit number check, but wondering if we should be using the errno module values instead to make things easier to decipher.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, assuming that errno is not buggy 😄

@BCSharp BCSharp merged commit e6620f1 into IronLanguages:main Dec 27, 2024
8 checks passed
@BCSharp BCSharp deleted the open_file_flags branch December 27, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants