aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-09-13 12:59:43 +0200
committerAndy Shaw <andy.shaw@qt.io>2019-09-17 13:07:23 +0200
commitc3cb549b69d5529a33aaba9de6c34e784cec4df2 (patch)
treefbcf69c398279f28b4da8753410568a27071a69f
parent242d28afcc60728b3ae30bb3ce2a3362b26fb57b (diff)
Use replace() instead of re.escape() to escape the backslash
Versions of Python before 3.7 will escape any character that might be used in a regexp when using re.escape() even if it is not completely part of a regexp expression. For example : will be escaped as \: which is invalid when used inside a string. Therefore we should just ensure that any instances of a \ inside a string is escaped correctly when generating the C++ code by using replace(). Change-Id: I746d99bf6bb7a9b69a1d4747da49ad0fb85f151d Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rwxr-xr-xsrc/tools/ivigenerator/generate.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py
index fe88334..c19de65 100755
--- a/src/tools/ivigenerator/generate.py
+++ b/src/tools/ivigenerator/generate.py
@@ -248,7 +248,7 @@ def default_value_helper(symbol, res):
else:
return 'false'
if t.is_string:
- return 'QLatin1String("{0}")'.format(re.escape(res))
+ return 'QLatin1String("{0}")'.format(res.replace("\\", "\\\\"))
if t.is_var:
if isinstance(res, str):
res = 'QLatin1String("{0}")'.format(res)