]> granicus.if.org Git - python/commitdiff
Merged revisions 72458 via svnmerge from
authorPhilip Jenvey <pjenvey@underboss.org>
Fri, 8 May 2009 02:47:02 +0000 (02:47 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Fri, 8 May 2009 02:47:02 +0000 (02:47 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72458 | philip.jenvey | 2009-05-07 19:28:39 -0700 (Thu, 07 May 2009) | 2 lines

  #4351: more appropriate DeprecationWarning stacklevels
........

Lib/cgi.py
Lib/commands.py
Lib/gzip.py
Lib/macpath.py
Lib/ntpath.py
Lib/plistlib.py
Lib/posixpath.py
Lib/tarfile.py
Lib/xmllib.py

index 0bb5b8eaf1d78a755019bead9971c5d4b1610ec9..fd303830cd7cfd6141c78b55a2ce7e1d24eb40dc 100755 (executable)
@@ -181,14 +181,14 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
 def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
     """Parse a query given as a string argument."""
     warn("cgi.parse_qs is deprecated, use urlparse.parse_qs \
-            instead",PendingDeprecationWarning)
+            instead", PendingDeprecationWarning, 2)
     return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
 
 
 def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
     """Parse a query given as a string argument."""
     warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
-            PendingDeprecationWarning)
+         PendingDeprecationWarning, 2)
     return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing)
 
 def parse_multipart(fp, pdict):
index 287aa27f4dd3d1fb10a5daae57df0600c3d0743a..858b3d6f35ba31b42e58f4cd9e3d9c993689f09d 100644 (file)
@@ -33,7 +33,7 @@ __all__ = ["getstatusoutput","getoutput","getstatus"]
 def getstatus(file):
     """Return output of "ls -ld <file>" in a string."""
     import warnings
-    warnings.warn("commands.getstatus() is deprecated", DeprecationWarning)
+    warnings.warn("commands.getstatus() is deprecated", DeprecationWarning, 2)
     return getoutput('ls -ld' + mkarg(file))
 
 
index 7a3f813de62bc67c8ae84aa0ee1791492ea051c6..b09d0186c3d86b27b8abd98b8468e664066802bb 100644 (file)
@@ -114,7 +114,7 @@ class GzipFile:
     @property
     def filename(self):
         import warnings
-        warnings.warn("use the name attribute", DeprecationWarning)
+        warnings.warn("use the name attribute", DeprecationWarning, 2)
         if self.mode == WRITE and self.name[-3:] != ".gz":
             return self.name + ".gz"
         return self.name
index 38e6eaeda9163c71388c1bb7a12889eb7bef9701..14e49a312e66054bd5f055969793b0c352f2ca92 100644 (file)
@@ -170,7 +170,8 @@ def walk(top, func, arg):
     beyond that arg is always passed to func.  It can be used, e.g., to pass
     a filename pattern, or a mutable object designed to accumulate
     statistics.  Passing None for arg is common."""
-    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.")
+    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
+                      stacklevel=2)
     try:
         names = os.listdir(top)
     except os.error:
index 714f2054161ed2b731be7a57f3cb502d56ee1d34..37f32f019d54e18558952645b5ffc8b07bf95e8e 100644 (file)
@@ -250,7 +250,8 @@ def walk(top, func, arg):
     beyond that arg is always passed to func.  It can be used, e.g., to pass
     a filename pattern, or a mutable object designed to accumulate
     statistics.  Passing None for arg is common."""
-    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.")
+    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
+                      stacklevel=2)
     try:
         names = os.listdir(top)
     except os.error:
index 05a6ae81fcc9e26da3276dd6a43d88ce16a48d37..0b1748cd481e04aac5d95ce7e4ea1d1b35223cac 100644 (file)
@@ -114,7 +114,8 @@ def writePlistToString(rootObject):
 def readPlistFromResource(path, restype='plst', resid=0):
     """Read plst resource from the resource fork of path.
     """
