Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mhammond/pywin32 into remov…
Browse files Browse the repository at this point in the history
…e-ironpython
  • Loading branch information
Avasam committed Jul 24, 2023
2 parents 2b338a7 + 630ffa3 commit 15ea614
Show file tree
Hide file tree
Showing 123 changed files with 341 additions and 612 deletions.
9 changes: 4 additions & 5 deletions AutoDuck/py2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def ad_escape(s):


Print = __builtins__.__dict__["print"]
long = int


class DocInfo:
Expand Down Expand Up @@ -106,11 +105,11 @@ def build_module(fp, mod_name):
continue
if hasattr(ob, "__module__") and ob.__module__ != mod_name:
continue
if type(ob) in (type, type):
if type(ob) == type:
classes.append(BuildInfo(name, ob))
elif type(ob) == types.FunctionType:
elif isinstance(ob, types.FunctionType):
functions.append(BuildInfo(name, ob))
elif name.upper() == name and type(ob) in (int, str):
elif name.upper() == name and isinstance(ob, (int, str)):
constants.append((name, ob))
info = BuildInfo(mod_name, mod)
Print("// @module %s|%s" % (mod_name, format_desc(info.desc)), file=fp)
Expand Down Expand Up @@ -169,7 +168,7 @@ def build_module(fp, mod_name):

for name, val in constants:
desc = "%s = %r" % (name, val)
if type(val) in (int, int):
if isinstance(val, int):
desc += " (0x%x)" % (val,)
Print("// @const %s|%s|%s" % (mod_name, name, desc), file=fp)

Expand Down
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ https://mhammond.github.io/pywin32_installers.html.

Coming in build 307, as yet unreleased
--------------------------------------
* Release GIL when calling CreateService or StartService

Build 306, released 2023-03-26
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/Demos/app/basictimerapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import win32api
import win32con
import win32ui
from pywin.framework import app, cmdline, dlgappcore
from pywin.framework import cmdline, dlgappcore


class TimerAppDialog(dlgappcore.AppDialog):
Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/Demos/demoutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def NeedApp():
win32ui.MessageBox("Error executing command - %s" % (details), "Demos")


from pywin.framework.app import HaveGoodGUI

if __name__ == "__main__":
import demoutils

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/Demos/dlgtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def OnNotify(self, controlid, code):
# Simply increment the value in the text box.
def KillFocus(self, msg):
self.counter = self.counter + 1
if self.edit != None:
if self.edit is not None:
self.edit.SetWindowText(str(self.counter))

# Called when the dialog box is terminating...
Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/Demos/ocx/demoutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def NeedApp():
win32ui.MessageBox("Error executing command - %s" % (details), "Demos")


from pywin.framework.app import HaveGoodGUI

if __name__ == "__main__":
from . import demoutils

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/debugger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def post_mortem(t=None):
# No idea why I need to settrace to None - it should have been reset by now?
sys.settrace(None)
p.reset()
while t.tb_next != None:
while t.tb_next is not None:
t = t.tb_next
p.bAtPostMortem = 1
p.prep_run(None)
Expand Down
9 changes: 2 additions & 7 deletions Pythonwin/pywin/debugger/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@
from pywin.mfc import afxres, dialog, object, window
from pywin.tools import browser, hierlist

# import win32traceutil
if win32ui.UNICODE:
LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW
else:
LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITA

from .dbgcon import *

LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW
error = "pywin.debugger.error"


Expand Down Expand Up @@ -751,7 +746,7 @@ def run(self, cmd, globals=None, locals=None, start_stepping=1):
self.reset()
self.prep_run(cmd)
sys.settrace(self.trace_dispatch)
if type(cmd) != types.CodeType:
if not isinstance(cmd, types.CodeType):
cmd = cmd + "\n"
try:
try:
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/dialogs/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def GetPassword(title="Password", password=""):
if len(sys.argv) > 2:
def_userid = sys.argv[2]
userid, password = GetLogin(title, def_user)
if userid == password == None:
if userid == password is None:
print("User pressed Cancel")
else:
print("User ID: ", userid)
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def Win32RawInput(prompt=None):
if prompt is None:
prompt = ""
ret = dialog.GetSimpleInput(prompt)
if ret == None:
if ret is None:
raise KeyboardInterrupt("operation cancelled")
return ret

Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/framework/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@


def ParseArgs(str):
import string

ret = []
pos = 0
length = len(str)
Expand Down
3 changes: 0 additions & 3 deletions Pythonwin/pywin/framework/editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# This really isnt necessary with Scintilla, and scintilla
# is getting so deeply embedded that it was too much work.

import sys

import win32con
import win32ui

defaultCharacterFormat = (-402653169, 0, 200, 0, 0, 0, 49, "Courier New")
Expand Down
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
1 change: 0 additions & 1 deletion Pythonwin/pywin/framework/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def ListAllHelpFiles():

def _ListAllHelpFilesInRoot(root):
"""Returns a list of (helpDesc, helpFname) for all registered help files"""
import regutil

