Commit Graph

63 Commits

Author SHA1 Message Date
Antoine Pitrou 87538e7bc4 Issue #4180: The warnings registries are now reset when the filters are modified. 2014-09-18 02:42:05 +02:00
Antoine Pitrou cb0a006fd1 Issue #4180: The warnings registries are now reset when the filters are modified. 2014-09-18 02:40:46 +02:00
Berker Peksag d8089e0d04 Issue #16382: Improve exception message of warnings.warn() for bad category.
Initial patch by Phil Elson.
2014-07-11 19:50:25 +03:00
Victor Stinner bd303c165b Issue #19512, #19515: remove shared identifiers, move identifiers where they
are used.

Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
2013-11-07 23:07:29 +01:00
Victor Stinner 090543736f Issue #19512: add some common identifiers to only create common strings once,
instead of creating temporary Unicode string objects

Add also more identifiers in pythonrun.c to avoid temporary Unicode string
objets for the interactive interpreter.
2013-11-06 22:41:44 +01:00
Victor Stinner dcdd05b0b4 Close #19442: warn_explicit() does nothing when called late during Python shutdown
After more tests, I now think that it is the safest option.
2013-11-01 00:55:30 +01:00
Victor Stinner ae233eab5c Issue #19437: Fix show_warning() of _warnings, stop at the first error to not
call a Python function with an exception set
2013-10-31 14:51:38 +01:00
Victor Stinner 3cd04aa1b2 Issue #19437: Fix get_filter() from _warnings, don't call PyObject_IsSubclass()
with an exception set
2013-10-31 14:46:00 +01:00
Victor Stinner 856f45f09c Issue #19442: Fix warnings emitted during Python shutdown
Warnings may be emitted during Python shutdown, like "unclosed file XXX".
During shutdown, globals()['__main__'] may be None.
2013-10-30 00:04:59 +01:00
Victor Stinner a4c704b260 Issue #19424: Fix the warnings module to accept filename containing surrogate
characters.
2013-10-29 23:43:41 +01:00
Victor Stinner ce5f4fba11 Issue #19421: fix a check in warnings.warn() to be able to use it during Python
finalization.

sys.argv is set to None during Python finalization: add PyList_Check() to avoid
a crash in PyList_Size().
2013-10-28 18:47:22 +01:00
Victor Stinner 14e461d5b9 Close #11619: The parser and the import machinery do not encode Unicode
filenames anymore on Windows.
2013-08-26 22:28:21 +02:00
Victor Stinner 78e2c985ac Issue #18408: Fix show_warning(), clear also the exception raised by
_Py_DisplaySourceLine()

For example, _PyGC_DumpShutdownStats() calls PyErr_WarnExplicitFormat() while
the import machinery does not work anymore, _Py_DisplaySourceLine() fails when
trying to import the io module.
2013-07-16 01:54:37 +02:00
Antoine Pitrou 070cb3c9be Issue #1545463: At shutdown, defer finalization of codec modules so that stderr remains usable.
(should fix Windows buildbot failures on test_gc)
2013-05-08 13:23:25 +02:00
Antoine Pitrou aa5c5c60f1 Finally fix all test_capi refleaks 2012-01-18 21:45:15 +01:00
Benjamin Peterson 21e0da228d remove some usage of Py_UNICODE_TOUPPER/LOWER 2012-01-11 21:00:42 -05:00
Florent Xicluna 720682efd1 Merge 3.2 2011-12-09 23:42:29 +01:00
Florent Xicluna 5126df602c Remove obsolete py3k comment. 2011-12-09 23:41:21 +01:00
Victor Stinner 9e30aa52fd Fix misuse of PyUnicode_GET_SIZE() => PyUnicode_GET_LENGTH()
And PyUnicode_GetSize() => PyUnicode_GetLength()
2011-11-21 02:49:52 +01:00
Martin v. Löwis d10759f6ed Make _PyUnicode_FromId return borrowed references.
http://mail.python.org/pipermail/python-dev/2011-November/114347.html
2011-11-07 13:00:05 +01:00
Martin v. Löwis 1c67dd9b15 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId. 2011-10-14 15:16:45 +02:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Martin v. Löwis 1ee1b6fe0d Use identifier API for PyObject_GetAttrString. 2011-10-10 18:11:30 +02:00
Martin v. Löwis afe55bba33 Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
2011-10-09 10:38:36 +02:00
Victor Stinner b62a7b268a Fix _warnings.c: make the filename string ready 2011-10-06 02:34:51 +02:00
Martin v. Löwis d63a3b8beb Implement PEP 393. 2011-09-28 07:41:54 +02:00
Brett Cannon 52a7d98273 Make warnings accept a callable for showwarnings instead of
restricting itself to just functions and methods (which allows
built-in functions to be used, etc.).

