(str_change_func)
| 40 | return buf |
| 41 | |
| 42 | def _modify_str_or_docstring(str_change_func): |
| 43 | @functools.wraps(str_change_func) |
| 44 | def wrapper(func_or_str): |
| 45 | if isinstance(func_or_str, (str,)): |
| 46 | func = None |
| 47 | doc = func_or_str |
| 48 | else: |
| 49 | func = func_or_str |
| 50 | doc = func.__doc__ |
| 51 | |
| 52 | # PYTHONOPTIMIZE=2 strips docstrings, so they can disappear unexpectedly |
| 53 | if doc is not None: |
| 54 | doc = str_change_func(doc) |
| 55 | |
| 56 | if func: |
| 57 | func.__doc__ = doc |
| 58 | return func |
| 59 | return doc |
| 60 | return wrapper |
| 61 | |
| 62 | def safe_unicode(e): |
| 63 | """unicode(e) with various fallbacks. Used for exceptions, which may not be |
nothing calls this directly
no outgoing calls
no test coverage detected