Skip to content

Commit

Permalink
Fix plenty of undefined names
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 10, 2023
1 parent ba9e475 commit 1f0f8b5
Show file tree
Hide file tree
Showing 31 changed files with 56 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Pythonwin/pywin/Demos/fontdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def SetFont(self, new_font):
# Change font on the fly
self.font = win32ui.CreateFont(new_font)
# redraw the entire client window
selfInvalidateRect(None)
self.InvalidateRect(None)

def OnSize(self, params):
lParam = params[3]
Expand Down
6 changes: 0 additions & 6 deletions Pythonwin/pywin/debugger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import sys


# Some cruft to deal with the Pythonwin GUI booting up from a non GUI app.
def _MakeDebuggerGUI():
app.InitInstance()


isInprocApp = -1


Expand Down
4 changes: 3 additions & 1 deletion Pythonwin/pywin/framework/dlgappcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ def OnInitDialog(self):
def OnPaint(self):
if not self.IsIconic():
return self._obj_.OnPaint()
dc, paintStruct = self.BeginPaint()
self.DefWindowProc(win32con.WM_ICONERASEBKGND, dc.GetHandleOutput(), 0)
left, top, right, bottom = self.GetClientRect()
left = (right - win32api.GetSystemMetrics(win32con.SM_CXICON)) >> 1
top = (bottom - win32api.GetSystemMetrics(win32con.SM_CYICON)) >> 1
hIcon = win32ui.GetApp().LoadIcon(self.iconId)
self.GetDC().DrawIcon((left, top), hIcon)
dc.DrawIcon((left, top), hIcon)
self.EndPaint(paintStruct)

# Only needed to provide a minimized icon (and this seems
# less important under win95/NT4
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 @@ -332,7 +332,7 @@ def Init(self):
% (win32ui.copyright,)
)
else:
sys.stderr.write(banner)
sys.stderr.write(self.banner)
rcfile = os.environ.get("PYTHONSTARTUP")
if rcfile:
import __main__
Expand Down
1 change: 1 addition & 0 deletions Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import re
import sys
import time
from functools import reduce

import win32api
import win32con
Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/scintilla/configui.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def OnOK(self):


def test():
page = ColorEditorPropertyPage()
sheet = pywin.mfc.dialog.PropertySheet("Test")
page = ScintillaFormatPropertyPage()
sheet = dialog.PropertySheet("Test")
sheet.AddPage(page)
sheet.CreateWindow()
10 changes: 5 additions & 5 deletions Pythonwin/pywin/tools/TraceCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def _StopThread(self):
def Close(self):
self._StopThread()
winout.WindowOutput.Close(self)
# def OnViewDestroy(self, frame):
# return winout.WindowOutput.OnViewDestroy(self, frame)
# def Create(self, title=None, style = None):
# rc = winout.WindowOutput.Create(self, title, style)
return rc
# def OnViewDestroy(self, frame):
# return winout.WindowOutput.OnViewDestroy(self, frame)
# def Create(self, title=None, style = None):
# rc = winout.WindowOutput.Create(self, title, style)
# return rc


def MakeOutputWindow():
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3>VARIANT objects</h3>
Up until build 212, code could set <code>pythoncom.__future_currency__ = True</code>
to force use of the decimal module, with a warning issued otherwise. In
builds 213 and later, the decimal module is unconditionally used when
pythoncon returns you a currency value.
pythoncom returns you a currency value.
</p>

<h3>Recent Changes</h3>
Expand Down
3 changes: 2 additions & 1 deletion com/win32com/server/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from sys import exc_info

import pythoncom
import pywin.debugger
import pywin.debugger.dbgcon
import win32api
import win32com
from win32com.server.exception import IsCOMServerException
Expand Down Expand Up @@ -255,7 +257,6 @@ def _HandleException_(self):
"""Invoke the debugger post mortem capability"""
# Save details away.
typ, val, tb = exc_info()
# import pywin.debugger, pywin.debugger.dbgcon
debug = 0
try:
raise typ(val)
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/server/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def IsCOMException(t=None):
try:
return issubclass(t, pythoncom.com_error)
except TypeError: # 1.5 in -X mode?
return t is pythoncon.com_error
return t is pythoncom.com_error