Closes issue #10271. Thanks to lekma for the bug report.
2011-07-17 19:17:55 -07:00
Benjamin Peterson bb4a747b69 start out this branch always with filename NULL 2011-07-04 22:27:16 -05:00
Benjamin Peterson a55007a620 plug refleak 2011-07-03 22:18:34 -05:00
Victor Stinner 8b0508ed4e Issue #12467: warnings: fix a race condition if a warning is emitted at
shutdown, if globals()['__file__'] is None.
2011-07-04 02:43:09 +02:00
Ezio Melotti 4969f709cc #11515: Merge with 3.1. 2011-03-15 05:59:46 +02:00
Ezio Melotti 42da663e6f #11515: fix several typos. Patch by Piotr Kasprzyk. 2011-03-15 05:18:48 +02:00
Victor Stinner cb428f0162 Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
encoding instead of UTF-8.
2010-12-27 20:10:36 +00:00
Georg Brandl 08be72d0aa Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
except when configured --with-pydebug.

Emit this warning from the GC shutdown procedure, rather than just printing to stderr.
2010-10-24 15:11:22 +00:00
Brett Cannon ef0e6c3b04 _warnings exposed two variables with the name 'default_action' and
'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.
2010-09-04 18:24:04 +00:00
Victor Stinner 4a2b7a1b14 Issue #9425: Create PyErr_WarnFormat() function
Similar to PyErr_WarnEx() but use PyUnicode_FromFormatV() to format the warning
message.

Strip also some trailing spaces.
2010-08-13 14:03:48 +00:00
Victor Stinner 2e5f1178ac Issue #9425: fix setup_context() for non-ascii filenames
setup_context() replaces .pyc or .pyo filename suffix by .py, but it
didn't work if the filename contains a non-ascii character because the
function used the wrong unit for the length (number of characters
instead of the number of bytes).

With this patch, it uses unicode filenames instead of bytes filenames,
to fix the bug and to be fully unicode compliant.
2010-08-08 22:12:45 +00:00
Benjamin Peterson 7ab4b8d3a2 Merged revisions 77402,77505,77510 via svnmerge from
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.
........
2010-06-28 00:01:59 +00:00
Victor Stinner 25bb0fdb67 Merged revisions 82059,82061 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82059 | victor.stinner | 2010-06-18 01:08:50 +0200 (ven., 18 juin 2010) | 5 lines

  Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
  Fix the encoding of the modules filename.

  Reindent also traceback.h, just because I hate tabs :-)
........
  r82061 | victor.stinner | 2010-06-18 01:17:37 +0200 (ven., 18 juin 2010) | 2 lines

  Issue #6543: Mention the author of the patch, Amaury Forgeot d'Arc
........
2010-06-17 23:23:37 +00:00
Victor Stinner 0fe25a445d Issue #6543: Write the traceback in the terminal encoding instead of utf-8.
Fix the encoding of the modules filename.

Reindent also traceback.h, just because I hate tabs :-)
2010-06-17 23:08:50 +00:00
Victor Stinner 148051a054 Recorded merge of revisions 81364 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r81364 | victor.stinner | 2010-05-19 22:40:50 +0200 (mer., 19 mai 2010) | 3 lines

  Issue #8766: Initialize _warnings module before importing the first module.
  Fix a crash if an empty directory called "encodings" exists in sys.path.
........
2010-05-20 21:00:34 +00:00
Victor Stinner 7d79b8b771 Issue #8766: Initialize _warnings module before importing the first module.
Fix a crash if an empty directory called "encodings" exists in sys.path.
2010-05-19 20:40:50 +00:00
Antoine Pitrou 7f14f0d8a0 Recorded merge of revisions 81032 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines

  Recorded merge of revisions 81029 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

    Untabify C files. Will watch buildbots.
  ........
