summaryrefslogtreecommitdiffstats
path: root/Lib/warnings.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Issue #18200: Update the stdlib (except tests) to useBrett Cannon2013-06-141-3/+3
| | | | ModuleNotFoundError.
* Replace IOError with OSError (#16715)Andrew Svetlov2012-12-251-1/+1
|
* Closes #13258: Use callable() built-in in the standard library.Florent Xicluna2011-10-281-1/+1
|
* Add a new warning gategory, ResourceWarning, as discussed on python-dev. It ↵Georg Brandl2010-10-241-0/+7
| | | | | | | | is silent by default, except when configured --with-pydebug. Emit this warning from the GC shutdown procedure, rather than just printing to stderr.
* _warnings exposed two variables with the name 'default_action' andBrett Cannon2010-09-041-3/+3
| | | | | | | | | | | 'once_registry'. This is bad as the warnings module had variables named 'defaultaction' and 'onceregistry' which are what people should be looking at (technically those variables shouldn't be mucked with as they are undocumented, but we all know better than to believe that isn't happening). So the variables from _warnings have been renamed to come off as private and to avoid confusion over what variable should be used. Closes issue #9766. Thanks to Antoine Pitrou for the discovery.
* Merged revisions 77402,77505,77510 via svnmerge fromBenjamin Peterson2010-06-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r77402 | brett.cannon | 2010-01-09 20:56:19 -0600 (Sat, 09 Jan 2010) | 12 lines DeprecationWarning is now silent by default. This was originally suggested by Guido, discussed on the stdlib-sig mailing list, and given the OK by Guido directly to me. What this change essentially means is that Python has taken a policy of silencing warnings that are only of interest to developers by default. This should prevent users from seeing warnings which are triggered by an application being run against a new interpreter before the app developer has a chance to update their code. Closes issue #7319. Thanks to Antoine Pitrou, Ezio Melotti, and Brian Curtin for helping with the issue. ........ r77505 | brett.cannon | 2010-01-14 14:00:28 -0600 (Thu, 14 Jan 2010) | 7 lines The silencing of DeprecationWarning was not taking -3 into consideration. Since Py3K warnings are DeprecationWarning by default this was causing -3 to essentially be a no-op. Now DeprecationWarning is only silenced if -3 is not used. Closes issue #7700. Thanks Ezio Melotti and Florent Xicluna for patch help. ........ r77510 | brett.cannon | 2010-01-14 19:31:45 -0600 (Thu, 14 Jan 2010) | 1 line Remove C++/C99-style comments. ........
* Merged revisions ↵Georg Brandl2009-10-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there. ........ r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line Fix markup. ........ r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line #7125: fix typo. ........ r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line #7126: os.environ changes *do* take effect in subprocesses started with os.system(). ........ r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line #7116: str.join() takes an iterable. ........ r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. ........ r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line Fix missing word. ........ r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line Fix punctuation. ........ r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line Revert unintended change. ........ r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line Fix markup. ........ r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line Fix duplicate target. ........ r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line Add a new directive marking up implementation details and start using it. ........ r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line Make it more robust. ........ r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line Document new directive. ........ r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line Allow short form with text as argument. ........ r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line Fix stylesheet for multi-paragraph impl-details. ........ r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line Use "impl-detail" directive where applicable. ........ r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line #6324: membership test tries iteration via __iter__. ........ r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line #7088: document new functions in signal as Unix-only. ........ r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line Reorder __slots__ fine print and add a clarification. ........ r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line #7035: improve docs of the various <method>_errors() functions, and give them docstrings. ........ r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line #7156: document curses as Unix-only. ........ r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line #6977: getopt does not support optional option arguments. ........ r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line Add proper references. ........ r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line Make printout margin important. ........ r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line #7188: fix optionxform() docs. ........ r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines add further note about what's passed to optionxform ........ r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines Improve some docstrings in the 'warnings' module. ........ r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line Fix markup. ........ r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line Fix a demo. ........ r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line Fix a strange mis-edit. ........
* Use true booleans and PEP8 for argdefaults.Georg Brandl2009-09-161-2/+2
|
* forward port r66386Benjamin Peterson2008-10-161-0/+15
|
* Merged revisions 66321 via svnmerge fromBrett Cannon2008-09-091-25/+21
| | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r66321 | brett.cannon | 2008-09-08 17:49:16 -0700 (Mon, 08 Sep 2008) | 7 lines warnings.catch_warnings() now returns a list or None instead of the custom WarningsRecorder object. This makes the API simpler to use as no special object must be learned. Closes issue 3781. Review by Benjamin Peterson. ........
* Merge in r66135. Doing also required removing a stale DeprecationWarning alongBrett Cannon2008-09-021-0/+70
| | | | | with moving warnings.catch_warnings() over to keyword-only parameters for its constructor (as documented in the 2.6 docs).