def IsCOMServerException(t=None):
Expand Down
1 change: 1 addition & 0 deletions com/win32com/test/daodump.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# import dao3032
# No longer imported here - callers responsibility to load
#
import pythoncom
import win32com.client


Expand Down
3 changes: 1 addition & 2 deletions com/win32com/test/testClipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def QueryGetData(self, fe):
return None # should check better

def GetCanonicalFormatEtc(self, fe):
RaiseCOMException(winerror.DATA_S_SAMEFORMATETC)
# return fe
raise COMException(winerror.DATA_S_SAMEFORMATETC)

def SetData(self, fe, medium):
raise COMException(hresult=winerror.E_NOTIMPL)
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testGatewayAddresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Dummy2:
]


class DeletgatedDummy:
class DelegatedDummy:
_public_methods_ = []


Expand Down
1 change: 1 addition & 0 deletions com/win32com/test/testvb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#

import traceback
from collections.abc import Callable

import pythoncom
import win32com.client
Expand Down
1 change: 1 addition & 0 deletions com/win32comext/adsi/demos/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import string
import sys
from collections.abc import Callable

import pythoncom
import win32api
Expand Down
13 changes: 7 additions & 6 deletions com/win32comext/axdebug/Test/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import traceback

import pythoncom
import ttest
import win32api
import win32com.server.util
import winerror
Expand Down Expand Up @@ -97,12 +98,12 @@ def GetPathName(self):
try:
return win32api.GetFullPathName(self.module.__file__), 1
except (AttributeError, win32api.error):
raise Exception(scode == E_FAIL)
raise Exception(scode=winerror.E_FAIL)

def GetFileName(self):
# Result is a string with just the name of the document, no path information.
trace("GetFileName")
return os.path.split(module.__file__)
return os.path.split(self.module.__file__)

def NotifyChanged():
trace("NotifyChanged")
Expand Down Expand Up @@ -171,15 +172,15 @@ def TestSmartProvider():

def test():
try:
# app = TestSmartHelper()
# app = TestSmartHelper()
app = TestSmartProvider()
# app = testdumb()
# app = testdumb()
except:
traceback.print_exc()


# _wrap_remove(externalConnectionManager)
# wrappedExternalConnectionManager = None
# _wrap_remove(externalConnectionManager)
# wrappedExternalConnectionManager = None

