Repository navigation
Raise ENAMETOOLONG for path components over NAME_MAX - #1375
Conversation
The fake filesystem accepted paths with components longer than 255 characters, which the real Posix filesystem refuses with ENAMETOOLONG. A new filesystem-level check raises the error when a too long component is reached and all preceding components resolve, so a missing ancestor still reports ENOENT as before. Fixes pytest-dev#1374 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
for more information, see https://pre-commit.ci
| under Posix) silently succeeding instead of raising `ENAMETOOLONG` | ||
| in the fake filesystem, for example in `os.mkdir`, `os.stat`, `os.listdir`, | ||
| `os.remove`, `os.truncate`, `os.rename`, `os.link` and file open | ||
| (see [issue #1374](https://github.com/pytest-dev/pyfakefs/issues/1374)) |
There was a problem hiding this comment.
No need to list all examples here (this is what the link to the issue is for), I prefer shorter release notes entries for readability. For example:
- path operations on paths with too long path components now correctly raise
ENAMETOOLONGunder Posix (see ...)
There was a problem hiding this comment.
Done — shortened the entry following your suggested wording, thanks! (commit 22d7c88)
Shorten the release notes entry as requested by the review, following the reviewer's preferred short style for readability. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
|
Merged — thank you! Glad the release-notes entry landed in the short style. Nice to see it merged the same day the fix went up. On a personal note: I'm on the lookout for my next role (Full Stack (PHP, NodeJs, Python) / Data Science / Applied AI / Devtools, based in India). Happy to chat if there's an opening on your side or one you'd recommend: |
|
Can't help with the job. This project is purely free-time, and my day job does not fit your skills (and we are not hiring). |
Describe the changes
Fixes #1374.
The fake filesystem accepted path components longer than
NAME_MAX(255 characters under Posix) that the real OS refuses withENAMETOOLONG. This adds a filesystem-level check (FakeFilesystem._check_component_length, configurable viaFakeFilesystem.name_max) applied in the path resolution and creation entry points (resolve_path,lresolve,makedir,remove,rename,create_link).The check only reports the error when all preceding components resolve, so paths under a missing ancestor keep reporting
ENOENTas before. Windows is skipped, as its limits are more complicated and are not emulated.Tasks