MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _showwarnmsg

Function _showwarnmsg

tools/python-3.11.9-amd64/Lib/warnings.py:97–113  ·  view source on GitHub ↗

Hook to write a warning to a file; replace if you like.

(msg)

Source from the content-addressed store, hash-verified

95_showwarning_orig = showwarning
96
97def _showwarnmsg(msg):
98 """Hook to write a warning to a file; replace if you like."""
99 try:
100 sw = showwarning
101 except NameError:
102 pass
103 else:
104 if sw is not _showwarning_orig:
105 # warnings.showwarning() was replaced
106 if not callable(sw):
107 raise TypeError("warnings.showwarning() must be set to a "
108 "function or method")
109
110 sw(msg.message, msg.category, msg.filename, msg.lineno,
111 msg.file, msg.line)
112 return
113 _showwarnmsg_impl(msg)
114
115# Keep a reference to check if the function was replaced
116_formatwarning_orig = formatwarning

Callers 1

warn_explicitFunction · 0.85

Calls 2

_showwarnmsg_implFunction · 0.85
callableFunction · 0.50

Tested by

no test coverage detected