Commit 75479c2
Fix
If a partial function generated by `functools.partial` is passed into
fiddle AND certain exceptions are raised, accessing `__qualname__`
will trigger another exception, prevent the users from seeing the
real error messages.
Type type `TypeOrCallableProducingT = Union[Callable[..., T], Type[T]]`
does not guarantee that `__qualname__` will exist.
- Added a regression test case in third_party/py/fiddle/_src/config_test.py that uses functools.partial to trigger the bug.
- Replace all `self.__fn_or_cls__.__qualname__` with the existing `self._fn_or_cls_name_repr()` which already solved the problem.
PiperOrigin-RevId: 893119387__qualname__ AttributeError in fiddle config.py1 parent bf94959 commit 75479c2
2 files changed
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
854 | 867 | | |
855 | 868 | | |
856 | 869 | | |
| |||
0 commit comments