File 5d44af277b005692241a09f30e11bb0d16166823.patch of Package krita
From 5d44af277b005692241a09f30e11bb0d16166823 Mon Sep 17 00:00:00 2001
From: Freya Lupen <penguinflyer2222@gmail.com>
Date: Thu, 25 Jul 2024 08:37:45 -0500
Subject: [PATCH] Fix Python invalid escape sequence warnings
If Python finds a string with an invalid backslash escape such as '\*',
it will throw a Syntax or Deprecation warning. In the future this will
become an error. The fix is to use a raw string r'\*' instead, which
won't attempt to interpolate the escape sequences in the regexes.
BUG:489526
---
.../comics_project_management_tools/comics_exporter.py | 6 +++---
.../exporters/CPMT_ACBF_XML_Exporter.py | 4 ++--
.../exporters/CPMT_po_parser.py | 8 ++++----
.../python/scripter/ui_scripter/editor/pythoneditor.py | 2 +-
plugins/python/scripter/ui_scripter/syntax/syntax.py | 8 ++++----
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/plugins/python/comics_project_management_tools/comics_exporter.py b/plugins/python/comics_project_management_tools/comics_exporter.py
index 73fe21bcbe3..6cb3f2a095f 100644
--- a/plugins/python/comics_project_management_tools/comics_exporter.py
+++ b/plugins/python/comics_project_management_tools/comics_exporter.py
@@ -420,7 +420,7 @@ class comicsExporter():
def handleShapeDescription(self, shape, list, textOnly=False):
return
# Turn off shape retrieval for now until the new text tool is finished.
- """
+ r"""
if (shape.type() != "KoSvgTextShapeID" and textOnly is True):
return
shapeDesc = {}
@@ -429,7 +429,7 @@ class comicsExporter():
listOfPoints = [rect.topLeft(), rect.topRight(), rect.bottomRight(), rect.bottomLeft()]
shapeDoc = minidom.parseString(shape.toSvg())
docElem = shapeDoc.documentElement
- svgRegExp = re.compile('[MLCSQHVATmlzcqshva]\d+\.?\d* \d+\.?\d*')
+ svgRegExp = re.compile(r'[MLCSQHVATmlzcqshva]\d+\.?\d* \d+\.?\d*')
transform = docElem.getAttribute("transform")
coord = []
adjust = QTransform()
@@ -539,7 +539,7 @@ class comicsExporter():
fontsize = int(size)
font = QFont(family, fontsize)
string = el.toxml()
- string = re.sub("\<.*?\>", " ", string)
+ string = re.sub(r"\<.*?\>", " ", string)
string = string.replace(" ", " ")
width = min(QFontMetrics(font).width(string.strip()), rect.width())
height = QFontMetrics(font).height()
diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py
index 985b83b6409..386f39bd384 100644
--- a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py
+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py
@@ -507,8 +507,8 @@ def write_xml(configDictionary = {}, pageData = [], pagesLocationList = [], loc
figureOut = figure_out_type(svg.documentElement())
type = figureOut[0]
inverted = figureOut[1]
- string = re.sub("\<\/*?text.*?\>",'', str(v["text"]))
- string = re.sub("\s+?", " ", string)
+ string = re.sub(r"\<\/*?text.*?\>",'', str(v["text"]))
+ string = re.sub(r"\s+?", " ", string)
translationEntry = poParser.get_entry_for_key(string, lang)
string = translationEntry.get("trans", string)
svg.setContent("<text>"+string+"</text>")
diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py b/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py
index 3d35218d27e..73a1227443a 100644
--- a/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py
+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_po_parser.py
@@ -46,8 +46,8 @@ class po_file_parser():
key = ""
if self.key_xml:
text = entry.get("text", "")
- text = re.sub("\<.*?\>", " ", text)
- key += str(re.sub("\s+", " ", text)).strip()
+ text = re.sub(r"\<.*?\>", " ", text)
+ key += str(re.sub(r"\s+", " ", text)).strip()
else:
key += entry.get("text", None)
if key is not None:
@@ -111,8 +111,8 @@ class po_file_parser():
entry = {}
entry["trans"] = " "
if self.key_xml:
- key = re.sub("\<.*?\>", " ", key)
- key = re.sub("\s+", " ", key)
+ key = re.sub(r"\<.*?\>", " ", key)
+ key = re.sub(r"\s+", " ", key)
key = key.strip()
if key in self.translationDict.keys():
translations = {}
diff --git a/plugins/python/scripter/ui_scripter/editor/pythoneditor.py b/plugins/python/scripter/ui_scripter/editor/pythoneditor.py
index 76572ab1e3c..da3efbc89c1 100644
--- a/plugins/python/scripter/ui_scripter/editor/pythoneditor.py
+++ b/plugins/python/scripter/ui_scripter/editor/pythoneditor.py
@@ -271,7 +271,7 @@ class CodeEditor(QPlainTextEdit):
self.dedentBlock(blockNumber)
def autoindent(self):
- """The return key has just been pressed (and processed by the editor)
+ r"""The return key has just been pressed (and processed by the editor)
now insert leading spaces to reflect an appropriate indent level
against the previous line.
This will depend on the end of the previous line. If it ends:
diff --git a/plugins/python/scripter/ui_scripter/syntax/syntax.py b/plugins/python/scripter/ui_scripter/syntax/syntax.py
index abc7903b3cb..b0d3088e038 100644
--- a/plugins/python/scripter/ui_scripter/syntax/syntax.py
+++ b/plugins/python/scripter/ui_scripter/syntax/syntax.py
@@ -30,16 +30,16 @@ class PythonHighlighter (QSyntaxHighlighter):
# Comparison
'==', '!=', '<', '<=', '>', '>=',
# Arithmetic
- '\+', '-', '\*', '/', '//', '\%', '\*\*',
+ r'\+', '-', r'\*', '/', '//', r'\%', r'\*\*',
# In-place
- '\+=', '-=', '\*=', '/=', '\%=',
+ r'\+=', '-=', r'\*=', '/=', r'\%=',
# Bitwise
- '\^', '\|', '\&', '\~', '>>', '<<',
+ r'\^', r'\|', r'\&', r'\~', '>>', '<<',
]
# Python braces
braces = [
- '\{', '\}', '\(', '\)', '\[', '\]',
+ r'\{', r'\}', r'\(', r'\)', r'\[', r'\]',
]
def __init__(self, document, syntaxStyle):
--
GitLab