Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mhammond/pywin32 into undef…
Browse files Browse the repository at this point in the history
…ined-names
  • Loading branch information
Avasam committed Nov 1, 2023
2 parents 130c0da + d26c5c8 commit 623fb6a
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 188 deletions.
3 changes: 0 additions & 3 deletions Pythonwin/pywin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
# others are looking at it, but it will go away soon!
is_platform_unicode = 0

# Ditto default_platform_encoding - not referenced and will die.
default_platform_encoding = "mbcs"

# This one *is* real and used - but in practice can't be changed.
default_scintilla_encoding = "utf-8" # Scintilla _only_ supports this ATM
18 changes: 6 additions & 12 deletions Pythonwin/pywin/framework/editor/color/coloreditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
# even tighter into Pythonwin.

import pywin.scintilla.keycodes
import pywin.scintilla.view
import win32api
import win32con
import win32ui
from pywin.debugger import dbgcon
from pywin.framework.editor import GetEditorOption
from pywin.scintilla import bindings

# from pywin.framework.editor import EditorPropertyPage
from pywin.framework.editor.document import EditorDocumentBase
from pywin.scintilla import bindings, scintillacon

MSG_CHECK_EXTERNAL_FILE = (
win32con.WM_USER + 1999
) ## WARNING: Duplicated in document.py and editor.py
# WARNING: Duplicated in document.py and editor.py
MSG_CHECK_EXTERNAL_FILE = win32con.WM_USER + 1999

# Define a few common markers
MARKER_BOOKMARK = 0
MARKER_BREAKPOINT = 1
MARKER_CURRENT = 2

import pywin.scintilla.view
from pywin.debugger import dbgcon
from pywin.framework.editor.document import EditorDocumentBase
from pywin.scintilla import scintillacon # For the marker definitions
from pywin.scintilla.document import CScintillaDocument


class SyntEditDocument(EditorDocumentBase):
"A SyntEdit document."
Expand Down
21 changes: 9 additions & 12 deletions Pythonwin/pywin/framework/editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@
GetEditorOption,
defaultCharacterFormat,
)
from pywin.mfc import afxres, docview
from pywin.mfc import afxres
from pywin.mfc.docview import RichEditView as ParentEditorView

from .document import EditorDocumentBase as ParentEditorDocument

# from pywin.mfc.docview import EditView as ParentEditorView
# from pywin.mfc.docview import Document as ParentEditorDocument

patImport = regex.symcomp(r"import \(<name>.*\)")
patIndent = regex.compile(r"^\([ \t]*[~ \t]\)")

ID_LOCATE_FILE = 0xE200
ID_GOTO_LINE = 0xE2001
MSG_CHECK_EXTERNAL_FILE = (
win32con.WM_USER + 1999
) ## WARNING: Duplicated in document.py and coloreditor.py
# WARNING: Duplicated in document.py and coloreditor.py
MSG_CHECK_EXTERNAL_FILE = win32con.WM_USER + 1999