retList = []
try:
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def ColorizeInteractiveCode(self, cdoc, styleStart, stylePyStart):
return
state = styleStart
# As per comments in Colorize(), we work with the raw utf8
# bytes. To avoid too muych py3k pain, we treat each utf8 byte
# bytes. To avoid too much pain, we treat each utf8 byte
# as a latin-1 unicode character - we only use it to compare
# against ascii chars anyway...
chNext = cdoc[0:1].decode("latin-1")
Expand Down
12 changes: 6 additions & 6 deletions Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ def __delslice__(self, lo, hi):
del self.dirs[lo:hi]

def __add__(self, other):
if type(other) == type(self) or type(other) == type([]):
if isinstance(other, (dirpath, list)):
return self.dirs + other.dirs

def __radd__(self, other):
if type(other) == type(self) or type(other) == type([]):
if isinstance(other, (dirpath, list)):
return other.dirs + self.dirs


# 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 @@ -319,7 +319,7 @@ def idleHandler(self, handler, count):
import time

time.sleep(0.001)
if self.result != None:
if self.result is not None:
win32ui.GetApp().DeleteIdleHandler(self.idleHandler)
return 0
return 1 # more
Expand Down Expand Up @@ -389,7 +389,7 @@ def _inactive_idleHandler(self, handler, count):
lines = open(f, "r").readlines()
for i in range(len(lines)):
line = lines[i]
if self.pat.search(line) != None:
if self.pat.search(line) is not None:
self.GetFirstView().Append(f + "(" + repr(i + 1) + ") " + line)
else:
self.fndx = -1
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
8 changes: 4 additions & 4 deletions Pythonwin/pywin/framework/sgrepmdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ def __delslice__(self, lo, hi):
del self.dirs[lo:hi]

def __add__(self, other):
if type(other) == type(self) or type(other) == type([]):
if isinstance(other, (dirpath, list)):
return self.dirs + other.dirs

def __radd__(self, other):
if type(other) == type(self) or type(other) == type([]):
if isinstance(other, (dirpath, list)):
return other.dirs + self.dirs


# 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 Expand Up @@ -302,7 +302,7 @@ def SearchFile(self, handler, count):
lines = open(f, "r").readlines()
for i in range(len(lines)):
line = lines[i]
if self.pat.search(line) != None:
if self.pat.search(line) is not None:
self.GetFirstView().Append(f + "(" + repr(i + 1) + ") " + line)
else:
self.fndx = -1
Expand Down
17 changes: 6 additions & 11 deletions Pythonwin/pywin/framework/stdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# any purpose.
"""Provides a class Stdin which can be used to emulate the regular old
sys.stdin for the PythonWin interactive window. Right now it just pops
up a raw_input() dialog. With luck, someone will integrate it into the
up a input() dialog. With luck, someone will integrate it into the
actual PythonWin interactive window someday.
WARNING: Importing this file automatically replaces sys.stdin with an
Expand All @@ -18,15 +18,12 @@
"""
import sys

try:
get_input_line = raw_input # py2x
except NameError:
get_input_line = input # py3k
get_input_line = input


class Stdin:
def __init__(self):
self.real_file = sys.stdin # NOTE: Likely to be None in py3k
self.real_file = sys.stdin # NOTE: Likely to be None
self.buffer = ""
self.closed = False

Expand Down Expand Up @@ -142,7 +139,7 @@ def readlines(self, *sizehint):
Sell you soul to the devil, baby
"""

def fake_raw_input(prompt=None):
def fake_input(prompt=None):
"""Replacement for raw_input() which pulls lines out of global test_input.
For testing only!
"""
Expand All @@ -157,7 +154,7 @@ def fake_raw_input(prompt=None):
raise EOFError()
return result

get_input_line = fake_raw_input
get_input_line = fake_input

# Some completely inadequate tests, just to make sure the code's not totally broken
try:
Expand All @@ -169,8 +166,6 @@ def fake_raw_input(prompt=None):
print(x.readline(3))
print(x.readlines())
finally:
get_input_line = raw_input
get_input_line = input
else:
import sys

sys.stdin = Stdin()
7 changes: 2 additions & 5 deletions 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 Expand Up @@ -149,10 +149,7 @@ def HandleToolCommand(cmd, code):
import commctrl
from pywin.mfc import dialog

if win32ui.UNICODE:
LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW
else:
LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITA
LVN_ENDLABELEDIT = commctrl.LVN_ENDLABELEDITW


class ToolMenuPropPage(dialog.PropertyPage):
Expand Down
6 changes: 3 additions & 3 deletions 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 Expand Up @@ -129,7 +129,7 @@ def OnRClick(self, params):
paramsList = self.GetRightMenuItems()
menu = win32ui.CreatePopupMenu()
for appendParams in paramsList:
if type(appendParams) != type(()):
if not isinstance(appendParams, tuple):
appendParams = (appendParams,)
menu.AppendMenu(*appendParams)
menu.TrackPopupMenu(params[5]) # track at mouse position.
Expand Down Expand Up @@ -377,7 +377,7 @@ def __init__(
self.title = title
self.bCreating = 0
self.interruptCount = 0
if type(defSize) == type(""): # is a string - maintain size pos from ini file.
if isinstance(defSize, str): # maintain size pos from ini file.
self.iniSizeSection = defSize
self.defSize = app.LoadWindowSize(defSize)
self.loadedSize = self.defSize
Expand Down
Loading

0 comments on commit 15ea614

Please sign in to comment.