Skip to content

Commit

Permalink
Merge branch 'main' into Drop-Python-3.7-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Oct 18, 2024
2 parents 73c3202 + a940d68 commit fa6ab21
Show file tree
Hide file tree
Showing 76 changed files with 352 additions and 181 deletions.
2 changes: 1 addition & 1 deletion .github/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For all bugs, please provide the following information:
## Expected behavior and actual behavior

## Steps to reproduce the problem
<!-- Prefer using code snippets rather than a screenshot. Please include a full minimal reproduction if possible. -->
<!-- Prefer using code snippets rather than a screenshot. Please include a [full minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) if possible. -->

1. ...
2. ...
Expand Down
1 change: 0 additions & 1 deletion AutoDuck/TOCToHHK.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os.path
import sys

"""
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Coming in build 309, as yet unreleased
--------------------------------------

* Dropped support for Python 3.7 (#2207, @Avasam)
* Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2310)
* Fix memory leak converting to PyObject from some SAFEARRAY elements (#2316)
* Fix bug where makepy support was unnecessarily generated (#2354, #2353, @geppi)
* Fail sooner on invalid `win32timezone.TimeZoneInfo` creation (#2338, @Avasam)
* Removed temporary `win32com.server.policy` reexports hack (#2344, @Avasam)
Import `DispatcherWin32trace` and `DispatcherTrace` from `win32com.server.dispatcher` instead.
* Fixed `win32timezone.TimeZoneInfo` initialization from a `[DYNAMIC_]TIME_ZONE_INFORMATION` (#2339, @Avasam)
* Added runtime deprecation warning of `win2kras`, use `win32ras` instead (#2356, @Avasam)
* Improved handling of dict iterations and fallbacks (removes Python 2 support code, small general speed improvement) (#2332, #2330, @Avasam)
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/editor/ModuleBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import win32con
import win32ui
from pywin.mfc import afxres
from pywin.tools import browser, hierlist
from pywin.tools import hierlist


class HierListCLBRModule(hierlist.HierListItem):
Expand Down
4 changes: 3 additions & 1 deletion Pythonwin/pywin/framework/editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@ def SetEditorFontOption(option, newValue):
SetEditorOption(option, str(newValue))


from pywin.framework.editor.color.coloreditor import editorTemplate
from pywin.framework.editor.color.coloreditor import ( # nopycln: import
editorTemplate as editorTemplate, # Adds doc template & Re-export
)
1 change: 0 additions & 1 deletion Pythonwin/pywin/framework/editor/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import win32con
import win32ui
from pywin.framework.editor import GetEditorOption
from pywin.mfc import docview, object

BAK_NONE = 0
BAK_DOT_BAK = 1
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 @@ -14,7 +14,7 @@
import pywin.framework.app
import pywin.scintilla.control
import pywin.scintilla.formatter
import pywin.scintilla.IDLEenvironment
import pywin.scintilla.IDLEenvironment # nopycln: import # Injects fast_readline into the IDLE auto-indent extension
import win32api
import win32clipboard
import win32con
Expand Down
8 changes: 7 additions & 1 deletion Pythonwin/pywin/framework/intpydde.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@

import win32api
import win32ui
from dde import *
from dde import ( # nopycln: import # Re-exported for intpyapp.py
CBF_FAIL_SELFCONNECTIONS as CBF_FAIL_SELFCONNECTIONS, # noqa: PLC0414
CreateConversation as CreateConversation, # noqa: PLC0414
CreateServer,
CreateServerSystemTopic,
error as error, # noqa: PLC0414
)
from pywin.mfc import object


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

from . import app

tools = {}
idPos = 100

Expand Down
4 changes: 3 additions & 1 deletion Pythonwin/pywin/scintilla/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import win32con
import win32ui

from . import IDLEenvironment, keycodes
from . import ( # nopycln: import # Injects fast_readline into the IDLE auto-indent extension
IDLEenvironment,
)

HANDLER_ARGS_GUESS = 0
HANDLER_ARGS_NATIVE = 1
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/scintilla/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pywin.mfc import afxres, docview

from . import (
IDLEenvironment, # IDLE emulation.
IDLEenvironment, # nopycln: import # Injects fast_readline into the IDLE auto-indent extension
bindings,
control,
scintillacon,
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/test/test_pywin.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def test_ia(self):
def test_docedit(self):
import tempfile

import pywin.scintilla.IDLEenvironment
import pywin.scintilla.IDLEenvironment # nopycln: import # Injects fast_readline into the IDLE auto-indent extension

##doc = pywin.framework.editor.editorTemplate.OpenDocumentFile(None)
def t_print(*args):
Expand Down
1 change: 1 addition & 0 deletions adodbapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# nopycln: file # undecidable cases due to explicit re-exports https://github.com/hadialqattan/pycln/issues/205
"""adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO
Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole
Expand Down
1 change: 0 additions & 1 deletion adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import adodbapitestconfig as config # run the configuration module. # will set sys.path to find correct version of adodbapi
import tryconnection # in our code below, all our switches are from config.whatever
import win32com.client