-    warnings.warnpy3k("In 3.x, readPlistFromResource is removed.")
+    warnings.warnpy3k("In 3.x, readPlistFromResource is removed.",
+                      stacklevel=2)
     from Carbon.File import FSRef, FSGetResourceForkName
     from Carbon.Files import fsRdPerm
     from Carbon import Res
@@ -129,7 +130,7 @@ def readPlistFromResource(path, restype='plst', resid=0):
 def writePlistToResource(rootObject, path, restype='plst', resid=0):
     """Write 'rootObject' as a plst resource to the resource fork of path.
     """
-    warnings.warnpy3k("In 3.x, writePlistToResource is removed.")
+    warnings.warnpy3k("In 3.x, writePlistToResource is removed.", stacklevel=2)
     from Carbon.File import FSRef, FSGetResourceForkName
     from Carbon.Files import fsRdWrPerm
     from Carbon import Res
@@ -300,13 +301,13 @@ class _InternalDict(dict):
             raise AttributeError, attr
         from warnings import warn
         warn("Attribute access from plist dicts is deprecated, use d[key] "
-             "notation instead", PendingDeprecationWarning)
+             "notation instead", PendingDeprecationWarning, 2)
         return value
 
     def __setattr__(self, attr, value):
         from warnings import warn
         warn("Attribute access from plist dicts is deprecated, use d[key] "
-             "notation instead", PendingDeprecationWarning)
+             "notation instead", PendingDeprecationWarning, 2)
         self[attr] = value
 
     def __delattr__(self, attr):
@@ -316,14 +317,14 @@ class _InternalDict(dict):
             raise AttributeError, attr
         from warnings import warn
         warn("Attribute access from plist dicts is deprecated, use d[key] "
-             "notation instead", PendingDeprecationWarning)
+             "notation instead", PendingDeprecationWarning, 2)
 
 class Dict(_InternalDict):
 
     def __init__(self, **kwargs):
         from warnings import warn
         warn("The plistlib.Dict class is deprecated, use builtin dict instead",
-             PendingDeprecationWarning)
+             PendingDeprecationWarning, 2)
         super(Dict, self).__init__(**kwargs)
 
 
@@ -336,7 +337,7 @@ class Plist(_InternalDict):
     def __init__(self, **kwargs):
         from warnings import warn
         warn("The Plist class is deprecated, use the readPlist() and "
-             "writePlist() functions instead", PendingDeprecationWarning)
+             "writePlist() functions instead", PendingDeprecationWarning, 2)
         super(Plist, self).__init__(**kwargs)
 
     def fromFile(cls, pathOrFile):
index 4f3519b2d0f7dd6356263c3cec6a6e8befe189d2..cdce5afedecf21931d089bd430427dd199e54bf3 100644 (file)
@@ -216,7 +216,8 @@ def walk(top, func, arg):
     beyond that arg is always passed to func.  It can be used, e.g., to pass
     a filename pattern, or a mutable object designed to accumulate
     statistics.  Passing None for arg is common."""
-    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.")
+    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
+                      stacklevel=2)
     try:
         names = os.listdir(top)
     except os.error:
index 508d88ea20f88f843289f4933322857e2040e3f1..2c228395d78a2560c13647699b1705ee77e201ee 100644 (file)
@@ -1591,7 +1591,8 @@ class TarFile(object):
         return self.format == USTAR_FORMAT
     def _setposix(self, value):
         import warnings
-        warnings.warn("use the format attribute instead", DeprecationWarning)
+        warnings.warn("use the format attribute instead", DeprecationWarning,
+                      2)
         if value:
             self.format = USTAR_FORMAT
         else:
index 2a189cdd8fe51f94d3ef94cf7cd28255cf1d1b5f..96ee8411e7a74a347a9b2935fc8b3760d0a7491a 100644 (file)
@@ -6,7 +6,8 @@ import re
 import string
 
 import warnings
-warnings.warn("The xmllib module is obsolete.  Use xml.sax instead.", DeprecationWarning)
+warnings.warn("The xmllib module is obsolete.  Use xml.sax instead.",
+              DeprecationWarning, 2)
 del warnings
 
 version = '0.3'