Fix Python 3.6 DeprecationWarning invalid escape sequence messages

Fix by ensuring that regular expressions are constructed using either
raw string literals [1] or double backslashes [2].

[1] https://stackoverflow.com/questions/44325948/pandas-invalid-escape-sequence-after-update
[2] https://github.com/joblib/joblib/pull/526

Note that python only shows the deprecation warnings on initial run [3].

[3] https://bugs.python.org/issue30091

To work around this issue, remove the cached bytecode with:

    find . -name "__pycache__" -exec rm -rf {} \;

Then to prevent compiling to bytecode add the "-B" option to python:

    python3 -B -m pytest -vs
This commit is contained in:
Curtis Gedak 2018-11-10 11:17:48 -07:00
parent af53102e77
commit 7f592bae41
4 changed files with 19 additions and 19 deletions

View file

@ -137,7 +137,7 @@ def createThemePreview(theme, screenRect, size=QSize(200, 120)):
def findThemePath(themeName):
p = findFirstFile(re.escape("{}.theme".format(themeName)), "resources/themes")
if not p:
return findFirstFile(".*\.theme", "resources/themes")
return findFirstFile(r".*\.theme", "resources/themes")
else:
return p

View file

@ -11,19 +11,19 @@ from manuskript.ui.highlighters import BasicHighlighter
class MMDHighlighter(BasicHighlighter):
MARKDOWN_REGEX = {
'Bold': '(\*\*)(.+?)(\*\*)',
'Bold': r'(\*\*)(.+?)(\*\*)',
'Bold2': '(__)(.+?)(__)',
'Italic': '(\*)([^\*].+?[^\*])(\*)',
'Italic': r'(\*)([^\*].+?[^\*])(\*)',
'Italic2': '(_)([^_].+?[^_])(_)',
'Title': '^(#+)(\s*)(.*)(#*)',
'Title': r'^(#+)(\s*)(.*)(#*)',
'HTML': '<.+?>',
'Blockquotes': '^(> )+.*$',
'OrderedList': '^\d+\.\s+',
'UnorderedList': '^[\*\+-]\s+',
'Code': '^\s{4,}.*$',
'Links-inline': '(\[)(.*?)(\])(\()(.*?)(\))',
'Links-ref': '(\[)(.*?)(\])\s?(\[)(.*?)(\])',
'Links-ref2': '^\s{,3}(\[)(.*?)(\]:)\s+([^\s]*)\s*(.*?)*$',
'OrderedList': r'^\d+\.\s+',
'UnorderedList': r'^[\*\+-]\s+',
'Code': r'^\s{4,}.*$',
'Links-inline': r'(\[)(.*?)(\])(\()(.*?)(\))',
'Links-ref': r'(\[)(.*?)(\])\s?(\[)(.*?)(\])',
'Links-ref2': r'^\s{,3}(\[)(.*?)(\]:)\s+([^\s]*)\s*(.*?)*$',
}
def __init__(self, editor, style="Default"):

View file

@ -91,7 +91,7 @@ class MarkdownTokenizer(HighlightTokenizer):
strongRegex.setMinimal(True)
strikethroughRegex = QRegExp("~~[^\\s]+.*[^\\s]+~~")
strikethroughRegex.setMinimal(True)
superScriptRegex = QRegExp("\^([^\\s]|(\\\\\\s))+\^") # Spaces must be escaped "\ "
superScriptRegex = QRegExp(r"\^([^\s]|(\\\\\s))+\^") # Spaces must be escaped "\ "
superScriptRegex.setMinimal(True)
subScriptRegex = QRegExp("~([^\\s]|(\\\\\\s))+~") # Spaces must be escaped "\ "
subScriptRegex.setMinimal(True)
@ -887,7 +887,7 @@ class MarkdownTokenizer(HighlightTokenizer):
with the escaped characters replaced with a dummy character.
"""
return re.sub("\\\\.", "\$", text)
return re.sub("\\\\.", r"\$", text)
#escape = False
#escapedText = text

View file

@ -18,7 +18,7 @@ from manuskript import functions as F
class MDEditView(textEditView):
blockquoteRegex = QRegExp("^ {0,3}(>\\s*)+")
listRegex = QRegExp("^(\\s*)([+*-]|([0-9a-z])+([.\)]))(\\s+)")
listRegex = QRegExp(r"^(\s*)([+*-]|([0-9a-z])+([.\)]))(\s+)")
inlineLinkRegex = QRegExp("\\[([^\n]+)\\]\\(([^\n]+)\\)")
imageRegex = QRegExp("!\\[([^\n]*)\\]\\(([^\n]+)\\)")
automaticLinkRegex = QRegExp("(<([a-zA-Z]+\\:[^\n]+)>)|(<([^\n]+@[^\n]+)>)")
@ -342,15 +342,15 @@ class MDEditView(textEditView):
def clearedFormat(self, text):
# FIXME: clear also block formats
for reg, rep, flags in [
("\*\*(.*?)\*\*", "\\1", None), # bold
(r"\*\*(.*?)\*\*", "\\1", None), # bold
("__(.*?)__", "\\1", None), # bold
("\*(.*?)\*", "\\1", None), # emphasis
(r"\*(.*?)\*", "\\1", None), # emphasis
("_(.*?)_", "\\1", None), # emphasis
("`(.*?)`", "\\1", None), # verbatim
("~~(.*?)~~", "\\1", None), # strike
("\^(.*?)\^", "\\1", None), # superscript
(r"\^(.*?)\^", "\\1", None), # superscript
("~(.*?)~", "\\1", None), # subscript
("<!--\s*(.*?)\s*-->", "\\1", re.S), # comments
(r"<!--\s*(.*?)\s*-->", "\\1", re.S), # comments
# LINES OR BLOCKS
(r"^#*\s*(.+?)\s*", "\\1", re.M), # ATX
@ -394,7 +394,7 @@ class MDEditView(textEditView):
c.insertText("")
char = "=" if level == 1 else "-"
text = re.sub("^#*\s*(.*)\s*#*", "\\1", text) # Removes #
text = re.sub(r"^#*\s*(.*)\s*#*", "\\1", text) # Removes #
sub = char * len(text)
text = text + "\n" + sub
@ -429,7 +429,7 @@ class MDEditView(textEditView):
self.titleATX(level)
return
m = re.match("^(#+)(\s*)(.+)", text)
m = re.match(r"^(#+)(\s*)(.+)", text)
if m:
pre = m.group(1)
space = m.group(2)