# Key Codes that modify the bufffer when Ctrl or Alt are NOT pressed.
MODIFYING_VK_KEYS = [
Expand Down Expand Up @@ -76,11 +81,6 @@

isRichText = 1 # We are using the Rich Text control. This has not been tested with value "0" for quite some time!

# ParentEditorDocument=docview.Document
from .document import EditorDocumentBase

ParentEditorDocument = EditorDocumentBase


class EditorDocument(ParentEditorDocument):
#
Expand Down Expand Up @@ -164,9 +164,6 @@ def SetLineColor(self, lineNo, color):
# self.saveFileHandle.write(data)
# return 1 # keep em coming!

# ParentEditorView=docview.EditView
ParentEditorView = docview.RichEditView


class EditorView(ParentEditorView):
def __init__(self, doc):
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def IsOnPythonPath(path):


def GetPackageModuleName(fileName):
"""Given a filename, return (module name, new path).
r"""Given a filename, return (module name, new path).
eg - given "c:\a\b\c\my.py", return ("b.c.my",None) if "c:\a" is on sys.path.
If no package found, will return ("my", "c:\a\b\c")
"""
Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/tools/hierlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ def AddItem(self, parentHandle, item, hInsertAfter=commctrl.TVI_LAST):
bitmapSel = self.GetSelectedBitmapColumn(item)
if bitmapSel is None:
bitmapSel = bitmapCol
## if isinstance(text, str):
## text = text.encode("mbcs")
hitem = self.listControl.InsertItem(
parentHandle,
hInsertAfter,
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __WrapDispatch(


def GetObject(Pathname=None, Class=None, clsctx=None):
"""
r"""
Mimic VB's GetObject() function.
ob = GetObject(Class = "ProgID") or GetObject(Class = clsid) will
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/client/genpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def BuildOleItemsFromType(self):

return oleItems, enumItems, recordItems, vtableItems

def open_writer(self, filename, encoding="mbcs"):
def open_writer(self, filename, encoding="utf-8"):
# A place to put code to open a file with the appropriate encoding.
# Does *not* set self.file - just opens and returns a file.
# Actually returns a handle to a temp file - finish_writer then deletes
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def do_gen_file_header(self):
# We assert this is it may indicate somewhere in pywin32 that needs
# upgrading.
assert self.file.encoding, self.file
encoding = self.file.encoding # or "mbcs"
encoding = self.file.encoding

print(f"# -*- coding: {encoding} -*-", file=self.file)
print(f"# Created by makepy.py version {makepy_version}", file=self.file)
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/authorization/demos/EditServiceSecurity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
Implements a permissions editor for services.
Service can be specified as plain name for local machine,
or as a remote service of the form \\machinename\service
Expand Down
17 changes: 5 additions & 12 deletions com/win32comext/axdebug/Test/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pythoncom
import win32api
import win32com.server.util
import winerror
from win32com.axdebug import codecontainer, gateways
from win32com.axdebug.util import _wrap, trace
Expand Down Expand Up @@ -49,9 +48,7 @@ def _query_interface_(self, iid):
from win32com.util import IIDToInterfaceName

trace(
"PySourceModuleDebugDocumentHost QI with {} ({})".format(
IIDToInterfaceName(iid), str(iid)
)
f"PySourceModuleDebugDocumentHost QI with {IIDToInterfaceName(iid)} ({iid})"
)
return 0

Expand All @@ -60,7 +57,7 @@ def _GetCodeContainer(self):
try:
codeText = open(self.module.__file__, "rt").read()
except OSError as details:
codeText = "# Exception opening file\n# %s" % (details)
codeText = f"# Exception opening file\n# {details}"

self.codeContainer = codecontainer.SourceCodeContainer(
codeText, self.module.__file__
Expand Down Expand Up @@ -115,8 +112,8 @@ def TestSmartProvider():
from win32com.axdebug import debugger

d = debugger.AXDebugger()
# d.StartDebugger()
# d.Attach()
# d.StartDebugger()
# d.Attach()
d.Break()
input("Waiting...")
ttest.test()
Expand All @@ -133,10 +130,6 @@ def test():

if __name__ == "__main__":
test()
import win32com.axdebug.util

win32com.axdebug.util._dump_wrapped()
print(
" %d/%d com objects still alive"
% (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
f" {pythoncom._GetInterfaceCount()}/{pythoncom._GetGatewayCount()} com objects still alive"
)
51 changes: 22 additions & 29 deletions com/win32comext/axdebug/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import win32api
import win32com.client.connect
from win32com.axdebug.util import _wrap, trace
from win32com.server.util import unwrap

from . import axdebug, gateways, stackframe

Expand Down Expand Up @@ -53,12 +52,7 @@ def _dumpf(frame):
addn = "(with trace!)"
if frame.f_trace is None:
addn = " **No Trace Set **"
return "Frame at %d, file %s, line: %d%s" % (
id(frame),
frame.f_code.co_filename,
frame.f_lineno,
addn,
)
return f"Frame at {id(frame)}, file {frame.f_code.co_filename}, line: {frame.f_lineno}{addn}"


g_adb = None
Expand Down Expand Up @@ -118,8 +112,8 @@ def __xxxxx__set_break(self, filename, lineno, cond=None):
def stop_here(self, frame):
traceenter("stop_here", _dumpf(frame), _dumpf(self.stopframe))
# As per bdb.stop_here, except for logicalbotframe
## if self.stopframe is None:
## return 1
# if self.stopframe is None:
# return 1
if frame is self.stopframe:
return 1

Expand Down Expand Up @@ -157,13 +151,13 @@ def dispatch_return(self, frame, arg):
tracev("dispatch_return resetting sys.trace")
sys.settrace(None)
return
# self.bSetTrace = 0
# self.bSetTrace = 0
self.currentframe = frame.f_back
return bdb.Bdb.dispatch_return(self, frame, arg)

def dispatch_line(self, frame):
traceenter("dispatch_line", _dumpf(frame), _dumpf(self.botframe))
# trace("logbotframe is", _dumpf(self.logicalbotframe), "botframe is", self.botframe)
# trace("logbotframe is", _dumpf(self.logicalbotframe), "botframe is", self.botframe)
if frame is self.logicalbotframe:
trace("dispatch_line", _dumpf(frame), "for bottom frame returing tracer")
# The next code executed in the frame above may be a builtin (eg, apply())
Expand Down Expand Up @@ -195,13 +189,13 @@ def dispatch_call(self, frame, arg):
trace(
"dispatch_call has no document for", _dumpf(frame), "- skipping trace!"
)
## sys.settrace(None)
# sys.settrace(None)
return None
return self.trace_dispatch

# rc = bdb.Bdb.dispatch_call(self, frame, arg)
# trace("dispatch_call", _dumpf(frame),"returned",rc)
# return rc
# rc = bdb.Bdb.dispatch_call(self, frame, arg)
# trace("dispatch_call", _dumpf(frame),"returned",rc)
# return rc

def trace_dispatch(self, frame, event, arg):
traceenter("trace_dispatch", _dumpf(frame), event, arg)
Expand All @@ -213,8 +207,8 @@ def trace_dispatch(self, frame, event, arg):
#
# The user functions do bugger all!
#
# def user_call(self, frame, argument_list):
# traceenter("user_call",_dumpf(frame))
# def user_call(self, frame, argument_list):
# traceenter("user_call",_dumpf(frame))

def user_line(self, frame):
traceenter("user_line", _dumpf(frame))
Expand All @@ -226,11 +220,11 @@ def user_line(self, frame):
self._HandleBreakPoint(frame, None, breakReason)

def user_return(self, frame, return_value):
# traceenter("user_return",_dumpf(frame),return_value)
# traceenter("user_return",_dumpf(frame),return_value)
bdb.Bdb.user_return(self, frame, return_value)

def user_exception(self, frame, exc_info):
# traceenter("user_exception")
# traceenter("user_exception")
bdb.Bdb.user_exception(self, frame, exc_info)

def _HandleBreakPoint(self, frame, tb, reason):
Expand Down Expand Up @@ -281,8 +275,7 @@ def CloseApp(self):

except pythoncom.com_error:
trace(
"*** Could not RemoveStackFrameSniffer %d"
% (self.stackSnifferCookie)
f"*** Could not RemoveStackFrameSniffer {self.stackSnifferCookie}"
)
self.stackSnifferCookie = self.stackSniffer = None

Expand All @@ -296,7 +289,7 @@ def CloseApp(self):
self.codeContainerProvider = None

def AttachApp(self, debugApplication, codeContainerProvider):
# traceenter("AttachApp", debugApplication, codeContainerProvider)
# traceenter("AttachApp", debugApplication, codeContainerProvider)
self.codeContainerProvider = codeContainerProvider
self.debugApplication = debugApplication
self.stackSniffer = _wrap(
Expand All @@ -305,7 +298,7 @@ def AttachApp(self, debugApplication, codeContainerProvider):
self.stackSnifferCookie = debugApplication.AddStackFrameSniffer(
self.stackSniffer
)
# trace("StackFrameSniffer added (%d)" % self.stackSnifferCookie)
# trace(f"StackFrameSniffer added ({self.stackSnifferCookie})")

# Connect to the application events.
self.appEventConnection = win32com.client.connect.SimpleConnection(
Expand All @@ -319,7 +312,7 @@ def ResetAXDebugging(self):
return

if len(self.recursiveData) == 0:
# print "ResetAXDebugging called for final time."
# print("ResetAXDebugging called for final time.")
self.logicalbotframe = None
self.debuggingThread = None
self.currentframe = None
Expand Down Expand Up @@ -425,14 +418,14 @@ def OnBreakFlagChange(self, abf, rdat):

def _BreakFlagsChanged(self):
traceenter(
"_BreakFlagsChanged to {} with our thread = {}, and debugging thread = {}".format(
self.breakFlags, self.debuggingThread, win32api.GetCurrentThreadId()
)
f"_BreakFlagsChanged to {self.breakFlags} "
+ f"with our thread = {self.debuggingThread}, "
+ f"and debugging thread = {win32api.GetCurrentThreadId()}"
)
trace("_BreakFlagsChanged has breaks", self.breaks)
# If a request comes on our debugging thread, then do it now!
# if self.debuggingThread!=win32api.GetCurrentThreadId():
# return
# if self.debuggingThread!=win32api.GetCurrentThreadId():
# return

if len(self.breaks) or self.breakFlags:
if self.logicalbotframe:
Expand Down
Loading

0 comments on commit 623fb6a

Please sign in to comment.