IronLanguages / IronLanguages/ironpython3
`os` string marshalling on Linux is inconsistent for unencodable characters
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
On Linux, some of our os methods use .NET methods while others use Mono.Unix.Native.Syscall. For example, os.mkdir uses the .NET Directory.CreateDirectory, but os.stat uses Syscall.stat. It appears that the string marshalling used by .NET and Mono.Unix is different (only?) for unencodable characters. This causes unexpected exceptions:
import os
f = '\udcff'
os.mkdir(f)
os.stat(f) # raises FileNotFoundError
os.rmdir(f)
Similarly for other calls that use Syscall behind the scenes, such as os.open which uses Syscall.open.
I only tested this with .NET 10 on Linux so it's possible Mono doesn't have this issue? Note that during my testing Directory.CreateDirectory, Syscall.mkdir and the CPython (3.12) os.mkdir all created different folders for the \udcff filename. I'm just noting the difference with CPython because I noticed it, my main concern is incompatibility with our own os methods. Although in practice it's probably all irrelevant. 😄
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the os.mkdir, os.stat, os.rmdir, and os.open entry points and compare their use of Directory.CreateDirectory with Mono.Unix.Native.Syscall. Reproduce the \udcff example on Linux and compare the paths created by each call. Done means the affected os methods consistently handle unencodable characters without unexpected cross-method failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100