Skip to content

Commit

Permalink
Merge pull request #31 from felixonmars/master
Browse files Browse the repository at this point in the history
Add support for Python 3.5
  • Loading branch information
mgedmin committed Nov 9, 2015
2 parents 070c482 + 45b26f3 commit 9b0c659
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python:
- 3.2
- 3.3
- 3.4
- 3.5
- pypy
- pypy3
install:
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ zope.testrunner Changelog
4.4.10 (unreleased)
===================

- Nothing changed yet.
- Added support for Python 3.5.


4.4.9 (2015-05-21)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def run_tests(self):
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
30 changes: 28 additions & 2 deletions src/zope/testrunner/tb_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,35 @@
import zope.testrunner.feature


try:
_iter_chain = traceback._iter_chain
except AttributeError:
# Python 3.5
def _iter_chain(exc, custom_tb=None, seen=None):
if seen is None:
seen = set()
seen.add(exc)
its = []
context = exc.__context__
cause = exc.__cause__
if cause is not None and cause not in seen:
its.append(_iter_chain(cause, False, seen))
its.append([(traceback._cause_message, None)])
elif (context is not None and
not exc.__suppress_context__ and
context not in seen):
its.append(_iter_chain(context, None, seen))
its.append([(traceback._context_message, None)])
its.append([(exc, custom_tb or exc.__traceback__)])
# itertools.chain is in an extension module and may be unavailable
for it in its:
for x in it:
yield x


def format_exception(t, v, tb, limit=None, chain=None):
if chain:
values = traceback._iter_chain(v, tb)
values = _iter_chain(v, tb)
else:
values = [(v, tb)]
fmt = zope.exceptions.exceptionformatter.TextExceptionFormatter(
Expand All @@ -33,7 +59,7 @@ def format_exception(t, v, tb, limit=None, chain=None):

def print_exception(t, v, tb, limit=None, file=None, chain=None):
if chain:
values = traceback._iter_chain(v, tb)
values = _iter_chain(v, tb)
else:
values = [(v, tb)]
if file is None:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py26,py27,pypy,py32,py33,py34,pypy3
py26,py27,pypy,py32,py33,py34,py35,pypy3

[testenv]
deps =
Expand Down

0 comments on commit 9b0c659

Please sign in to comment.