[py3k] Fix raise with embedded traceback

python 3 removed the raise syntax with 3 expressions.

authorRémi Cardona <remi.cardona@free.fr>
changesetf62e21c83b08
branchdefault
phasepublic
hiddenno
parent revision#ee0548a2abbe [compat] Remove callable (related to #264017)
child revision#edca0769f4b5 [py3k] print function
files modified by this revision
registry.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@free.fr>
# Date 1405377395 -7200
# Tue Jul 15 00:36:35 2014 +0200
# Node ID f62e21c83b08cf6b164adbf59e0add1a9cd9e5c8
# Parent ee0548a2abbe96b99a4da1e57bf8489cfa8afc75
[py3k] Fix raise with embedded traceback

python 3 removed the raise syntax with 3 expressions.

diff --git a/registry.py b/registry.py
@@ -246,11 +246,13 @@
1          this name
2          """
3          try:
4              return super(Registry, self).__getitem__(name)
5          except KeyError:
6 -            raise ObjectNotFound(name), None, sys.exc_info()[-1]
7 +            exc = ObjectNotFound(name)
8 +            exc.__traceback__ = sys.exc_info()[-1]
9 +            raise exc
10 
11      @classmethod
12      def objid(cls, obj):
13          """returns a unique identifier for an object stored in the registry"""
14          return '%s.%s' % (obj.__module__, cls.objname(obj))
@@ -553,11 +555,13 @@
15          this name
16          """
17          try:
18              return super(RegistryStore, self).__getitem__(name)
19          except KeyError:
20 -            raise RegistryNotFound(name), None, sys.exc_info()[-1]
21 +            exc = RegistryNotFound(name)
22 +            exc.__traceback__ = sys.exc_info()[-1]
23 +            raise exc
24 
25      # methods for explicit (un)registration ###################################
26 
27      # default class, when no specific class set
28      REGISTRY_FACTORY = {None: Registry}