Skip to content

Commit

Permalink
SpeechSymbols.load: Don't barf when reading an identifier that just c…
Browse files Browse the repository at this point in the history
…ontains "\".

SpeechSymbols.save: Escape "\". This isn't strictly necessary, but it's more consistent.
  • Loading branch information
jcsteh committed May 28, 2011
1 parent a48d64f commit 522d6f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/characterProcessing.py
Expand Up @@ -223,6 +223,7 @@ def _loadSymbolField(self, input, inputMap=None):
"f": "\f",
"v": "\v",
"#": "#",
"\\": "\\",
}
IDENTIFIER_ESCAPES_OUTPUT = {v: k for k, v in IDENTIFIER_ESCAPES_INPUT.iteritems()}
LEVEL_INPUT = {
Expand Down Expand Up @@ -254,7 +255,7 @@ def _loadSymbol(self, line):
if not identifier:
# Empty identifier is not allowed.
raise ValueError
if identifier.startswith("\\"):
if identifier.startswith("\\") and len(identifier) >= 2:
identifier = self.IDENTIFIER_ESCAPES_INPUT.get(identifier[1], identifier[1]) + identifier[2:]
replacement = self._loadSymbolField(next(line))
except StopIteration:
Expand Down

0 comments on commit 522d6f0

Please sign in to comment.