[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Python: don't use assert to check argument in set_data_mode.
From: |
Christopher Brannon |
Subject: |
[PATCH] Python: don't use assert to check argument in set_data_mode. |
Date: |
Sun, 15 Aug 2010 11:30:29 -0500 |
The assert statement is no longer used to check this method's argument,
because optimization disables assertions. Previously, set_data_mode
raised UnboundLocalError when its argument was invalid and assertions
were disabled. ValueError is more meaningful in this context.
set_data_mode now raises ValueError when its argument is not one of the
DataMode constants.
---
src/python/speechd/client.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/python/speechd/client.py b/src/python/speechd/client.py
index 602674c..13a9c7e 100644
--- a/src/python/speechd/client.py
+++ b/src/python/speechd/client.py
@@ -697,11 +697,14 @@ class SSIPClient(object):
value - one of the constants defined by the DataMode class.
"""
- assert value in (DataMode.TEXT, DataMode.SSML)
if value == DataMode.SSML:
ssip_val = 'on'
elif value == DataMode.TEXT:
ssip_val = 'off'
+ else:
+ raise ValueError(
+ 'Value "%s" is not one of the constants from the DataMode
class.' % \
+ value)
self._conn.send_command('SET', Scope.SELF, 'SSML_MODE', ssip_val)
def speak(self, text, callback=None, event_types=None):
--
1.7.2.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Python: don't use assert to check argument in set_data_mode.,
Christopher Brannon <=