Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Pythonwin/pywin/framework/editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
)
from pywin.mfc import afxres, dialog, docview

patImport = regex.symcomp("import \(<name>.*\)")
patIndent = regex.compile("^\\([ \t]*[~ \t]\\)")
patImport = regex.symcomp(r"import \(<name>.*\)")
patIndent = regex.compile(r"^\([ \t]*[~ \t]\)")

ID_LOCATE_FILE = 0xE200
ID_GOTO_LINE = 0xE2001
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*(.*)")

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/sgrepmdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)\)")

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/toolmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/winout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/idle/FormatParagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions Pythonwin/pywin/scintilla/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/scintilla/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

wordbreaks = "._" + string.ascii_uppercase + string.ascii_lowercase + string.digits

patImport = re.compile("import (?P<name>.*)")
patImport = re.compile(r"import (?P<name>.*)")

_event_commands = [
# File menu
Expand Down Expand Up @@ -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 :-)
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/tools/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion com/win32com/makegw/makegw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/makegw/makegwparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/storagecon.py
Original file line number Diff line number Diff line change
@@ -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.
"""

Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/test/testvbscript_regexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions com/win32comext/axscript/client/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/axscript/client/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions com/win32comext/axscript/client/pyscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion win32/Demos/security/sspi/socket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 5 additions & 5 deletions win32/test/test_sspi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down
2 changes: 1 addition & 1 deletion win32/test/testall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down