THRIFT-5051: Fix Python tutorials to address THRIFT-4002
Client: Python
Patch: Kengo Seki
This closes #1968
diff --git a/tutorial/py.tornado/PythonServer.py b/tutorial/py.tornado/PythonServer.py
index e0229a2..b472195 100755
--- a/tutorial/py.tornado/PythonServer.py
+++ b/tutorial/py.tornado/PythonServer.py
@@ -58,16 +58,10 @@
val = work.num1 * work.num2
elif work.op == Operation.DIVIDE:
if work.num2 == 0:
- x = InvalidOperation()
- x.whatOp = work.op
- x.why = "Cannot divide by 0"
- raise x
+ raise InvalidOperation(work.op, "Cannot divide by 0")
val = work.num1 / work.num2
else:
- x = InvalidOperation()
- x.whatOp = work.op
- x.why = "Invalid operation"
- raise x
+ raise InvalidOperation(work.op, "Invalid operation")
log = SharedStruct()
log.key = logid
diff --git a/tutorial/py.twisted/PythonServer.py b/tutorial/py.twisted/PythonServer.py
index 034e4a3..c3e64db 100755
--- a/tutorial/py.twisted/PythonServer.py
+++ b/tutorial/py.twisted/PythonServer.py
@@ -60,16 +60,10 @@
val = work.num1 * work.num2
elif work.op == Operation.DIVIDE:
if work.num2 == 0:
- x = InvalidOperation()
- x.whatOp = work.op
- x.why = 'Cannot divide by 0'
- raise x
+ raise InvalidOperation(work.op, 'Cannot divide by 0')
val = work.num1 / work.num2
else:
- x = InvalidOperation()
- x.whatOp = work.op
- x.why = 'Invalid operation'
- raise x
+ raise InvalidOperation(work.op, 'Invalid operation')
log = SharedStruct()
log.key = logid
diff --git a/tutorial/py/PythonServer.py b/tutorial/py/PythonServer.py
index e6421ef..d2343ed 100755
--- a/tutorial/py/PythonServer.py
+++ b/tutorial/py/PythonServer.py
@@ -57,16 +57,10 @@
val = work.num1 * work.num2
elif work.op == Operation.DIVIDE:
if work.num2 == 0:
- x = InvalidOperation()
- x.whatOp = work.op
- x.why = 'Cannot divide by 0'
- raise x
+ raise InvalidOperation(work.op, 'Cannot divide by 0')
val = work.num1 / work.num2
else:
- x = InvalidOperation()
- x.whatOp = work.op
- x.why = 'Invalid operation'
- raise x
+ raise InvalidOperation(work.op, 'Invalid operation')
log = SharedStruct()
log.key = logid