summaryrefslogtreecommitdiffstats
path: root/Lib/warnings.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-122088: Copy the coroutine status of the underlying callable in ↵Sebastian Rittau2024-07-231-0/+4
| | | | | | `@warnings.deprecated` (#122086) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-121163: Add "all" as an valid alias for "always" in ↵Kirill Podoprigora2024-06-301-8/+7
| | | | | | warnings.simplefilter() (#121164) Add support for ``all`` as an valid alias for ``always`` in ``warnings.simplefilter()`` and ``warnings.filterswarnings()``.
* gh-117535: Change unknown filename of warnings from `sys` to `<sys>` (#118018)Tian Gao2024-04-191-2/+2
|
* gh-113781: Silence AttributeError in warning module during Python ↵Serhiy Storchaka2024-01-091-3/+4
| | | | | | finalization (GH-113813) The tracemalloc module can already be cleared.
* bpo-39912: Raise appropriate exceptions in filterwarnings() and ↵Rémi Lapeyre2023-12-011-12/+18
| | | | simplefilter() (GH-18878)
* gh-104003: Implement PEP 702 (#104004)Jelle Zijlstra2023-11-291-1/+130
| | | | Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* Fix docstring of `warnings._deprecated` to show correct `remove` value (#105178)Nikita Sobolev2023-06-011-1/+1
|
* gh-39615: Add warnings.warn() skip_file_prefixes support (#100840)Gregory P. Smith2023-01-281-7/+22
| | | | | `warnings.warn()` gains the ability to skip stack frames based on code filename prefix rather than only a numeric `stacklevel=` via a new `skip_file_prefixes=` keyword argument.
* gh-91230: Concise catch_warnings with simplefilter (#91435)Zac Hatfield-Dodds2022-04-241-1/+11
|
* bpo-47061: deprecate the `aifc` module (GH-32134)Brett Cannon2022-04-051-0/+21
| | | Co-authored-by: Christian Heimes <christian@python.org>
* bpo-39056: Fix handling invalid warning category in the -W option. (GH-17618)Serhiy Storchaka2020-01-051-17/+13
| | | No longer import the re module if it is not needed.
* bpo-35178: Fix warnings._formatwarnmsg() (GH-12033)Xtreak2019-03-011-1/+1
| | | | | Ensure custom formatwarning function can receive line as positional argument. Co-Authored-By: Tashrif Billah <tashrifbillah@gmail.com>
* bpo-29564: warnings suggests to enable tracemalloc (GH-10486)Victor Stinner2018-11-131-6/+17
| | | | | The warnings module now suggests to enable tracemalloc if the source is specified, tracemalloc module is available, but tracemalloc is not tracing memory allocations.
* bpo-33375: Get filename for warnings from frame.f_code.co_filename (GH-6622)Thomas Kluyver2018-06-081-14/+2
| | | More consistent with how other parts of Python find the filename (e.g. tracebacks and pdb).
* bpo-32591: Add native coroutine origin tracking (#5250)Nathaniel J. Smith2018-01-211-0/+23
| | | | | | * Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth * Use coroutine origin information in the unawaited coroutine warning * Stop using set_coroutine_wrapper in asyncio debug mode * In BaseEventLoop.set_debug, enable debugging in the correct thread
* bpo-31975 (PEP 565): Show DeprecationWarning in __main__ (GH-4458)Nick Coghlan2018-01-081-1/+3
| | | | | | | | | | | | | - primary change is to add a new default filter entry for 'default::DeprecationWarning:__main__' - secondary change is an internal one to cope with plain strings in the warning module's internal filter list (this avoids the need to create a compiled regex object early on during interpreter startup) - assorted documentation updates, including many more examples of configuring the warnings settings - additional tests to ensure that both the pure Python and the C accelerated warnings modules have the expected default configuration
* bpo-32230: Set sys.warnoptions with -X dev (#4820)Victor Stinner2017-12-121-29/+6
| | | | | | | | | | | | | | Rather than supporting dev mode directly in the warnings module, this instead adjusts the initialisation code to add an extra 'default' entry to sys.warnoptions when dev mode is enabled. This ensures that dev mode behaves *exactly* as if `-Wdefault` had been passed on the command line, including in the way it interacts with `sys.warnoptions`, and with other command line flags like `-bb`. Fix also bpo-20361: have -b & -bb options take precedence over any other warnings options. Patch written by Nick Coghlan, with minor modifications of Victor Stinner.
* bpo-32121: Add most_recent_first parameter to tracemalloc.Traceback.format ↵Jesse-Bakker2017-11-291-1/+1
| | | | | | | | (#4534) * Add most_recent_first parameter to tracemalloc.Traceback.format to allow reversing the order of the frames in the output * Reversed default sorting of tracemalloc.Traceback frames * Allowed negative limit, truncating from the other side.
* bpo-27535: Fix memory leak with warnings ignore (#4489)Victor Stinner2017-11-271-1/+0
| | | | | | | The warnings module doesn't leak memory anymore in the hidden warnings registry for the "ignore" action of warnings filters. The warn_explicit() function doesn't add the warning key to the registry anymore for the "ignore" action.
* bpo-32089: Use default action for ResourceWarning (#4584)Victor Stinner2017-11-271-1/+1
| | | | | In development and debug mode, use the "default" action, rather than the "always" action, for ResourceWarning in the default warnings filters.
* bpo-27535: Optimize warnings.warn() (#4508)Victor Stinner2017-11-221-3/+14
| | | | | | | | | | | | | * Optimize warnings.filterwarnings(). Replace re.compile('') with None to avoid the cost of calling a regex.match() method, whereas it always matchs. * Optimize get_warnings_attr(): replace PyObject_GetAttrString() with _PyObject_GetAttrId(). Cleanup also create_filter(): * Use _Py_IDENTIFIER() to allow to cleanup strings at Python finalization * Replace Py_FatalError() with a regular exceptions
* bpo-32089: Fix warnings filters in dev mode (#4482)Victor Stinner2017-11-211-3/+11
| | | | | | | | | | The developer mode (-X dev) now creates all default warnings filters to order filters in the correct order to always show ResourceWarning and make BytesWarning depend on the -b option. Write a functional test to make sure that ResourceWarning is logged twice at the same location in the developer mode. Add a new 'dev_mode' field to _PyCoreConfig.
* bpo-32088: Display Deprecation in debug mode (#4474)Victor Stinner2017-11-201-5/+9
| | | | | | | | When Python is build is debug mode (Py_DEBUG), DeprecationWarning, PendingDeprecationWarning and ImportWarning warnings are now displayed by default. test_venv: run "-m pip" and "-m ensurepip._uninstall" with -W ignore::DeprecationWarning since pip code is not part of Python.
* Simplify code in warnings modules (#1935)Alex Gaynor2017-06-041-3/+7
| | | Metaprogramming a list of attributes was excessive, and made the code less readable and slower.
* bpo-29762: More use "raise from None". (#569)Serhiy Storchaka2017-04-051-4/+4
| | | This hides unwanted implementation details from tracebacks.
* Issue #28835: Tidy previous showwarning changes based on review comments.Ned Deily2016-12-061-28/+27
| | | | Patch by Serhiy Storchaka.
* catch_warnings() calls showwarning() if overridenVictor Stinner2016-12-061-2/+12
| | | | | Issue #28089: Fix a regression introduced in warnings.catch_warnings(): call warnings.showwarning() if it was overriden inside the context manager.
* Issue #18383: Merge warnings fix from 3.5Martin Panter2016-05-261-11/+15
|\
| * Issue #18383: Avoid adding duplicate filters when warnings is reloadedMartin Panter2016-05-261-11/+15
| | | | | | | | Based on patch by Alex Shkop.
* | Merge typo fixes from 3.5Martin Panter2016-04-051-1/+1
|\ \ | |/
| * Fix typos in documentation and commentsMartin Panter2016-04-051-1/+1
| |
* | Merge 3.5Victor Stinner2016-03-241-5/+26
|\ \ | |/ | | | | | | | | Issue #21925: warnings.formatwarning() now catches exceptions when calling linecache.getline() and tracemalloc.get_object_traceback() to be able to log ResourceWarning emitted late during the Python shutdown process.
| * warnings.formatwarning(): catch exceptionsVictor Stinner2016-03-241-2/+8
| | | | | | | | | | | | Issue #21925: warnings.formatwarning() now catches exceptions on linecache.getline(...) to be able to log ResourceWarning emitted late during the Python shutdown process.
* | Add a source parameter to warnings.warn()Victor Stinner2016-03-221-2/+2
| | | | | | | | | | | | | | | | Issue #26604: * Add a new optional source parameter to _warnings.warn() and warnings.warn() * Modify asyncore, asyncio and _pyio modules to set the source parameter when logging a ResourceWarning warning
* | Fix test_loggingVictor Stinner2016-03-191-27/+33
| | | | | | | | | | Issue #26568: Fix implementation of showwarning() and formatwarning() for test_logging.
* | On ResourceWarning, log traceback where the object was allocatedVictor Stinner2016-03-191-4/+18
| | | | | | | | | | | | | | | | | | | | Issue #26567: * Add a new function PyErr_ResourceWarning() function to pass the destroyed object * Add a source attribute to warnings.WarningMessage * Add warnings._showwarnmsg() which uses tracemalloc to get the traceback where source object was allocated.
* | Add _showwarnmsg() and _formatwarnmsg() to warningsVictor Stinner2016-03-181-16/+53
|/ | | | | | | | | | | | | Issue #26568: add new _showwarnmsg() and _formatwarnmsg() functions to the warnings module. The C function warn_explicit() now calls warnings._showwarnmsg() with a warnings.WarningMessage as parameter, instead of calling warnings.showwarning() with multiple parameters. _showwarnmsg() calls warnings.showwarning() if warnings.showwarning() was replaced. Same for _formatwarnmsg(): call warnings.formatwarning() if it was replaced.
* Issue #24305: Prevent import subsystem stack frames from being countedLarry Hastings2015-09-061-4/+27
| | | | by the warnings.warn(stacklevel=) parameter.
* Issue #23731: Implement PEP 488.Brett Cannon2015-04-131-1/+1
| | | | | | The concept of .pyo files no longer exists. Now .pyc files have an optional `opt-` tag which specifies if any extra optimizations beyond the peepholer were applied.
* Fixed a typo in a comment (issue #23016).Serhiy Storchaka2014-12-141-1/+1
|\
| * Fixed a typo in a comment (issue #23016).Serhiy Storchaka2014-12-141-1/+1
| |
* | Issue #23016: A warning no longer produces an AttributeError when the programSerhiy Storchaka2014-12-101-0/+3
|\ \ | |/ | | | | is run with pythonw.exe.
| * Issue #23016: A warning no longer produces AttributeError when the programSerhiy Storchaka2014-12-101-0/+3
| | | | | | | | is run with pythonw.exe.
* | Issue #4180: The warnings registries are now reset when the filters are ↵Antoine Pitrou2014-09-181-1/+16
|\ \ | |/ | | | | modified.
| * Issue #4180: The warnings registries are now reset when the filters are ↵Antoine Pitrou2014-09-181-1/+16
| | | | | | | | modified.
* | Merge for issue #22191 fixBrett Cannon2014-08-221-1/+2
|\ \ | |/
| * Issue #22191: Fix warnings.__all__.Brett Cannon2014-08-221-1/+2
| | | | | | | | Thanks to Jon Poler for the patch.
* | Issue #16382: Improve exception message of warnings.warn() for bad category.Berker Peksag2014-07-111-1/+3
|/ | | | Initial patch by Phil Elson.
* Close #19379: Lazily import linecache in the warnings module, to make ↵Antoine Pitrou2013-10-241-4/+2
| | | | startup with warnings faster until a warning gets printed.
* Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a)Brett Cannon2013-07-041-3/+3
|