Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs Decorates a function such that if it calls itself with the same first argument, it returns `fillvalue` instead of recursing. Largely copied from reprlib.recursive_repr
(fillvalue='...')
| 491 | |
| 492 | |
| 493 | def _recursive_guard(fillvalue='...'): |
| 494 | """ |
| 495 | Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs |
| 496 | |
| 497 | Decorates a function such that if it calls itself with the same first |
| 498 | argument, it returns `fillvalue` instead of recursing. |
| 499 | |
| 500 | Largely copied from reprlib.recursive_repr |
| 501 | """ |
| 502 | |
| 503 | def decorating_function(f): |
| 504 | repr_running = set() |
| 505 | |
| 506 | @functools.wraps(f) |
| 507 | def wrapper(self, *args, **kwargs): |
| 508 | key = id(self), get_ident() |
| 509 | if key in repr_running: |
| 510 | return fillvalue |
| 511 | repr_running.add(key) |
| 512 | try: |
| 513 | return f(self, *args, **kwargs) |
| 514 | finally: |
| 515 | repr_running.discard(key) |
| 516 | |
| 517 | return wrapper |
| 518 | |
| 519 | return decorating_function |
| 520 | |
| 521 | |
| 522 | # gracefully handle recursive calls, when object arrays contain themselves |
nothing calls this directly
no outgoing calls
no test coverage detected