[py-svn] commit/py: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Jul 8 12:24:30 CEST 2011
2 new changesets in py:
http://bitbucket.org/hpk42/py/changeset/56eaf981e1bb/
changeset: 56eaf981e1bb
user: hpk42
date: 2011-07-08 12:11:04
summary: fix a reported pytest-issue (running tests on coveragepy caused internal
errors): guard py.code.Code and getfslineno against bogus input and
make py.code.Code work for object instance by looking up their
__call__ function.
affected #: 6 files (775 bytes)
--- a/CHANGELOG Thu Jul 07 20:17:42 2011 +0200
+++ b/CHANGELOG Fri Jul 08 12:11:04 2011 +0200
@@ -2,6 +2,9 @@
==================================================
- a few fixes and assertion related refinements for pytest-2.1
+- guard py.code.Code and getfslineno against bogus input
+ and make py.code.Code objects for object instance
+ by looking up their __call__ function.
Changes between 1.4.2 and 1.4.3
==================================================
--- a/py/__init__.py Thu Jul 07 20:17:42 2011 +0200
+++ b/py/__init__.py Fri Jul 08 12:11:04 2011 +0200
@@ -8,7 +8,7 @@
(c) Holger Krekel and others, 2004-2010
"""
-__version__ = '1.4.4.dev2'
+__version__ = '1.4.4.dev3'
from py import _apipkg
--- a/py/_code/code.py Thu Jul 07 20:17:42 2011 +0200
+++ b/py/_code/code.py Fri Jul 08 12:11:04 2011 +0200
@@ -709,7 +709,7 @@
if compile:
py.builtin.builtins.compile = oldbuiltins['compile'].pop()
-def getrawcode(obj):
+def getrawcode(obj, trycall=True):
""" return code object for given function. """
try:
return obj.__code__
@@ -718,5 +718,10 @@
obj = getattr(obj, 'func_code', obj)
obj = getattr(obj, 'f_code', obj)
obj = getattr(obj, '__code__', obj)
+ if trycall and not hasattr(obj, 'co_firstlineno'):
+ if hasattr(obj, '__call__'):
+ x = getrawcode(obj.__call__, trycall=False)
+ if hasattr(x, 'co_firstlineno'):
+ return x
return obj
--- a/py/_code/source.py Thu Jul 07 20:17:42 2011 +0200
+++ b/py/_code/source.py Fri Jul 08 12:11:04 2011 +0200
@@ -260,9 +260,12 @@
try:
code = py.code.Code(obj)
except TypeError:
- # fallback to
- fn = (py.std.inspect.getsourcefile(obj) or
- py.std.inspect.getfile(obj))
+ try:
+ fn = (py.std.inspect.getsourcefile(obj) or
+ py.std.inspect.getfile(obj))
+ except TypeError:
+ return None, None
+
fspath = fn and py.path.local(fn) or None
if fspath:
try:
--- a/setup.py Thu Jul 07 20:17:42 2011 +0200
+++ b/setup.py Fri Jul 08 12:11:04 2011 +0200
@@ -9,7 +9,7 @@
name='py',
description='library with cross-python path, ini-parsing, io, code, log facilities',
long_description = open('README.txt').read(),
- version='1.4.4.dev2',
+ version='1.4.4.dev3',
url='http://pylib.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
--- a/testing/code/test_source.py Thu Jul 07 20:17:42 2011 +0200
+++ b/testing/code/test_source.py Fri Jul 08 12:11:04 2011 +0200
@@ -430,3 +430,16 @@
assert fspath.basename == "test_source.py"
assert lineno == A_lineno
+ assert getfslineno(3) == (None, None)
+
+
+def test_code_of_object_instance_with_call():
+ class A:
+ pass
+ py.test.raises(TypeError, lambda: py.code.Source(A()))
+ class WithCall:
+ def __call__(self):
+ pass
+
+ code = py.code.Code(WithCall())
+ assert 'pass' in str(code.source())
http://bitbucket.org/hpk42/py/changeset/a1f2c4d23419/
changeset: a1f2c4d23419
user: hpk42
date: 2011-07-08 12:11:47
summary: make formatting exceptioninfo robust against invalid CWD
affected #: 5 files (658 bytes)
--- a/CHANGELOG Fri Jul 08 12:11:04 2011 +0200
+++ b/CHANGELOG Fri Jul 08 12:11:47 2011 +0200
@@ -5,6 +5,7 @@
- guard py.code.Code and getfslineno against bogus input
and make py.code.Code objects for object instance
by looking up their __call__ function.
+- make exception presentation robust against invalid current cwd
Changes between 1.4.2 and 1.4.3
==================================================
--- a/py/__init__.py Fri Jul 08 12:11:04 2011 +0200
+++ b/py/__init__.py Fri Jul 08 12:11:47 2011 +0200
@@ -8,7 +8,7 @@
(c) Holger Krekel and others, 2004-2010
"""
-__version__ = '1.4.4.dev3'
+__version__ = '1.4.4.dev4'
from py import _apipkg
--- a/py/_code/code.py Fri Jul 08 12:11:04 2011 +0200
+++ b/py/_code/code.py Fri Jul 08 12:11:47 2011 +0200
@@ -516,7 +516,10 @@
def _makepath(self, path):
if not self.abspath:
- np = py.path.local().bestrelpath(path)
+ try:
+ np = py.path.local().bestrelpath(path)
+ except OSError:
+ return path
if len(np) < len(str(path)):
path = np
return path
--- a/setup.py Fri Jul 08 12:11:04 2011 +0200
+++ b/setup.py Fri Jul 08 12:11:47 2011 +0200
@@ -9,7 +9,7 @@
name='py',
description='library with cross-python path, ini-parsing, io, code, log facilities',
long_description = open('README.txt').read(),
- version='1.4.4.dev3',
+ version='1.4.4.dev4',
url='http://pylib.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
--- a/testing/code/test_excinfo.py Fri Jul 08 12:11:04 2011 +0200
+++ b/testing/code/test_excinfo.py Fri Jul 08 12:11:47 2011 +0200
@@ -549,6 +549,22 @@
assert repr.reprcrash.path.endswith("mod.py")
assert repr.reprcrash.message == "ValueError: 0"
+ def test_repr_traceback_with_invalid_cwd(self, importasmod, monkeypatch):
+ mod = importasmod("""
+ def f(x):
+ raise ValueError(x)
+ def entry():
+ f(0)
+ """)
+ excinfo = py.test.raises(ValueError, mod.entry)
+
+ p = FormattedExcinfo()
+ def raiseos():
+ raise OSError(2)
+ monkeypatch.setattr(py.std.os, 'getcwd', raiseos)
+ assert p._makepath(__file__) == __file__
+ reprtb = p.repr_traceback(excinfo)
+
def test_repr_excinfo_addouterr(self, importasmod):
mod = importasmod("""
def entry():
Repository URL: https://bitbucket.org/hpk42/py/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list