import adodbapi
import adodbapi.apibase as api
Expand Down
8 changes: 8 additions & 0 deletions com/TestSources/PyCOMTest/PyCOMImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ HRESULT CPyCOMTest::GetStruct(TestStruct1 *ret)
*ret = r;
return S_OK;
}

HRESULT CPyCOMTest::ModifyStruct(TestStruct1 *prec)
{
prec->int_value = 100;
prec->str_value = SysAllocString(L"Nothing is as constant as change");
return S_OK;
}

HRESULT CPyCOMTest::DoubleString(BSTR in, BSTR *out)
{
*out = SysAllocStringLen(NULL, SysStringLen(in) * 2);
Expand Down
2 changes: 2 additions & 0 deletions com/TestSources/PyCOMTest/PyCOMImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class CPyCOMTest : public IDispatchImpl<IPyCOMTest, &IID_IPyCOMTest, &LIBID_PyCO
STDMETHOD(None)();
STDMETHOD(def)();

STDMETHOD(ModifyStruct)(TestStruct1 *prec);

// info associated to each session
struct PyCOMTestSessionData {
IStream *pStream; // Stream for marshalling the data to the new thread.
Expand Down
2 changes: 2 additions & 0 deletions com/TestSources/PyCOMTest/PyCOMTest.idl
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ library PyCOMTestLib
// reserved words etc
HRESULT None();
HRESULT def();
// Test struct byref as [ in, out ] parameter.
HRESULT ModifyStruct([ in, out ] TestStruct1 * prec);
};

// Define a new class to test how Python handles derived interfaces!
Expand Down
1 change: 0 additions & 1 deletion com/win32com/client/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ def _ResolveType(typerepr, itypeinfo):
if was_user and subrepr in [
pythoncom.VT_DISPATCH,
pythoncom.VT_UNKNOWN,
pythoncom.VT_RECORD,
]:
# Drop the VT_PTR indirection
return subrepr, sub_clsid, sub_doc
Expand Down
3 changes: 0 additions & 3 deletions com/win32com/client/combrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def CalculateIsExpandable(self):
rc = 0
return rc

pass


class HLI_IEnumMoniker(HLI_Enum):
def GetSubList(self):
Expand Down Expand Up @@ -583,7 +581,6 @@ def GetSubList(self):


def main(modal=True, mdi=False):
from pywin.tools import hierlist

root = HLIRoot("COM Browser")
if mdi and "pywin.framework.app" in sys.modules:
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/gencache.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def EnsureDispatch(
): # New fn, so we default the new demand feature to on!
"""Given a COM prog_id, return an object that is using makepy support, building if necessary"""
disp = win32com.client.Dispatch(prog_id)
if not disp.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it.
if not hasattr(disp, "CLSID"): # Eeek - no makepy support - try and build it.
try:
ti = disp._oleobj_.GetTypeInfo()
disp_clsid = ti.GetTypeAttr()[0]
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import pythoncom
from win32com.client import Dispatch, _get_good_object_
from win32com.client import _get_good_object_

PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]

Expand Down
2 changes: 1 addition & 1 deletion com/win32com/demos/excelAddin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import pythoncom
from win32com import universal
from win32com.client import Dispatch, DispatchWithEvents, constants, gencache
from win32com.client import DispatchWithEvents, constants, gencache

# Support for COM objects we use.
gencache.EnsureModule(
Expand Down
3 changes: 0 additions & 3 deletions com/win32com/demos/iebutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import win32api
import win32com
import win32com.server.register
from win32com import universal
from win32com.client import Dispatch, DispatchWithEvents, constants, gencache, getevents

# This demo uses 'print' - use win32traceutil to see it if we have no
# console.
Expand All @@ -40,7 +38,6 @@
except win32api.error:
import win32traceutil

import array

from win32com.axcontrol import axcontrol

Expand Down
2 changes: 1 addition & 1 deletion com/win32com/server/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _trace_(self, *args):


try:
import win32trace
import win32trace # nopycln: import # Check for win32traceutil w/o importing it

DefaultDebugDispatcher: type[DispatcherTrace] = DispatcherWin32trace
except ImportError: # no win32trace module - just use a print based one.
Expand Down
16 changes: 2 additions & 14 deletions com/win32com/server/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
problem, rather than a COM error.
"""

__author__ = "Greg Stein and Mark Hammond"

import sys
import types

Expand All @@ -92,6 +90,8 @@

from .exception import COMException

__author__ = "Greg Stein and Mark Hammond"

S_OK = 0

# Few more globals to speed things.
Expand Down Expand Up @@ -801,15 +801,3 @@ def _import_module(mname):
# Eeek - result of _import_ is "win32com" - not "win32com.a.b.c"
# Get the full module from sys.modules
return sys.modules[mname]


#######
#
# Temporary hacks until all old code moves.
#
# These have been moved to a new source file, but some code may
# still reference them here. These will end up being removed.
try:
from .dispatcher import DispatcherTrace, DispatcherWin32trace
except ImportError: # Quite likely a frozen executable that doesn't need dispatchers
pass
1 change: 0 additions & 1 deletion com/win32com/servers/test_pycomtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import winerror

# Ensure the vtables in the tlb are known.
from win32com import universal
from win32com.client import constants, gencache
from win32com.server.exception import COMException
from win32com.server.util import wrap
Expand Down
7 changes: 4 additions & 3 deletions com/win32com/src/oleargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,15 @@ static PyObject *PyCom_PyObjectFromSAFEARRAYDimensionItem(SAFEARRAY *psa, VARENU
hres = SafeArrayGetElement(psa, arrayIndices, &str);
if (FAILED(hres))
break;
subitem = PyWinObject_FromBstr(str);
subitem = PyWinObject_FromBstr(str, TRUE);
break;
}
case VT_DISPATCH: {
IDispatch *pDisp;
hres = SafeArrayGetElement(psa, arrayIndices, &pDisp);
if (FAILED(hres))
break;
subitem = PyCom_PyObjectFromIUnknown(pDisp, IID_IDispatch, TRUE);
subitem = PyCom_PyObjectFromIUnknown(pDisp, IID_IDispatch, FALSE);
break;
}
// case VT_ERROR - handled above with I4
Expand All @@ -895,7 +895,7 @@ static PyObject *PyCom_PyObjectFromSAFEARRAYDimensionItem(SAFEARRAY *psa, VARENU
hres = SafeArrayGetElement(psa, arrayIndices, &pUnk);
if (FAILED(hres))
break;
subitem = PyCom_PyObjectFromIUnknown(pUnk, IID_IUnknown, TRUE);
subitem = PyCom_PyObjectFromIUnknown(pUnk, IID_IUnknown, FALSE);
break;
}
// case VT_DECIMAL
Expand Down Expand Up @@ -1572,6 +1572,7 @@ BOOL PythonOleArgHelper::MakeObjToVariant(PyObject *obj, VARIANT *var, PyObject
// Nothing else to do - the code below sets the VT up correctly.
break;
case VT_RECORD:
case VT_RECORD | VT_BYREF:
rc = PyObject_AsVARIANTRecordInfo(obj, var);
break;
case VT_CY:
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testADOEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time

import pythoncom
from win32com.client import Dispatch, DispatchWithEvents, constants
from win32com.client import DispatchWithEvents, constants

finished = 0 # Flag for the wait loop from (3) to test

Expand Down
3 changes: 1 addition & 2 deletions com/win32com/test/testAXScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ def setUp(self):
file = win32api.GetFullPathName(
os.path.join(next(iter(win32com.axscript.client.__path__)), "pyscript.py")
)
from win32com.test.util import RegisterPythonServer

self.verbose = verbose
RegisterPythonServer(file, "python", verbose=self.verbose)
win32com.test.util.RegisterPythonServer(file, "python", verbose=self.verbose)

def testHost(self):
file = win32api.GetFullPathName(
Expand Down
5 changes: 3 additions & 2 deletions com/win32com/test/testDictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def TestDictAgainst(dict, check):
# Ensure we have the correct version registered.
def Register(quiet):
import win32com.servers.dictionary
from win32com.test.util import RegisterPythonServer

RegisterPythonServer(win32com.servers.dictionary.__file__, "Python.Dictionary")
win32com.test.util.RegisterPythonServer(
win32com.servers.dictionary.__file__, "Python.Dictionary"
)


def TestDict(quiet=None):
Expand Down
3 changes: 1 addition & 2 deletions com/win32com/test/testExchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os

import pythoncom
from win32com.client import constants, gencache
from win32com.client import gencache

ammodule = None # was the generated module!

Expand Down Expand Up @@ -91,7 +91,6 @@ def TestUser(session):


def test():
import win32com.client

oldcwd = os.getcwd()
try:
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testMSOffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def TestAll():
traceback.print_exc()

try:
import xl5en32
import xl5en32 # nopycln: import # Test import. TODO: Is testing Excel 95 still relevant ?

mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 9, 1, 0)
xl = win32com.client.Dispatch("Excel.Application.5")
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testMSOfficeEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import types

import pythoncom
from win32com.client import Dispatch, DispatchWithEvents
from win32com.client import DispatchWithEvents

stopEvent = threading.Event()

Expand Down
Loading

0 comments on commit fa6ab21

Please sign in to comment.