................
2010-05-09 16:14:21 +00:00
Antoine Pitrou f95a1b3c53 Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
2010-05-09 15:52:27 +00:00
Alexandre Vassalotti 7b82b40a47 Merged revisions 72487-72488,72879 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72487 | jeffrey.yasskin | 2009-05-08 17:51:06 -0400 (Fri, 08 May 2009) | 7 lines

  PyCode_NewEmpty:
  Most uses of PyCode_New found by http://www.google.com/codesearch?q=PyCode_New
  are trying to build an empty code object, usually to put it in a dummy frame
  object. This patch adds a PyCode_NewEmpty wrapper which lets the user specify
  just the filename, function name, and first line number, instead of also
  requiring lots of code internals.
........
  r72488 | jeffrey.yasskin | 2009-05-08 18:23:21 -0400 (Fri, 08 May 2009) | 13 lines

  Issue 5954, PyFrame_GetLineNumber:
  Most uses of PyCode_Addr2Line
  (http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get
  the line number of a specified frame, but there's no way to do that directly.
  Forcing people to go through the code object makes them know more about the
  guts of the interpreter than they should need.

  The remaining uses of PyCode_Addr2Line seem to be getting the line from a
  traceback (for example,
  http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line),
  which is replaced by the tb_lineno field.  So we may be able to deprecate
  PyCode_Addr2Line entirely for external use.
........
  r72879 | jeffrey.yasskin | 2009-05-23 19:23:01 -0400 (Sat, 23 May 2009) | 14 lines

  Issue #6042:
  lnotab-based tracing is very complicated and isn't documented very well.  There
  were at least 3 comment blocks purporting to document co_lnotab, and none did a
  very good job. This patch unifies them into Objects/lnotab_notes.txt which
  tries to completely capture the current state of affairs.

  I also discovered that we've attached 2 layers of patches to the basic tracing
  scheme. The first layer avoids jumping to instructions that don't start a line,
  to avoid problems in if statements and while loops.  The second layer
  discovered that jumps backward do need to trace at instructions that don't
  start a line, so it added extra lnotab entries for 'while' and 'for' loops, and
  added a special case for backward jumps within the same line. I replaced these
  patches by just treating forward and backward jumps differently.
........
2009-07-21 04:30:03 +00:00
Hirokazu Yamamoto 680ac292ac Merged revisions 74046 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r74046 | hirokazu.yamamoto | 2009-07-17 15:55:42 +0900 | 13 lines

  Merged revisions 74040,74042 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r74040 | hirokazu.yamamoto | 2009-07-17 15:20:46 +0900 | 1 line

    Issue #6415: Fixed warnings.warn sagfault on bad formatted string.
  ........
    r74042 | hirokazu.yamamoto | 2009-07-17 15:26:54 +0900 | 1 line

    NEWS about r74040.
  ........
................
2009-07-17 07:02:18 +00:00
Hirokazu Yamamoto 1c0c00371f Merged revisions 74040,74042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74040 | hirokazu.yamamoto | 2009-07-17 15:20:46 +0900 | 1 line

  Issue #6415: Fixed warnings.warn sagfault on bad formatted string.
........
  r74042 | hirokazu.yamamoto | 2009-07-17 15:26:54 +0900 | 1 line

  NEWS about r74040.
........
2009-07-17 06:55:42 +00:00
Brett Cannon 0759dd66c5 Merged revisions 70965 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r70965 | brett.cannon | 2009-04-01 11:03:59 -0700 (Wed, 01 Apr 2009) | 5 lines

  _warnings was importing itself to get an attribute. That's bad if warnings gets
  called in a thread that was spawned by an import itself.

  Last part to close #1665206.
........
2009-04-01 18:13:07 +00:00
Christian Heimes 1a8501c648 Merged revisions 66748 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66748 | christian.heimes | 2008-10-02 21:47:50 +0200 (Thu, 02 Oct 2008) | 1 line

  Fixed a couple more C99 comments and one occurence of inline.
........

+ another // comment in bytesobject
2008-10-02 19:56:01 +00:00
Brett Cannon 54bd41d81b The _warnings module did not properly handle cases where strings were not being
passed in as the message to use for a warning. Fixed along with making the code
more robust against other errors where return values were not checked.

Closes issue 3639.
Code review by Benjamin Peterson.
2008-09-02 04:01:42 +00:00