Commit d89c576
authored
fix: zipfile.ZipInfo monkey-patch NameError after init cleanup (#79)
The _safe_zi wrapper referenced _orig_zi as a module-level global, but
`del _orig_zi` at the end of the init block destroyed it before any
call to ZipInfo() could use it. This broke all libraries that use
zip-based formats (python-docx, openpyxl, etc.) with:
NameError: name '_orig_zi' is not defined
Wrap the patch in a function so _orig becomes a proper closure cell
that survives the namespace cleanup.
Adds a regression test using python-docx's Document() constructor.
Signed-off-by: danbugs <danilochiarlone@gmail.com>1 parent 581b8d8 commit d89c576
2 files changed
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
| |||
0 commit comments