]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
doc raise exceptions with a base class
authorAlfredo Deza <adeza@redhat.com>
Fri, 6 Oct 2017 12:03:36 +0000 (08:03 -0400)
committerKefu Chai <kchai@redhat.com>
Tue, 17 Oct 2017 02:47:30 +0000 (10:47 +0800)
Although valid in very old Python, it is no longer possible to raise
"bare" exceptions without a class.

Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 347b7b1f193f97a3577a971e074a23366b0c8617)

doc/scripts/gen_state_diagram.py

index f8414368c1c348b51e9dcde9fe6caea3a7d7fa26..14017fac3f1ef1158ddade2f6117d547d62febb1 100755 (executable)
@@ -105,7 +105,7 @@ class StateMachineRenderer(object):
                 r"boost::statechart::state_machine<\s*(\w*),\s*(\w*)\s*>",
                 line)
             if tokens is None:
-                raise "Error: malformed state_machine line: " + line
+                raise Exception("Error: malformed state_machine line: " + line)
             self.machines[tokens.group(1)] = tokens.group(2)
             self.context.append((tokens.group(1), self.context_depth, ""))
             return
@@ -114,7 +114,7 @@ class StateMachineRenderer(object):
                 r"boost::statechart::state<\s*(\w*),\s*(\w*)\s*,?\s*(\w*)\s*>",
                 line)
             if tokens is None:
-                raise "Error: malformed state line: " + line
+                raise Exception("Error: malformed state line: " + line)
             self.states[tokens.group(1)] = tokens.group(2)
             if tokens.group(2) not in self.state_contents.keys():
                 self.state_contents[tokens.group(2)] = []
@@ -131,14 +131,14 @@ class StateMachineRenderer(object):
                 if i.group(1) not in self.edges.keys():
                     self.edges[i.group(1)] = []
                 if len(self.context) is 0:
-                    raise "no context at line: " + line
+                    raise Exception("no context at line: " + line)
                 self.edges[i.group(1)].append((self.context[-1][0], i.group(2)))
         i = re.search("return\s+transit<\s*(\w*)\s*>()", line)
         if i is not None:
             if len(self.context) is 0:
-                raise "no context at line: " + line
+                raise Exception("no context at line: " + line)
             if self.context[-1][2] is "":
-                raise "no event in context at line: " + line
+                raise Exception("no event in context at line: " + line)
             if self.context[-1][2] not in self.edges.keys():
                 self.edges[self.context[-1][2]] = []
             self.edges[self.context[-1][2]].append((self.context[-1][0], i.group(1)))