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

Function _deprecated

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

Warn that *name* is deprecated or should be removed. RuntimeError is raised if *remove* specifies a major/minor tuple older than the current Python version or the same version but past the alpha. The *message* argument is formatted with *name* and *remove* as a Python version

(name, message=_DEPRECATED_MSG, *, remove, _version=sys.version_info)

Source from the content-addressed store, hash-verified

497_DEPRECATED_MSG = "{name!r} is deprecated and slated for removal in Python {remove}"
498
499def _deprecated(name, message=_DEPRECATED_MSG, *, remove, _version=sys.version_info):
500 """Warn that *name* is deprecated or should be removed.
501
502 RuntimeError is raised if *remove* specifies a major/minor tuple older than
503 the current Python version or the same version but past the alpha.
504
505 The *message* argument is formatted with *name* and *remove* as a Python
506 version (e.g. "3.11").
507
508 """
509 remove_formatted = f"{remove[0]}.{remove[1]}"
510 if (_version[:2] > remove) or (_version[:2] == remove and _version[3] != "alpha"):
511 msg = f"{name!r} was slated for removal after Python {remove_formatted} alpha"
512 raise RuntimeError(msg)
513 else:
514 msg = message.format(name=name, remove=remove_formatted)
515 warn(msg, DeprecationWarning, stacklevel=3)
516
517
518# Private utility function called by _PyErr_WarnUnawaitedCoroutine

Callers 2

asynchat.pyFile · 0.90
smtpd.pyFile · 0.90

Calls 2

warnFunction · 0.70
formatMethod · 0.45

Tested by

no test coverage detected