Skip to content
4 changes: 2 additions & 2 deletions Pythonwin/pywin/framework/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def ColorizeInteractiveCode(self, cdoc, styleStart, stylePyStart):
ch = chNext
chNext = cdoc[i + 1 : i + 2].decode("latin-1")

# trace("ch=%r, i=%d, next=%r, state=%s" % (ch, i, chNext, state))
# trace(f"ch={ch!r}, i={i}, next={chNext!r}, state={state}")
if state == STYLE_INTERACTIVE_EOL:
if ch not in "\r\n":
self.ColorSeg(startSeg, i - 1, state)
Expand Down Expand Up @@ -357,7 +357,7 @@ def Init(self):
)
except:
sys.stderr.write(
">>> \nError executing PYTHONSTARTUP script %r\n" % (rcfile)
f">>> \nError executing PYTHONSTARTUP script {rcfile!r}\n"
)
traceback.print_exc(file=sys.stderr)
self.AppendToPrompt([])
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/genpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def WriteVTableMap(self, generator):
if item_num % 5 == 0:
print("\n\t\t\t", end=" ", file=stream)
print(
"), %d, (%r, %r, [" % (dispid, desc.memid, desc.scodeArray),
f"), {dispid}, ({desc.memid!r}, {desc.scodeArray!r}, [",
end=" ",
file=stream,
)
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/demos/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def CheckEvent(server, client, val, verbose):
if client.last_event_arg != val:
raise RuntimeError(f"Sent {val!r}, but got back {client.last_event_arg!r}")
if verbose:
print("Sent and received %r" % val)
print(f"Sent and received {val!r}")


# A simple test script for all this.
Expand Down
7 changes: 2 additions & 5 deletions com/win32com/test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ def RegisterPythonServer(filename, progids=None, verbose=0):
return

if not IsUserAnAdmin():
msg = (
"%r isn't registered, but I'm not an administrator who can register it."
% progids[0]
)
msg = f"{progids[0]!r} isn't registered, but I'm not an administrator who can register it."
if why_not:
msg += "\n(registration check failed as %s)" % why_not
# throw a normal "class not registered" exception - we don't report
Expand Down Expand Up @@ -110,7 +107,7 @@ class Failed(Exception):
raise Failed("traceback in program output")
return output
except Failed as why:
print("Failed to exec command '%r'" % cmd)
print(f"Failed to exec command '{cmd}'")
print("Failed as", why)
print("** start of program output **")
print(output)
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/adsi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _get_good_ret(
if hasattr(ob, "Invoke"):
import win32com.client.dynamic

name = "Dispatch wrapper around %r" % ob
name = f"Dispatch wrapper around {ob!r}"
return win32com.client.dynamic.Dispatch(ob, name, ADSIDispatch)
return ob

Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/adsi/demos/scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def SpnRegister(
operation, # Add, replace, or delete SPNs
):
assert not isinstance(spns, str) and hasattr(spns, "__iter__"), (
"spns must be a sequence of strings (got %r)" % spns
f"spns must be a sequence of strings (got {spns!r})"
)
# Bind to a domain controller.
# Get the domain for the current user.
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/shell/demos/servers/folder_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def DisplayItem(shell_item_array, hwnd_parent=0):
else:
si = shell_item_array.GetItemAt(0)
name = si.GetDisplayName(shellcon.SIGDN_NORMALDISPLAY)
msg = "%d items selected, first is %r" % (shell_item_array.GetCount(), name)
msg = f"{shell_item_array.GetCount()} items selected, first is {name!r}"
win32gui.MessageBox(hwnd_parent, msg, "Hello", win32con.MB_OK)


Expand Down
4 changes: 2 additions & 2 deletions isapi/samples/redirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def io_callback(ecb, url, cbIO, errcode):
# Get the status of our ExecURL
httpstatus, substatus, win32 = ecb.GetExecURLStatus()
print(
"ExecURL of %r finished with http status %d.%d, win32 status %d (%s)"
% (url, httpstatus, substatus, win32, win32api.FormatMessage(win32).strip())
f"ExecURL of {url!r} finished with http status {httpstatus}.{substatus}, "
+ f"win32 status {win32} ({win32api.FormatMessage(win32).strip()})"
)
# nothing more to do!
ecb.DoneWithSession()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def build_extensions(self):
# Only mfcNNNu DLL is required (mfcmNNNX is Windows Forms, rest is ANSI)
mfc_contents = next(filter(None, map(glob.glob, redist_globs)), [])[:1]
if not mfc_contents:
raise RuntimeError("MFC redist DLLs not found like %r!" % redist_globs)
raise RuntimeError(f"MFC redist DLLs not found like {redist_globs!r}!")

target_dir = os.path.join(self.build_lib, win32ui_ext.get_pywin32_dir())
for mfc_content in mfc_contents:
Expand Down
9 changes: 3 additions & 6 deletions win32/Lib/win32evtlogutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,9 @@ def SafeFormatMessage(eventLogRecord, logType=None):
else:
desc = ", ".join(eventLogRecord.StringInserts)
return (
"<The description for Event ID ( %d ) in Source ( %r ) could not be found. It contains the following insertion string(s):%r.>"
% (
winerror.HRESULT_CODE(eventLogRecord.EventID),
eventLogRecord.SourceName,
desc,
)
f"<The description for Event ID ( {winerror.HRESULT_CODE(eventLogRecord.EventID)} ) "
+ f"in Source ( {eventLogRecord.SourceName!r} ) could not be found. "
+ f"It contains the following insertion string(s):{desc!r}.>"
)


Expand Down
6 changes: 2 additions & 4 deletions win32/Lib/win32rcparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def GenerateFrozenResource(rc_name, output_name, h_name=None):
out = open(output_name, "wt")
out.write("#%s\n" % output_name)
out.write("#This is a generated file. Please edit %s instead.\n" % rc_name)
out.write("__version__=%r\n" % __version__)
out.write(f"__version__={__version__!r}\n")
out.write(
"_rc_size_=%d\n_rc_mtime_=%d\n"
% (in_stat[stat.ST_SIZE], in_stat[stat.ST_MTIME])
Expand All @@ -631,9 +631,7 @@ def GenerateFrozenResource(rc_name, output_name, h_name=None):
out.write("\t\tself.idNum = idNum\n")
out.write("\t\tself.value = value\n")
out.write("\tdef __repr__(self):\n")
out.write(
'\t\treturn "StringDef(%r, %r, %r)" % (self.id, self.idNum, self.value)\n'
)
out.write('\t\treturn f"StringDef({self.id!r}, {self.idNum!r}, {self.value!r})"\n')

out.write("class FakeParser:\n")

Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/win32verstamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def stamp(pathname, options):
bits = [int(i) for i in ver.split(".")]
vmaj, vmin, vsub, vbuild = bits
except (IndexError, TypeError, ValueError):
raise ValueError("--version must be a.b.c.d (all integers) - got %r" % ver)
raise ValueError(f"--version must be a.b.c.d (all integers) - got {ver!r}")

ifn = options.internal_name
if not ifn:
Expand Down
2 changes: 1 addition & 1 deletion win32/test/testall.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def suite():
try:
mod = __import__(base)
except:
print("FAILED to import test module %r" % base)
print(f"FAILED to import test module {base!r}")
traceback.print_exc()
continue
if hasattr(mod, "suite"):
Expand Down
Loading