Skip to content

Commit 91fc9f4

Browse files
committed
Update after review
1 parent 3bce846 commit 91fc9f4

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

Src/IronPython.Modules/mmap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ file stream handle (if any), so that when the original file is disposed, the han
116116
(if any), plus `Dispose` of it if it owned the file stream.
117117
118118
`SafeFileHandle` closes the underlying file descriptor on dispose and sets it to invalid. It is OK
119-
to close the handle several times, or even if it add-reffed and in use somewhere else. The
120-
descriptor will be closed ass soon as the refcount is released, and in the meantime, it will prevent
119+
to close the handle several times, or even if it is add-reffed and in use somewhere else. The
120+
descriptor will be closed as soon as the refcount is released, and in the meantime, it will prevent
121121
future addrefs.
122122
123123
MmapDefault - Rules of Engagement

Src/IronPython.Modules/nt.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ private static int UnixDup(int fd, int fd2, out Stream? stream) {
438438
if (ClrModule.IsMono) {
439439
// Elaborate workaround on Mono to avoid UnixStream as out
440440
stream = new Mono.Unix.UnixStream(res, ownsHandle: false);
441-
FileAccess fileAccess = stream.CanRead ? stream.CanWrite ? FileAccess.ReadWrite : FileAccess.Read : FileAccess.Write;
441+
FileAccess fileAccess = stream.CanWrite ? stream.CanRead ? FileAccess.ReadWrite : FileAccess.Write : FileAccess.Read;
442442
stream.Dispose();
443443
try {
444444
// FileStream on Mono created with a file descriptor might not work: https://github.com/mono/mono/issues/12783
@@ -916,7 +916,6 @@ public static object open(CodeContext/*!*/ context, [NotNone] string path, int f
916916
// Use PosixFileStream to operate on fd directly
917917
// On Mono, we must use FileStream due to limitations in MemoryMappedFile
918918
Stream s = PosixFileStream.Open(path, flags, unchecked((uint)mode), out int fd);
919-
//Stream s = PythonIOModule.FileIO.OpenFilePosix(path, flags, mode, out int fd);
920919
if ((flags & O_APPEND) != 0) {
921920
s.Seek(0L, SeekOrigin.End);
922921
}

Src/IronPython/Modules/_fileio.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public FileIO(CodeContext/*!*/ context, [NotNone] string name, [NotNone] string
109109
// Use PosixFileStream to operate on fd directly
110110
// On Mono, we must use FileStream due to limitations in MemoryMappedFile
111111
var stream = PosixFileStream.Open(name, flags, 0b_110_110_110, out int fd); // mode: rw-rw-rw-
112-
//var stream = OpenFilePosix(name, flags, 0b_110_110_110, out int fd);
113112
if ((flags & O_APPEND) != 0) {
114113
stream.Seek(0L, SeekOrigin.End);
115114
}
@@ -152,7 +151,7 @@ public FileIO(CodeContext/*!*/ context, [NotNone] string name, [NotNone] string
152151
}
153152
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
154153
// On POSIX, register the file descriptor with the file manager right after file opening
155-
// Because the .NET case is already handled above before `switch`, this branch runs only on Mono
154+
// This branch is needed for Mono, the .NET case is already handled above before `switch`
156155
_context.FileManager.GetOrAssignId(_streams);
157156
// according to [documentation](https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.safefilehandle?view=net-9.0#remarks)
158157
// accessing SafeFileHandle sets the current stream position to 0

0 commit comments

Comments
 (0)