diff --git a/doc/changelog.txt b/doc/changelog.txt index fa456042f..e686ca6e6 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,3 +1,12 @@ +Changes between 1.1.1 and 1.1.0 +===================================== + +- fix a bug with path.check(versioned=True) for svn paths + +- try harder to have deprecation warnings for py.compat.* accesses + report a correct location + + Changes between 1.1.0 and 1.0.2 ===================================== diff --git a/py/__init__.py b/py/__init__.py index 92646bcd1..d40593100 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -9,7 +9,7 @@ dictionary or an import path. (c) Holger Krekel and others, 2009 """ -version = "1.1.0" +version = "1.1.1" __version__ = version = version or "1.1.x" import py.apipkg diff --git a/py/impl/compat/dep_doctest.py b/py/impl/compat/dep_doctest.py index e3a247d1e..6da68a500 100644 --- a/py/impl/compat/dep_doctest.py +++ b/py/impl/compat/dep_doctest.py @@ -1,4 +1,5 @@ import py -py.log._apiwarn("1.1", "py.compat.doctest deprecated, use standard library version.", stacklevel="initpkg") +py.log._apiwarn("1.1", "py.compat.doctest deprecated, use standard library version.", +stacklevel="apipkg") doctest = py.std.doctest diff --git a/py/impl/compat/dep_optparse.py b/py/impl/compat/dep_optparse.py index 79c7402a2..253d40fe4 100644 --- a/py/impl/compat/dep_optparse.py +++ b/py/impl/compat/dep_optparse.py @@ -1,4 +1,4 @@ import py -py.log._apiwarn("1.1", "py.compat.optparse deprecated, use standard library version.", stacklevel="initpkg") +py.log._apiwarn("1.1", "py.compat.optparse deprecated, use standard library version.", stacklevel="apipkg") optparse = py.std.optparse diff --git a/py/impl/compat/dep_subprocess.py b/py/impl/compat/dep_subprocess.py index 2289c111c..dac3d6916 100644 --- a/py/impl/compat/dep_subprocess.py +++ b/py/impl/compat/dep_subprocess.py @@ -1,4 +1,5 @@ import py -py.log._apiwarn("1.1", "py.compat.subprocess deprecated, use standard library version.", stacklevel="initpkg") +py.log._apiwarn("1.1", "py.compat.subprocess deprecated, use standard library version.", +stacklevel="apipkg") subprocess = py.std.subprocess diff --git a/py/impl/compat/dep_textwrap.py b/py/impl/compat/dep_textwrap.py index bed9d6f32..3f378298e 100644 --- a/py/impl/compat/dep_textwrap.py +++ b/py/impl/compat/dep_textwrap.py @@ -1,4 +1,5 @@ import py -py.log._apiwarn("1.1", "py.compat.textwrap deprecated, use standard library version.", stacklevel="initpkg") +py.log._apiwarn("1.1", "py.compat.textwrap deprecated, use standard library version.", + stacklevel="apipkg") textwrap = py.std.textwrap diff --git a/py/impl/log/warning.py b/py/impl/log/warning.py index 3a9a578bf..392a83aa6 100644 --- a/py/impl/log/warning.py +++ b/py/impl/log/warning.py @@ -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: diff --git a/setup.py b/setup.py index 7cb24260a..f3579ebb9 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def main(): name='py', description='py.test and pylib: rapid testing and development utils.', long_description = long_description, - version= trunk or '1.1.0', + version= trunk or '1.1.1', url='http://pylib.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/log/test_warning.py b/testing/log/test_warning.py index ef9c5770f..c16432d66 100644 --- a/testing/log/test_warning.py +++ b/testing/log/test_warning.py @@ -28,23 +28,30 @@ def test_stacklevel(): assert warning.find(":%s" % lno) != -1 def test_stacklevel_initpkg_with_resolve(testdir): - mod = testdir.makepyfile(initpkg=""" + testdir.makepyfile(modabc=""" import py - def __getattr__(): - f() def f(): - py.log._apiwarn("x", "some", stacklevel="initpkg") - """).pyimport() + py.log._apiwarn("x", "some", stacklevel="apipkg123") + """) + testdir.makepyfile(apipkg123=""" + def __getattr__(): + import modabc + modabc.f() + """) + p = testdir.makepyfile(""" + import apipkg123 + apipkg123.__getattr__() + """) capture = py.io.StdCapture() - mod.__getattr__() + p.pyimport() out, err = capture.reset() - lno = py.code.getrawcode(test_stacklevel_initpkg_with_resolve).co_firstlineno + 9 warning = str(err) - assert warning.find(":%s" % lno) != -1 + loc = 'test_stacklevel_initpkg_with_resolve.py:2' + assert warning.find(loc) != -1 def test_stacklevel_initpkg_no_resolve(): def f(): - py.log._apiwarn("x", "some", stacklevel="initpkg") + py.log._apiwarn("x", "some", stacklevel="apipkg") capture = py.io.StdCapture() f() out, err = capture.reset() diff --git a/testing/pytest/dist/acceptance_test.py b/testing/pytest/dist/acceptance_test.py index f96d0fa43..e26823ebd 100644 --- a/testing/pytest/dist/acceptance_test.py +++ b/testing/pytest/dist/acceptance_test.py @@ -147,6 +147,6 @@ class TestDistribution: args += ["--tx", "popen//python=%s" % interpreters[0]] args += ["--tx", "popen//python=%s" % interpreters[1]] result = testdir.runpytest(*args) - result.stdout.fnmatch_lines(["2...4"]) - result.stdout.fnmatch_lines(["2...5"]) - + s = result.stdout.str() + assert "2.4" in s + assert "2.5" in s diff --git a/testing/test_compat_deprecation.py b/testing/test_compat_deprecation.py index 62ca26aa4..06e50e31f 100644 --- a/testing/test_compat_deprecation.py +++ b/testing/test_compat_deprecation.py @@ -7,9 +7,10 @@ def test_functional_deprecation(testdir): check(recwarn, name) def check(recwarn, name): x = getattr(py.compat, name) - recwarn.pop(DeprecationWarning) + warn = recwarn.pop(DeprecationWarning) recwarn.clear() assert x == getattr(py.std, name) + assert warn.filename.find("test_functional_deprecation.py") != -1 """) result = testdir.runpytest() assert result.ret == 0