if __name__ == "__main__":
test()
Expand Down
1 change: 1 addition & 0 deletions com/win32comext/axdebug/codecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
to color the text, and also how to translate lines into offsets, and back.
"""

import os
import sys
import tokenize

Expand Down
4 changes: 2 additions & 2 deletions com/win32comext/axdebug/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def GetPropertyInfo(self, dwFieldSpec, nRadix):
dwFieldSpec,
nRadix,
self.hresult,
dictionary,
stackFrame,
self.dictionary,
self.stackFrame,
)

def GetExtendedInfo(self): ### Note - not in the framework.
Expand Down
14 changes: 8 additions & 6 deletions com/win32comext/axscript/client/pydumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# as a scripting language - meaning the dumps produced can be quite dynamic,
# and based on the script code you execute.

import sys

import win32api
import win32con
from win32com.axscript import axscript

from . import pyscript
Expand All @@ -34,8 +38,6 @@ class PyScript(pyscript.PyScript):


def Register():
import sys

if "-d" in sys.argv:
dispatcher = "DispatcherWin32trace"
debug_desc = " (" + dispatcher + ")"
Expand All @@ -51,7 +53,7 @@ def Register():
policy = None # "win32com.axscript.client.axspolicy.AXScriptPolicy"

print("Registering COM server%s..." % debug_desc)
from win32com.server.register import RegisterServer
from win32com.server.register import RegisterServer, _set_string

languageName = "PyDump"
verProgId = "Python.Dumper.1"
Expand All @@ -66,10 +68,10 @@ def Register():
dispatcher=dispatcher,
)

CreateRegKey(languageName + "\\OLEScript")
win32api.RegCreateKey(win32con.HKEY_CLASSES_ROOT, languageName + "\\OLEScript")
# Basic Registration for wsh.
win32com.server.register._set_string(".pysDump", "pysDumpFile")
win32com.server.register._set_string("pysDumpFile\\ScriptEngine", languageName)
_set_string(".pysDump", "pysDumpFile")
_set_string("pysDumpFile\\ScriptEngine", languageName)
print("Dumping Server registered.")


Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/shell/demos/servers/context_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags):
elif uFlags & shellcon.CMF_EXPLORE:
print("CMF_EXPLORE...")
items.append(msg + " - normal file, right-click in Explorer")
elif uFlags & CMF_DEFAULTONLY:
elif uFlags & shellcon.CMF_DEFAULTONLY:
print("CMF_DEFAULTONLY...\r\n")
else:
print("** unknown flags", uFlags)
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/shell/demos/servers/shell_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ def CreateViewWindow(self, prev, settings, browser, rect):
}
# win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

file_data = file(self.filename, "U").read()
file_data = open(self.filename, "U").read()

self._SetupLexer()
self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
Expand Down
4 changes: 2 additions & 2 deletions isapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def GetWebServer(description=None):
def LoadWebServer(path):
try:
server = GetObject(path)
except pythoncom.com_error as details:
msg = details.strerror
except pythoncom.com_error as exc:
msg = exc.strerror
if exc.excepinfo and exc.excepinfo[2]:
msg = exc.excepinfo[2]
msg = "WebServer %s: %s" % (path, msg)
Expand Down
1 change: 1 addition & 0 deletions pywin32_postinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# copies PyWinTypesxx.dll and PythonCOMxx.dll into the system directory,
# and creates a pth file
import argparse
import glob
import os
import shutil
Expand Down
1 change: 0 additions & 1 deletion win32/Lib/win32rcparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def Parse(rc_name, h_name=None):
if h_file is not None:
h_file.close()
rc_file.close()
return rcp


def GenerateFrozenResource(rc_name, output_name, h_name=None):
Expand Down
4 changes: 2 additions & 2 deletions win32/Lib/winnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,11 +905,11 @@ def DECREF(x):
IMAGE_ORDINAL_FLAG = -2147483648


def IMAGE_SNAP_BY_ORDINAL(Ordina):
def IMAGE_SNAP_BY_ORDINAL(Ordinal):
return (Ordinal & IMAGE_ORDINAL_FLAG) != 0


def IMAGE_ORDINAL(Ordina):
def IMAGE_ORDINAL(Ordinal):
return Ordinal & 65535


Expand Down
7 changes: 3 additions & 4 deletions win32/scripts/VersionStamp/BrandProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Brand a VSS project with a "build number", then optionally
# stamp DLL/EXE files with version information.

import getopt
import os
import string
import sys
Expand Down Expand Up @@ -33,7 +34,7 @@ def BrandProject(

bulkstamp.scan(build, stampPath, descFile)
for infile, outfile in filesToSubstitute:
SubstituteVSSInFile(vssProjectName, infile, outfile)
vssutil.SubstituteVSSInFile(vssProjectName, infile, outfile)
return 1


Expand Down Expand Up @@ -65,10 +66,8 @@ def usage(msg):

if __name__ == "__main__":
try:
import getopt

opts, args = getopt.getopt(sys.argv[1:], "af:d:r")
except getopts.error as msg:
except getopt.error as msg:
usage(msg)
bAuto = bRebrand = 0
stampFiles = []
Expand Down
2 changes: 1 addition & 1 deletion win32/scripts/backupEventLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def BackupClearLog(logType):
# OK - have unique file name.
try:
hlog = win32evtlog.OpenEventLog(None, logType)
except win32evtlogutil.error as details:
except win32evtlog.error as details:
print("Could not open the event log", details)
return
try:
Expand Down
1 change: 1 addition & 0 deletions win32/scripts/ce/pysynch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import string
import sys
from collections.abc import Callable

import win32api
import win32con
Expand Down
1 change: 1 addition & 0 deletions win32/scripts/rasutil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# A demo of using the RAS API from Python
import sys

import win32api
import win32ras


Expand Down
1 change: 1 addition & 0 deletions win32/test/test_win32api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys
import tempfile
import time
import unittest

import win32api
Expand Down
Loading

0 comments on commit 1f0f8b5

Please sign in to comment.