Show Idle-format warning (after replacing warnings.showwarning). The differences are the formatter called, the file=None replacement, which can be None, the capture of the consequence AttributeError, and the output of a hard-coded prompt.
(
message, category, filename, lineno, file=None, line=None)
| 71 | warning_stream = sys.__stderr__ # None, at least on Windows, if no console. |
| 72 | |
| 73 | def idle_showwarning( |
| 74 | message, category, filename, lineno, file=None, line=None): |
| 75 | """Show Idle-format warning (after replacing warnings.showwarning). |
| 76 | |
| 77 | The differences are the formatter called, the file=None replacement, |
| 78 | which can be None, the capture of the consequence AttributeError, |
| 79 | and the output of a hard-coded prompt. |
| 80 | """ |
| 81 | if file is None: |
| 82 | file = warning_stream |
| 83 | try: |
| 84 | file.write(idle_formatwarning( |
| 85 | message, category, filename, lineno, line=line)) |
| 86 | file.write(">>> ") |
| 87 | except (AttributeError, OSError): |
| 88 | pass # if file (probably __stderr__) is invalid, skip warning. |
| 89 | |
| 90 | _warnings_showwarning = None |
| 91 |
nothing calls this directly
no test coverage detected