diff --git a/Pythonwin/pywin/framework/editor/editor.py b/Pythonwin/pywin/framework/editor/editor.py index aa1f53857..2a61ea6c5 100644 --- a/Pythonwin/pywin/framework/editor/editor.py +++ b/Pythonwin/pywin/framework/editor/editor.py @@ -32,8 +32,8 @@ ) from pywin.mfc import afxres, dialog, docview -patImport = regex.symcomp("import \(.*\)") -patIndent = regex.compile("^\\([ \t]*[~ \t]\\)") +patImport = regex.symcomp(r"import \(.*\)") +patIndent = regex.compile(r"^\([ \t]*[~ \t]\)") ID_LOCATE_FILE = 0xE200 ID_GOTO_LINE = 0xE2001 @@ -131,7 +131,7 @@ def TranslateLoadedData(self, data): win32ui.SetStatusText( "Translating from Unix file format - please wait...", 1 ) - return re.sub("\r*\n", "\r\n", data) + return re.sub(r"\r*\n", "\r\n", data) else: return data diff --git a/Pythonwin/pywin/framework/mdi_pychecker.py b/Pythonwin/pywin/framework/mdi_pychecker.py index 6ae57606a..db1662b46 100644 --- a/Pythonwin/pywin/framework/mdi_pychecker.py +++ b/Pythonwin/pywin/framework/mdi_pychecker.py @@ -146,7 +146,7 @@ def __radd__(self, other): # Group(1) is the filename, group(2) is the lineno. -# regexGrepResult=regex.compile("^\\([a-zA-Z]:.*\\)(\\([0-9]+\\))") +# regexGrepResult=regex.compile(r"^\([a-zA-Z]:.*\)(\([0-9]+\))") # regexGrep=re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)") regexGrep = re.compile(r"^(..[^\(:]+)?[\(:](\d+)[\):]:?\s*(.*)") @@ -544,7 +544,7 @@ def OnAddComment(self, cmd, code): errtext = m.group(3) if start != end and line_start == line_end: errtext = self.GetSelText() - errtext = repr(re.escape(errtext).replace("\ ", " ")) + errtext = repr(re.escape(errtext).replace(r"\ ", " ")) view.ReplaceSel(addspecific and cmnt % locals() or cmnt) return 0 diff --git a/Pythonwin/pywin/framework/sgrepmdi.py b/Pythonwin/pywin/framework/sgrepmdi.py index d1007a197..16bff7fa8 100644 --- a/Pythonwin/pywin/framework/sgrepmdi.py +++ b/Pythonwin/pywin/framework/sgrepmdi.py @@ -129,7 +129,7 @@ def __radd__(self, other): # Group(1) is the filename, group(2) is the lineno. -# regexGrepResult=regex.compile("^\\([a-zA-Z]:.*\\)(\\([0-9]+\\))") +# regexGrepResult=regex.compile(r"^\([a-zA-Z]:.*\)(\([0-9]+\))") regexGrep = re.compile(r"^([a-zA-Z]:[^(]*)\(([0-9]+)\)") diff --git a/Pythonwin/pywin/framework/toolmenu.py b/Pythonwin/pywin/framework/toolmenu.py index 3f739e09e..17fb908e1 100644 --- a/Pythonwin/pywin/framework/toolmenu.py +++ b/Pythonwin/pywin/framework/toolmenu.py @@ -116,7 +116,7 @@ def HandleToolCommand(cmd, code): global tools (menuString, pyCmd, desc) = tools[cmd] win32ui.SetStatusText("Executing tool %s" % desc, 1) - pyCmd = re.sub("\\\\n", "\n", pyCmd) + pyCmd = re.sub(r"\\n", "\n", pyCmd) win32ui.DoWaitCursor(1) oldFlag = None try: diff --git a/Pythonwin/pywin/framework/winout.py b/Pythonwin/pywin/framework/winout.py index a55a13e37..645dbca81 100644 --- a/Pythonwin/pywin/framework/winout.py +++ b/Pythonwin/pywin/framework/winout.py @@ -101,7 +101,7 @@ def OnDestroy(self, message): class WindowOutputViewImpl: def __init__(self): - self.patErrorMessage = re.compile('\W*File "(.*)", line ([0-9]+)') + self.patErrorMessage = re.compile(r'\W*File "(.*)", line ([0-9]+)') self.template = self.GetDocument().GetDocTemplate() def HookHandlers(self): diff --git a/Pythonwin/pywin/idle/FormatParagraph.py b/Pythonwin/pywin/idle/FormatParagraph.py index 143c18ee3..b3e74c532 100644 --- a/Pythonwin/pywin/idle/FormatParagraph.py +++ b/Pythonwin/pywin/idle/FormatParagraph.py @@ -133,7 +133,7 @@ def reformat_paragraph(data, limit=70): partial = indent1 while i < n and not is_all_white(lines[i]): # XXX Should take double space after period (etc.) into account - words = re.split("(\s+)", lines[i]) + words = re.split(r"(\s+)", lines[i]) for j in range(0, len(words), 2): word = words[j] if not word: diff --git a/Pythonwin/pywin/scintilla/document.py b/Pythonwin/pywin/scintilla/document.py index 476eb8bcc..7fb5e264a 100644 --- a/Pythonwin/pywin/scintilla/document.py +++ b/Pythonwin/pywin/scintilla/document.py @@ -13,8 +13,8 @@ lf_bytes = b"\n" # re from pep263 - but we use it both on bytes and strings. -re_encoding_bytes = re.compile(b"coding[:=]\s*([-\w.]+)") -re_encoding_text = re.compile("coding[:=]\s*([-\w.]+)") +re_encoding_bytes = re.compile(rb"coding[:=]\s*([-\w.]+)") +re_encoding_text = re.compile(r"coding[:=]\s*([-\w.]+)") ParentScintillaDocument = docview.Document @@ -168,7 +168,7 @@ def _SaveTextToFile(self, view, filename, encoding=None): source_encoding = self.source_encoding else: # no BOM - look for an encoding. - bits = re.split("[\r\n]+", s, 3) + bits = re.split(r"[\r\n]+", s, 3) for look in bits[:-1]: match = re_encoding_text.search(look) if match is not None: diff --git a/Pythonwin/pywin/scintilla/view.py b/Pythonwin/pywin/scintilla/view.py index 3783666fc..910161bad 100644 --- a/Pythonwin/pywin/scintilla/view.py +++ b/Pythonwin/pywin/scintilla/view.py @@ -22,7 +22,7 @@ wordbreaks = "._" + string.ascii_uppercase + string.ascii_lowercase + string.digits -patImport = re.compile("import (?P.*)") +patImport = re.compile(r"import (?P.*)") _event_commands = [ # File menu @@ -533,7 +533,7 @@ def list2dict(l): endpos = self.LineIndex(maxline) text = self.GetTextRange(self.LineIndex(minline), endpos) try: - l = re.findall(r"\b" + left + "\.\w+", text) + l = re.findall(r"\b" + left + r"\.\w+", text) except re.error: # parens etc may make an invalid RE, but this code wouldnt # benefit even if the RE did work :-) diff --git a/Pythonwin/pywin/tools/browser.py b/Pythonwin/pywin/tools/browser.py index 9d9a193db..749018566 100644 --- a/Pythonwin/pywin/tools/browser.py +++ b/Pythonwin/pywin/tools/browser.py @@ -369,7 +369,7 @@ def OnInitDialog(self): t, v, tb = sys.exc_info() strval = "Exception getting object value\n\n%s:%s" % (t, v) tb = None - strval = re.sub("\n", "\r\n", strval) + strval = re.sub(r"\n", "\r\n", strval) self.edit.ReplaceSel(strval) diff --git a/com/win32com/makegw/makegw.py b/com/win32com/makegw/makegw.py index 8d2e83d65..6074900d5 100644 --- a/com/win32com/makegw/makegw.py +++ b/com/win32com/makegw/makegw.py @@ -197,7 +197,7 @@ def _write_ifc_cpp(f, interface): % (interface.__dict__) ) - ptr = re.sub("[a-z]", "", interface.name) + ptr = re.sub(r"[a-z]", "", interface.name) strdict = {"interfacename": interface.name, "ptr": ptr} for method in interface.methods: strdict["method"] = method.name diff --git a/com/win32com/makegw/makegwparse.py b/com/win32com/makegw/makegwparse.py index 59512f487..ffe69cb4c 100644 --- a/com/win32com/makegw/makegwparse.py +++ b/com/win32com/makegw/makegwparse.py @@ -928,7 +928,7 @@ class Interface: # name base # -------- -------- - regex = re.compile("(interface|) ([^ ]*) : public (.*)$") + regex = re.compile(r"(interface|) ([^ ]*) : public (.*)$") def __init__(self, mo): self.methods = [] diff --git a/com/win32com/storagecon.py b/com/win32com/storagecon.py index 3ed529023..10ee65de4 100644 --- a/com/win32com/storagecon.py +++ b/com/win32com/storagecon.py @@ -1,6 +1,6 @@ """Constants related to IStorage and related interfaces -This file was generated by h2py from d:\msdev\include\objbase.h +This file was generated by h2py from d:\\msdev\\include\\objbase.h then hand edited, a few extra constants added, etc. """ diff --git a/com/win32com/test/testall.py b/com/win32com/test/testall.py index 6da07407a..6ca312e34 100644 --- a/com/win32com/test/testall.py +++ b/com/win32com/test/testall.py @@ -63,7 +63,7 @@ def CleanGenerated(): def RemoveRefCountOutput(data): while 1: last_line_pos = data.rfind("\n") - if not re.match("\[\d+ refs\]", data[last_line_pos + 1 :]): + if not re.match(r"\[\d+ refs\]", data[last_line_pos + 1 :]): break if last_line_pos < 0: # All the output diff --git a/com/win32com/test/testvbscript_regexp.py b/com/win32com/test/testvbscript_regexp.py index a22f0bea5..a6c09ae8a 100644 --- a/com/win32com/test/testvbscript_regexp.py +++ b/com/win32com/test/testvbscript_regexp.py @@ -13,8 +13,8 @@ def _CheckMatches(self, match, expected): self.assertEqual(list(found), list(expected)) def _TestVBScriptRegex(self, re): - StringToSearch = "Python python pYthon Python" - re.Pattern = "Python" + StringToSearch = r"Python python pYthon Python" + re.Pattern = r"Python" re.Global = True re.IgnoreCase = True diff --git a/com/win32comext/axscript/client/error.py b/com/win32comext/axscript/client/error.py index 8ab7ec787..285978f76 100644 --- a/com/win32comext/axscript/client/error.py +++ b/com/win32comext/axscript/client/error.py @@ -25,11 +25,11 @@ def FormatForAX(text): def ExpandTabs(text): - return re.sub("\t", " ", text) + return re.sub(r"\t", " ", text) def AddCR(text): - return re.sub("\n", "\r\n", text) + return re.sub(r"\n", "\r\n", text) class IActiveScriptError: diff --git a/com/win32comext/axscript/client/framework.py b/com/win32comext/axscript/client/framework.py index 2274f4e08..7203e4ef3 100644 --- a/com/win32comext/axscript/client/framework.py +++ b/com/win32comext/axscript/client/framework.py @@ -21,7 +21,7 @@ def RemoveCR(text): # No longer just "RemoveCR" - should be renamed to # FixNewlines, or something. Idea is to fix arbitary newlines into # something Python can compile... - return re.sub("(\r\n)|\r|(\n\r)", "\n", text) + return re.sub(r"(\r\n)|\r|(\n\r)", "\n", text) SCRIPTTEXT_FORCEEXECUTION = -2147483648 # 0x80000000 diff --git a/com/win32comext/axscript/client/pyscript.py b/com/win32comext/axscript/client/pyscript.py index 5cbcffe3a..4da7db0b5 100644 --- a/com/win32comext/axscript/client/pyscript.py +++ b/com/win32comext/axscript/client/pyscript.py @@ -37,11 +37,11 @@ def debug_attr_print(*args): def ExpandTabs(text): - return re.sub("\t", " ", text) + return re.sub(r"\t", " ", text) def AddCR(text): - return re.sub("\n", "\r\n", text) + return re.sub(r"\n", "\r\n", text) class AXScriptCodeBlock(framework.AXScriptCodeBlock): diff --git a/setup.py b/setup.py index f249b2d74..82fd384a6 100644 --- a/setup.py +++ b/setup.py @@ -2144,7 +2144,7 @@ def convert_data_files(files): flist.findall(os.path.dirname(file)) flist.include_pattern(os.path.basename(file), anchor=0) # We never want CVS - flist.exclude_pattern(re.compile(".*\\\\CVS\\\\"), is_regex=1, anchor=0) + flist.exclude_pattern(re.compile(r".*\\CVS\\"), is_regex=1, anchor=0) flist.exclude_pattern("*.pyc", anchor=0) flist.exclude_pattern("*.pyo", anchor=0) if not flist.files: diff --git a/win32/Demos/security/sspi/socket_server.py b/win32/Demos/security/sspi/socket_server.py index 4d606bb86..d1ac70b22 100644 --- a/win32/Demos/security/sspi/socket_server.py +++ b/win32/Demos/security/sspi/socket_server.py @@ -9,7 +9,7 @@ Running either the client or server as a different user can be informative. A command-line such as the following may be useful: -`runas /user:{user} {fqp}\python.exe {fqp}\socket_server.py --wait client|server` +`runas /user:{user} {fqp}\\python.exe {fqp}\\socket_server.py --wait client|server` {fqp} should specify the relevant fully-qualified path names. diff --git a/win32/test/test_sspi.py b/win32/test/test_sspi.py index 69404fe6f..63003b0bc 100644 --- a/win32/test/test_sspi.py +++ b/win32/test/test_sspi.py @@ -197,32 +197,32 @@ def testSequenceEncrypt(self): def testSecBufferRepr(self): desc = win32security.PySecBufferDescType() assert re.match( - "PySecBufferDesc\(ulVersion: 0 \| cBuffers: 0 \| pBuffers: 0x[\da-fA-F]{8,16}\)", + r"PySecBufferDesc\(ulVersion: 0 \| cBuffers: 0 \| pBuffers: 0x[\da-fA-F]{8,16}\)", repr(desc), ) buffer1 = win32security.PySecBufferType(0, sspicon.SECBUFFER_TOKEN) assert re.match( - "PySecBuffer\(cbBuffer: 0 \| BufferType: 2 \| pvBuffer: 0x[\da-fA-F]{8,16}\)", + r"PySecBuffer\(cbBuffer: 0 \| BufferType: 2 \| pvBuffer: 0x[\da-fA-F]{8,16}\)", repr(buffer1), ) "PySecBuffer(cbBuffer: 0 | BufferType: 2 | pvBuffer: 0x000001B8CC6D8020)" desc.append(buffer1) assert re.match( - "PySecBufferDesc\(ulVersion: 0 \| cBuffers: 1 \| pBuffers: 0x[\da-fA-F]{8,16}\)", + r"PySecBufferDesc\(ulVersion: 0 \| cBuffers: 1 \| pBuffers: 0x[\da-fA-F]{8,16}\)", repr(desc), ) buffer2 = win32security.PySecBufferType(4, sspicon.SECBUFFER_DATA) assert re.match( - "PySecBuffer\(cbBuffer: 4 \| BufferType: 1 \| pvBuffer: 0x[\da-fA-F]{8,16}\)", + r"PySecBuffer\(cbBuffer: 4 \| BufferType: 1 \| pvBuffer: 0x[\da-fA-F]{8,16}\)", repr(buffer2), ) desc.append(buffer2) assert re.match( - "PySecBufferDesc\(ulVersion: 0 \| cBuffers: 2 \| pBuffers: 0x[\da-fA-F]{8,16}\)", + r"PySecBufferDesc\(ulVersion: 0 \| cBuffers: 2 \| pBuffers: 0x[\da-fA-F]{8,16}\)", repr(desc), ) diff --git a/win32/test/testall.py b/win32/test/testall.py index d3df26301..85adf736e 100644 --- a/win32/test/testall.py +++ b/win32/test/testall.py @@ -32,7 +32,7 @@ no_user_interaction = True # re to pull apart an exception line into the exception type and the args. -re_exception = re.compile("([a-zA-Z0-9_.]*): (.*)$") +re_exception = re.compile(r"([a-zA-Z0-9_.]*): (.*)$") def find_exception_in_output(data):