Repository navigation
Commit e965330
committed
fix: perceptron save_to_json breaks on Windows (os.open can't fd-open a directory)
The POSIX shared-temp-squat hardening (_open_private_model_dir) called
os.open(loc, O_RDONLY|O_DIRECTORY|O_NOFOLLOW) on the model *directory*, which
fails on Windows with PermissionError [Errno 13] -- Windows cannot open a
directory as a file descriptor via os.open. This broke every PerceptronTagger
train/save (and its doctest) on windows-latest.
The shared-temp squat is a POSIX concern: on Windows %TEMP% is per-user and
ACL-protected, so there is no world-writable-/tmp exposure. Gate the hardened
dir-fd path to POSIX and use a plain makedirs + write on Windows (the original
pre-hardening behaviour). POSIX keeps the atomic O_NOFOLLOW dir-fd hardening
unchanged; the squat regression tests are already POSIX-only.1 parent df1bb4c commit e965330
1 file changed
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
343 | 355 | | |
344 | 356 | | |
345 | 357 | | |
| |||
0 commit comments