improve deprecation, start changelog

--HG--
branch : trunk
This commit is contained in:
holger krekel
2009-11-12 13:10:30 +01:00
parent a4a652af85
commit f4ec2d1ecd
11 changed files with 49 additions and 25 deletions

View File

@@ -13,14 +13,18 @@ class Warning(DeprecationWarning):
def _apiwarn(startversion, msg, stacklevel=2, function=None):
# below is mostly COPIED from python2.4/warnings.py's def warn()
# Get context information
if stacklevel == "initpkg":
frame = sys._getframe(stacklevel == "initpkg" and 1 or stacklevel)
level = 2
if isinstance(stacklevel, str):
frame = sys._getframe(1)
level = 1
found = frame.f_code.co_filename.find(stacklevel) != -1
while frame:
co = frame.f_code
if co.co_name == "__getattr__" and co.co_filename.find("initpkg") !=-1:
stacklevel = level
break
if co.co_filename.find(stacklevel) == -1:
if found:
stacklevel = level
break
else:
found = True
level += 1
frame = frame.f_back
else: