Skip to content

Commit

Permalink
Merge branch 'main' into EvtSubscribe_push-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Jul 9, 2024
2 parents 3ece48f + a9010f3 commit 6c1a5a3
Show file tree
Hide file tree
Showing 25 changed files with 133 additions and 65 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
architecture: ["x64", "x86"]

steps:
Expand All @@ -30,6 +30,7 @@ jobs:
architecture: ${{ matrix.architecture }}
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true

- name: Setup environment
run: |
Expand Down Expand Up @@ -66,8 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12-dev"]

python-version: ["3.10", "3.11", "3.12", "3.13-dev"]
steps:
- uses: actions/checkout@v4

Expand All @@ -78,6 +78,7 @@ jobs:
architecture: "x64"
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true

- name: Setup Environment
run: |
Expand Down Expand Up @@ -137,6 +138,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true
- run: pip install types-regex types-setuptools mypy==1.9
- run: mypy . --python-version=${{ matrix.python-version }}

Expand All @@ -145,14 +147,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: .github/workflows/main.yml
check-latest: true
# 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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ venv.bak/
.idea/
.DS_Store
vagrant_helpers/bootstrap-salt.ps1
.vscode/
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Coming in build 307, as yet unreleased

### pywin32
* The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam)
* Add RealGetWindowClass (#2299, @CristiFati)
* Make it compile on Python 3.13 (#2260, @clin1234)
* Fixed accidentally trying to raise a `str` instead of an `Exception` in (#2270, @Avasam)
* `Pythonwin/pywin/debugger/debugger.py`
* `Pythonwin/pywin/framework/dlgappcore.py`
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/win32thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ unsigned int ThreadWorkerEntryPoint(LPVOID lpvoid)
{
CPythonWinThread *pThis = (CPythonWinThread *)lpvoid;
CEnterLeavePython _celp;
PyObject *result = PyEval_CallObject(pThis->obFunc, pThis->obArgs);
PyObject *result = PyObject_CallObject(pThis->obFunc, pThis->obArgs);
if (result == NULL) {
if (PyErr_Occurred() == PyExc_SystemExit)
PyErr_Clear();
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/win32uimodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ static DWORD FilterFunc(DWORD dwExceptionCode)
return (dwRet);
}

PyObject *gui_call_object(PyObject *themeth, PyObject *thearglst) { return PyEval_CallObject(themeth, thearglst); }
PyObject *gui_call_object(PyObject *themeth, PyObject *thearglst) { return PyObject_CallObject(themeth, thearglst); }

void gui_print_error(void)
{
Expand Down
5 changes: 2 additions & 3 deletions adodbapi/adodbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,8 @@ def __setattr__(self, name, value):
f"paramstyle={value!r} not in:{api.accepted_paramstyles!r}",
)
elif name == "variantConversions":
value = copy.copy(
value
) # make a new copy -- no changes in the default, please
# make a new copy -- no changes in the default, please
value = copy.copy(value)
object.__setattr__(self, name, value)

def __getattr__(self, item):
Expand Down
25 changes: 17 additions & 8 deletions adodbapi/apibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
* http://sourceforge.net/projects/adodbapi
"""

from __future__ import annotations

import datetime
import decimal
import numbers
import sys
import time
from collections.abc import Callable, Iterable, Mapping
from typing import Dict

# noinspection PyUnresolvedReferences
from . import ado_consts as adc
Expand Down Expand Up @@ -461,20 +465,25 @@ def convert_to_python(variant, func): # convert DB value into Python value
return func(variant) # call the appropriate conversion function


class MultiMap(dict): # builds a dictionary from {(sequence,of,keys) : function}
"""A dictionary of ado.type : function -- but you can set multiple items by passing a sequence of keys"""
class MultiMap(Dict[int, Callable[[object], object]]):
# builds a dictionary from {(iterable,of,keys) : function}
"""A dictionary of ado.type : function
-- but you can set multiple items by passing an iterable of keys"""

# useful for defining conversion functions for groups of similar data types.
def __init__(self, aDict):
for k, v in list(aDict.items()):
def __init__(self, aDict: Mapping[Iterable[int] | int, Callable[[object], object]]):
for k, v in aDict.items():
self[k] = v # we must call __setitem__

def __setitem__(self, adoType, cvtFn):
"set a single item, or a whole sequence of items"
try: # user passed us a sequence, set them individually
def __setitem__(
self, adoType: Iterable[int] | int, cvtFn: Callable[[object], object]
):
"set a single item, or a whole iterable of items"
if isinstance(adoType, Iterable):
# user passed us an iterable, set them individually
for type in adoType:
dict.__setitem__(self, type, cvtFn)
except TypeError: # a single value fails attempt to iterate
else:
dict.__setitem__(self, adoType, cvtFn)


Expand Down
28 changes: 13 additions & 15 deletions adodbapi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
Adodbapi can be run on CPython 3.5 and later.
"""

CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Operating System :: Microsoft :: Windows
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: SQL
Topic :: Software Development
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Database
"""

NAME = "adodbapi"
MAINTAINER = "Vernon Cole"
MAINTAINER_EMAIL = "vernondcole@gmail.com"
Expand All @@ -25,7 +11,19 @@
)
URL = "http://sourceforge.net/projects/adodbapi"
LICENSE = "LGPL"
CLASSIFIERS = filter(None, CLASSIFIERS.split("\n"))
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: SQL",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Database",
]
AUTHOR = "Henrik Ekelund, Vernon Cole, et.al."
AUTHOR_EMAIL = "vernondcole@gmail.com"
PLATFORMS = ["Windows", "Linux"]
Expand Down
24 changes: 18 additions & 6 deletions adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,17 +1546,29 @@ def testTimestamp(self):
assert t1 < obj < t2, obj


suites = [unittest.makeSuite(TestPythonDateTimeConverter, "test")]
suites = [
unittest.defaultTestLoader.loadTestsFromModule(TestPythonDateTimeConverter, "test")
]
if config.doTimeTest:
suites.append(unittest.makeSuite(TestPythonTimeConverter, "test"))
suites.append(
unittest.defaultTestLoader.loadTestsFromModule(TestPythonTimeConverter, "test")
)
if config.doAccessTest:
suites.append(unittest.makeSuite(TestADOwithAccessDB, "test"))
suites.append(
unittest.defaultTestLoader.loadTestsFromModule(TestADOwithAccessDB, "test")
)
if config.doSqlServerTest:
suites.append(unittest.makeSuite(TestADOwithSQLServer, "test"))
suites.append(
unittest.defaultTestLoader.loadTestsFromModule(TestADOwithSQLServer, "test")
)
if config.doMySqlTest:
suites.append(unittest.makeSuite(TestADOwithMySql, "test"))
suites.append(
unittest.defaultTestLoader.loadTestsFromModule(TestADOwithMySql, "test")
)
if config.doPostgresTest:
suites.append(unittest.makeSuite(TestADOwithPostgres, "test"))
suites.append(
unittest.defaultTestLoader.loadTestsFromModule(TestADOwithPostgres, "test")
)


class cleanup_manager:
Expand Down
4 changes: 4 additions & 0 deletions build_all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ py -3.12-32 setup.py -q build
@if errorlevel 1 goto failed
py -3.12 setup.py -q build
@if errorlevel 1 goto failed
py -3.13-32 setup.py -q build
@if errorlevel 1 goto failed
py -3.13 setup.py -q build
@if errorlevel 1 goto failed

goto xit
:failed
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/src/oleargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ BOOL PyCom_MakeOlePythonCall(PyObject *handler, DISPPARAMS FAR *params, VARIANT
argList = Py_BuildValue("OO", varArgs, addnlArgs);
Py_DECREF(varArgs);
}
PyObject *result = PyEval_CallObject(handler, argList);
PyObject *result = PyObject_CallObject(handler, argList);
Py_XDECREF(argList);
Py_XDECREF(namedArgList);
// handlers reference cleaned up by virtual manager.
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/src/univgw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static HRESULT univgw_dispatch(DWORD index, gw_object *_this, va_list argPtr)
PyTuple_SET_ITEM(obArgs, 2, obArgPtr);

// call the provided method
PyObject *result = PyEval_CallObjectWithKeywords(vtbl->dispatcher, obArgs, NULL);
PyObject *result = PyObject_CallObject(vtbl->dispatcher, obArgs);

// done with the arguments and the contained objects
Py_DECREF(obArgs);
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testIterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def suite():
and issubclass(item, unittest.TestCase)
and item != _BaseTestCase
):
suite.addTest(unittest.makeSuite(item))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(item))
return suite


Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/shell/src/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ static int CALLBACK PyBrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LP
#endif
if (!args)
goto done;
result = PyEval_CallObject(pc->fn, args);
result = PyObject_CallObject(pc->fn, args);
// API says must return 0, but there might be a good reason.
if (result && PyLong_Check(result))
rc = PyLong_AsLong(result);
Expand Down
5 changes: 5 additions & 0 deletions make_all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.12
py -3.12-32 setup.py -q bdist_wheel --skip-build
py -3.12 setup.py -q bdist_wheel --skip-build

py -3.9 setup.py -q bdist_wininst --skip-build --target-version=3.13
py -3.13-32 setup.py -q bdist_wheel --skip-build
py -3.13 setup.py -q bdist_wheel --skip-build

rem ARM64 builds - requires you to select:
rem * "Visual C++ compilers and libraries for ARM64"
rem * "Visual C++ for MFC for ARM64"
rem from "Individual Components" in VS setup.
py -3.10 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.11 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.12 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64
py -3.13 setup.py -q build_ext --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64

@goto xit
:couldnt_rm
Expand Down
2 changes: 0 additions & 2 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ exclude = (?x)(
| ^Pythonwin/Scintilla/
; Forked IDLE extensions predating Python 2.3. They now live in idlelib in https://github.com/python/cpython/tree/main/Lib/idlelib
| ^Pythonwin/pywin/idle/
; TODO: adodbapi should be updated and fixed separately
| ^adodbapi/
; TODO: Ignoring non-public APIs until all public API is typed
| ([Tt]est|[Dd]emos?)/
)
Expand Down
2 changes: 0 additions & 2 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"**/test/",
"**/Demos/",
"**/demo/",
// TODO: adodbapi should be updated and fixed separately
"adodbapi/",
],
// Packages that will be accessible globally.
// Setting this makes pyright use the repo's code for those modules instead of typeshed or pywin32 in site-packages
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,7 @@ def convert_optional_data_files(files):
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
]

Expand Down
2 changes: 1 addition & 1 deletion win32/src/PyTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ PyObject *PyWin_NewTime(PyObject *timeOb)
if (method == NULL)
PyErr_Clear();
else {
timeOb = PyEval_CallObject(method, NULL);
timeOb = PyObject_CallObject(method, NULL);
Py_DECREF(method);
if (!timeOb)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion win32/src/timermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ VOID CALLBACK py_win32_timer_callback(HWND hwnd, UINT msg, UINT_PTR timer_id, DW
// the callback itself removes the function from the map.
Py_INCREF(callback_function);
PyObject *callback_args = Py_BuildValue("(Ok)", py_timer_id, time);
PyObject *result = PyEval_CallObject(callback_function, callback_args);
PyObject *result = PyObject_CallObject(callback_function, callback_args);

if (!result) {
// Is this necessary, or will python already have flagged
Expand Down
Loading

0 comments on commit 6c1a5a3

Please sign in to comment.