Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mhammond/pywin32 into Dispa…
Browse files Browse the repository at this point in the history
…tcherWin32dbg
  • Loading branch information
Avasam committed Mar 14, 2024
2 parents 5173008 + ad20c9b commit 33ec99a
Show file tree
Hide file tree
Showing 151 changed files with 1,615 additions and 737 deletions.
41 changes: 40 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,52 @@ jobs:
path: |
dist/*.whl
# This job can be run locally with the `format_all.bat` script
checkers:
runs-on: ubuntu-latest
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# This job only needs to target the oldest supported version (black@stable supports Python >=3.8)
python-version: '3.8'
- run: pip install isort pycln
- run: pycln . --config=pycln.toml --check
- run: isort . --diff --check-only
- uses: psf/black@stable
with:
options: "--fast --check --diff --verbose"

mypy:
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
# mypy 1.5 dropped support for python 3.7
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: pip install types-regex types-setuptools mypy>=1.5
- run: mypy . --python-version=${{ matrix.python-version }}

pyright:
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# pyright vendors typeshed, but let's make sure we have the most up to date stubs
- run: pip install types-regex types-setuptools
- uses: jakebailey/pyright-action@v2
with:
python-version: ${{ matrix.python-version }}
annotate: errors

2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Build 305, released 2022-11-06
from there. (#1908)

* Dropped support for allowing a bytes object to be passed where a COM BSTR
is expected - this support was accidental on the path from 2.x->3.x.
is expected - this support was accidental on the path from Python 2 -> 3.

* win32crypt's PyCERTSTORE.CertCloseStore()'s `Flags` argument has been
deprecated as it is likely to crash the process if
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 cmdline, dlgappcore
from pywin.framework import dlgappcore


class TimerAppDialog(dlgappcore.AppDialog):
Expand Down
1 change: 0 additions & 1 deletion Pythonwin/pywin/Demos/app/customprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# This sample was contributed by Roger Burnham.

import win32api
import win32con
import win32ui
from pywin.framework import app
Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/Demos/app/dlgappdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys

import win32ui
from pywin.framework import app, dlgappcore
from pywin.framework import dlgappcore


class TestDialogApp(dlgappcore.DialogApp):
Expand Down Expand Up @@ -43,7 +43,7 @@ def write(self, str):
win32ui.OutputDebug("dlgapp - no edit control! >>\n%s\n<<\n" % str)


app.AppBuilder = TestDialogApp
app = TestDialogApp()

if __name__ == "__main__":
import demoutils
Expand Down
5 changes: 2 additions & 3 deletions Pythonwin/pywin/Demos/app/dojobapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
# pythonwin /app demos\dojobapp.py


import win32api
import win32con
import win32ui
from pywin.framework import app, dlgappcore
from pywin.framework import dlgappcore


class DoJobAppDialog(dlgappcore.AppDialog):
Expand Down Expand Up @@ -57,7 +56,7 @@ def __init__(self):
DoJobDialogApp.__init__(self)


app.AppBuilder = DoJobDialogApp
app = DoJobDialogApp()


def t():
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/Demos/guidemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
("Dynamic window creation", "import createwin;createwin.demo()"),
("Various Dialog demos", "import dlgtest;dlgtest.demo()"),
("OCX Control Demo", "from ocx import ocxtest;ocxtest.demo()"),
("OCX Serial Port Demo", "from ocx import ocxserialtest; ocxserialtest.test()"),
("OCX Serial Port Demo", "from ocx import ocxserialtest; ocxserialtest.test()"),
(
"IE4 Control Demo",
'from ocx import webbrowser; webbrowser.Demo("http://www.python.org")',
Expand Down
18 changes: 9 additions & 9 deletions Pythonwin/pywin/docking/DockingBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ def OnWindowPosChanged(self, msg):
return 0
lparam = msg[3]
""" LPARAM used with WM_WINDOWPOSCHANGED:
typedef struct {
HWND hwnd;
HWND hwndInsertAfter;
int x;
int y;
int cx;
int cy;
UINT flags;} WINDOWPOS;
"""
typedef struct {
HWND hwnd;
HWND hwndInsertAfter;
int x;
int y;
int cx;
int cy;
UINT flags;} WINDOWPOS;
"""
format = "PPiiiii"
bytes = win32ui.GetBytes(lparam, struct.calcsize(format))
hwnd, hwndAfter, x, y, cx, cy, flags = struct.unpack(format, bytes)
Expand Down
28 changes: 0 additions & 28 deletions Pythonwin/pywin/framework/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# App.py
# Application stuff.
# The application is responsible for managing the main frame window.
#
Expand All @@ -17,29 +16,6 @@

from . import scriptutils

## NOTE: App and AppBuild should NOT be used - instead, you should contruct your
## APP class manually whenever you like (just ensure you leave these 2 params None!)
## Whoever wants the generic "Application" should get it via win32iu.GetApp()

# These are "legacy"
AppBuilder = None
App = None # default - if used, must end up a CApp derived class.


# Helpers that should one day be removed!
def AddIdleHandler(handler):
print(
"app.AddIdleHandler is deprecated - please use win32ui.GetApp().AddIdleHandler() instead."
)
return win32ui.GetApp().AddIdleHandler(handler)


def DeleteIdleHandler(handler):
print(
"app.DeleteIdleHandler is deprecated - please use win32ui.GetApp().DeleteIdleHandler() instead."
)
return win32ui.GetApp().DeleteIdleHandler(handler)


# Helper for writing a Window position by name, and later loading it.
def SaveWindowSize(section, rect, state=""):
Expand Down Expand Up @@ -169,10 +145,6 @@ def ExitInstance(self):
if self._obj_:
self._obj_.AttachObject(None)
self._obj_ = None
global App
global AppBuilder
App = None
AppBuilder = None
return 0

def HaveIdleHandler(self, handler):
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def MatchDocType(self, fileName, fileType):

# For debugging purposes, when this module may be reloaded many times.
try:
win32ui.GetApp().RemoveDocTemplate(bitmapTemplate)
win32ui.GetApp().RemoveDocTemplate(bitmapTemplate) # type: ignore[has-type, used-before-def]
except NameError:
pass

Expand Down
14 changes: 4 additions & 10 deletions Pythonwin/pywin/framework/editor/color/coloreditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from pywin.debugger import dbgcon
from pywin.framework.editor import GetEditorOption
from pywin.framework.editor.document import EditorDocumentBase
from pywin.framework.editor.frame import EditorFrame
from pywin.framework.editor.template import EditorTemplateBase
from pywin.scintilla import bindings, scintillacon
from pywin.scintilla.view import CScintillaView as SyntEditViewParent

# WARNING: Duplicated in document.py and editor.py
MSG_CHECK_EXTERNAL_FILE = win32con.WM_USER + 1999
Expand All @@ -36,9 +39,6 @@ def FinalizeViewCreation(self, view):
self.GetDocTemplate().CheckIDLEMenus(view.idle)


SyntEditViewParent = pywin.scintilla.view.CScintillaView


class SyntEditView(SyntEditViewParent):
"A view of a SyntEdit. Obtains data from document."

Expand Down Expand Up @@ -571,9 +571,6 @@ def FoldCollapseAllEvent(self, event):
win32ui.DoWaitCursor(-1)


from pywin.framework.editor.frame import EditorFrame


class SplitterFrame(EditorFrame):
def OnCreate(self, cs):
self.HookCommand(self.OnWindowSplit, win32ui.ID_WINDOW_SPLIT)
Expand All @@ -584,9 +581,6 @@ def OnWindowSplit(self, id, code):
return 1


from pywin.framework.editor.template import EditorTemplateBase


class SyntEditTemplate(EditorTemplateBase):
def __init__(
self, res=win32ui.IDR_TEXTTYPE, makeDoc=None, makeFrame=None, makeView=None
Expand Down Expand Up @@ -644,7 +638,7 @@ def GetPythonPropertyPages(self):

# For debugging purposes, when this module may be reloaded many times.
try:
win32ui.GetApp().RemoveDocTemplate(editorTemplate)
win32ui.GetApp().RemoveDocTemplate(editorTemplate) # type: ignore[has-type, used-before-def]
except NameError:
pass

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def Create(fileName=None, title=None, template=None):
if __name__ == prefModule:
# For debugging purposes, when this module may be reloaded many times.
try:
win32ui.GetApp().RemoveDocTemplate(editorTemplate)
win32ui.GetApp().RemoveDocTemplate(editorTemplate) # type: ignore[has-type, used-before-def]
except (NameError, win32ui.error):
pass

Expand Down
4 changes: 0 additions & 4 deletions Pythonwin/pywin/framework/intpyapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,4 @@ def OnHelpIndex(self, id, code):
help.SelectAndRunHelpFile()


# As per the comments in app.py, this use is depreciated.
# app.AppBuilder = InteractivePythonApp

# Now all we do is create the application
thisApp = InteractivePythonApp()
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def getNew(self):


try:
win32ui.GetApp().RemoveDocTemplate(greptemplate)
win32ui.GetApp().RemoveDocTemplate(greptemplate) # type: ignore[has-type, used-before-def]
except NameError:
pass

Expand Down
1 change: 1 addition & 0 deletions Pythonwin/pywin/framework/scriptutils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Various utilities for running/importing a script
"""

import bdb
import linecache
import os
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 @@ -751,7 +751,7 @@ def getNew(self):


try:
win32ui.GetApp().RemoveDocTemplate(greptemplate)
win32ui.GetApp().RemoveDocTemplate(greptemplate) # type: ignore[has-type, used-before-def]
except NameError:
pass

Expand Down
14 changes: 0 additions & 14 deletions Pythonwin/pywin/framework/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,3 @@

# Import the application module.
__import__(moduleName)

try:
win32ui.GetApp()._obj_
# This worked - an app already exists - do nothing more
except (AttributeError, win32ui.error):
# This means either no app object exists at all, or the one
# that does exist does not have a Python class (ie, was created
# by the host .EXE). In this case, we do the "old style" init...
from . import app

if app.AppBuilder is None:
raise TypeError("No application object has been registered")

app.App = app.AppBuilder()
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/stdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ def fake_input(prompt=None):
finally:
get_input_line = input
else:
sys.stdin = Stdin()
sys.stdin = Stdin() # type: ignore[assignment] # Not an actual TextIO
1 change: 1 addition & 0 deletions Pythonwin/pywin/mfc/activex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Support for ActiveX control hosting in Pythonwin.
"""

import win32ui
import win32uiole

Expand Down
1 change: 1 addition & 0 deletions Pythonwin/pywin/mfc/dialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" \
Base class for Dialogs. Also contains a few useful utility functions
"""

# dialog.py
# Python class for Dialog Boxes in PythonWin.

Expand Down
48 changes: 24 additions & 24 deletions Pythonwin/pywin/scintilla/IDLEenvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,30 +533,30 @@ def test():
e.SetSel((4, 4))

skip = """
TestCheck("insert", e, 4)
TestCheck("insert wordstart", e, 3)
TestCheck("insert wordend", e, 8)
TestCheck("insert linestart", e, 0)
TestCheck("insert lineend", e, 12)
TestCheck("insert + 4 chars", e, 8)
TestCheck("insert +4c", e, 8)
TestCheck("insert - 2 chars", e, 2)
TestCheck("insert -2c", e, 2)
TestCheck("insert-2c", e, 2)
TestCheck("insert-2 c", e, 2)
TestCheck("insert- 2c", e, 2)
TestCheck("1.1", e, 1)
TestCheck("1.0", e, 0)
TestCheck("2.0", e, 13)
try:
TestCheck("sel.first", e, 0)
print("*** sel.first worked with an empty selection")
except TextError:
pass
e.SetSel((4,5))
TestCheck("sel.first- 2c", e, 2)
TestCheck("sel.last- 2c", e, 3)
"""
TestCheck("insert", e, 4)
TestCheck("insert wordstart", e, 3)
TestCheck("insert wordend", e, 8)
TestCheck("insert linestart", e, 0)
TestCheck("insert lineend", e, 12)
TestCheck("insert + 4 chars", e, 8)
TestCheck("insert +4c", e, 8)
TestCheck("insert - 2 chars", e, 2)
TestCheck("insert -2c", e, 2)
TestCheck("insert-2c", e, 2)
TestCheck("insert-2 c", e, 2)
TestCheck("insert- 2c", e, 2)
TestCheck("1.1", e, 1)
TestCheck("1.0", e, 0)
TestCheck("2.0", e, 13)
try:
TestCheck("sel.first", e, 0)
print("*** sel.first worked with an empty selection")
except TextError:
pass
e.SetSel((4,5))
TestCheck("sel.first- 2c", e, 2)
TestCheck("sel.last- 2c", e, 3)
"""
# Check EOL semantics
e.SetSel((4, 4))
TestGet("insert lineend", "insert lineend +1c", t, "\n")
Expand Down
Loading

0 comments on commit 33ec99a

Please sign in to comment.