summaryrefslogtreecommitdiff
path: root/sphinx/pycode/pgen2/literals.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-04 20:02:24 +0100
committerGeorg Brandl <georg@python.org>2009-01-04 20:02:24 +0100
commitcae384f5ff2bd3da925362eca0b89fa2f985029b (patch)
tree045aed7fe2c72e71a3d68225c75318e7691f2233 /sphinx/pycode/pgen2/literals.py
parent2e9866821eecbde6dc49dd42e407ecf8b41ce1f1 (diff)
downloadsphinx-git-cae384f5ff2bd3da925362eca0b89fa2f985029b.tar.gz
Add support for decoding strings and comments to the analyzer.
Diffstat (limited to 'sphinx/pycode/pgen2/literals.py')
-rw-r--r--sphinx/pycode/pgen2/literals.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/sphinx/pycode/pgen2/literals.py b/sphinx/pycode/pgen2/literals.py
index 78667df01..319002910 100644
--- a/sphinx/pycode/pgen2/literals.py
+++ b/sphinx/pycode/pgen2/literals.py
@@ -63,9 +63,11 @@ escape_re = re.compile(r"\\(\'|\"|\\|[abfnrtv]|x.{0,2}|[0-7]{1,3})")
uni_escape_re = re.compile(r"\\(\'|\"|\\|[abfnrtv]|x.{0,2}|[0-7]{1,3}|"
r"u[0-9a-fA-F]{0,4}|U[0-9a-fA-F]{0,8}|N\{.+?\})")
-def evalString(s):
+def evalString(s, encoding=None):
regex = escape_re
repl = escape
+ if encoding:
+ s = s.decode(encoding)
if s.startswith('u') or s.startswith('U'):
regex = uni_escape_re
s = s[1:]