Commit f23fb66
Fix in file position logic: file descriptor and Python-side handle (#20270)
Summary:
This addresses #18436
The logic replicates the essence of closing file descriptors in numpy:
https://github.com/numpy/numpy/blob/bf20e3034085716c4559ec4bf31b23b6016f266c/numpy/core/include/numpy/npy_3kcompat.h#L278
This stores the position of the file descriptor before resetting it to the Python handle offset, then resets to the original position before exit. The Python-side handle is then updated to reflect the new position. Also added somewhat more demanding tests to cover this.
Pull Request resolved: #20270
Differential Revision: D15275902
Pulled By: soumith
fbshipit-source-id: 5ca8a52b61c7718d2e69571f72f80b1350b0acdb1 parent c406bf2 commit f23fb66
File tree
3 files changed
+48
-23
lines changed- test
- torch
- csrc/generic
3 files changed
+48
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9287 | 9287 | | |
9288 | 9288 | | |
9289 | 9289 | | |
9290 | | - | |
9291 | | - | |
9292 | | - | |
9293 | | - | |
9294 | | - | |
9295 | | - | |
9296 | | - | |
9297 | | - | |
9298 | | - | |
9299 | | - | |
9300 | | - | |
9301 | | - | |
9302 | | - | |
9303 | | - | |
9304 | | - | |
| 9290 | + | |
| 9291 | + | |
| 9292 | + | |
| 9293 | + | |
| 9294 | + | |
| 9295 | + | |
| 9296 | + | |
| 9297 | + | |
| 9298 | + | |
| 9299 | + | |
| 9300 | + | |
| 9301 | + | |
| 9302 | + | |
| 9303 | + | |
| 9304 | + | |
| 9305 | + | |
| 9306 | + | |
| 9307 | + | |
| 9308 | + | |
| 9309 | + | |
9305 | 9310 | | |
9306 | 9311 | | |
9307 | 9312 | | |
9308 | | - | |
| 9313 | + | |
| 9314 | + | |
9309 | 9315 | | |
9310 | 9316 | | |
9311 | | - | |
| 9317 | + | |
| 9318 | + | |
| 9319 | + | |
9312 | 9320 | | |
9313 | | - | |
9314 | | - | |
9315 | | - | |
9316 | | - | |
| 9321 | + | |
| 9322 | + | |
| 9323 | + | |
| 9324 | + | |
| 9325 | + | |
| 9326 | + | |
| 9327 | + | |
| 9328 | + | |
9317 | 9329 | | |
9318 | 9330 | | |
9319 | 9331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
| 265 | + | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| |||
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
275 | 287 | | |
276 | 288 | | |
277 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
582 | | - | |
| 582 | + | |
| 583 | + | |
583 | 584 | | |
584 | 585 | | |
0 commit comments