Commit bbd9a19
fix: rm_rf now handles directories without S_IXUSR permission (#7940)
The on_rm_rf_error handler previously only set S_IRUSR|S_IWUSR (read+write)
when retrying failed removals, and silently skipped os.open/os.scandir
failures. This meant directories lacking execute permission (S_IXUSR) could
not be traversed or removed by shutil.rmtree.
Now the handler:
- Uses S_IRWXU (read+write+execute) for all permission fixes
- Handles os.open and os.scandir PermissionError by fixing permissions
on the path and its parent, then removing the entry directly
- Includes a guard against infinite recursion when chmod has no effect
Supersedes #7941 which took the approach of delegating to
tempfile.TemporaryDirectory._rmtree.
Co-authored-by: Cursor AI <ai@cursor.sh>
Co-authored-by: Claude Opus <claude@anthropic.com>1 parent bc57e69 commit bbd9a19
3 files changed
Lines changed: 97 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
73 | 92 | | |
74 | 93 | | |
75 | 94 | | |
| |||
98 | 117 | | |
99 | 118 | | |
100 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
101 | 139 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
107 | 143 | | |
| 144 | + | |
108 | 145 | | |
109 | 146 | | |
110 | 147 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 148 | | |
118 | | - | |
| 149 | + | |
119 | 150 | | |
120 | 151 | | |
121 | 152 | | |
122 | | - | |
| 153 | + | |
123 | 154 | | |
124 | 155 | | |
125 | 156 | | |
126 | | - | |
| 157 | + | |
127 | 158 | | |
128 | 159 | | |
129 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
503 | 522 | | |
504 | 523 | | |
505 | 524 | | |
| |||
527 | 546 | | |
528 | 547 | | |
529 | 548 | | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 549 | + | |
537 | 550 | | |
538 | 551 | | |
539 | 552 | | |
540 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
541 | 585 | | |
542 | 586 | | |
543 | 587 | | |
| |||
0 commit comments