|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -import linecache |
4 | 3 | import re |
5 | 4 | from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, Tuple, TypeVar |
6 | 5 |
|
@@ -212,12 +211,9 @@ def make_dict_unstructure_fn( |
212 | 211 | + [" return res"] |
213 | 212 | ) |
214 | 213 | script = "\n".join(total_lines) |
215 | | - fname = "" |
216 | | - if _cattrs_use_linecache: |
217 | | - fname = generate_unique_filename( |
218 | | - cl, "unstructure", reserve=_cattrs_use_linecache |
219 | | - ) |
220 | | - linecache.cache[fname] = len(script), None, total_lines, fname |
| 214 | + fname = generate_unique_filename( |
| 215 | + cl, "unstructure", lines=total_lines if _cattrs_use_linecache else [] |
| 216 | + ) |
221 | 217 |
|
222 | 218 | eval(compile(script, fname, "exec"), globs) |
223 | 219 | finally: |
@@ -627,10 +623,9 @@ def make_dict_structure_fn( |
627 | 623 | ] |
628 | 624 |
|
629 | 625 | script = "\n".join(total_lines) |
630 | | - fname = "" |
631 | | - if _cattrs_use_linecache: |
632 | | - fname = generate_unique_filename(cl, "structure", reserve=_cattrs_use_linecache) |
633 | | - linecache.cache[fname] = len(script), None, total_lines, fname |
| 626 | + fname = generate_unique_filename( |
| 627 | + cl, "structure", lines=total_lines if _cattrs_use_linecache else [] |
| 628 | + ) |
634 | 629 |
|
635 | 630 | eval(compile(script, fname, "exec"), globs) |
636 | 631 |
|
|
0 commit comments