diff --git a/AutoDuck/py2d.py b/AutoDuck/py2d.py index 7b3f641efe..7dda5d8d25 100644 --- a/AutoDuck/py2d.py +++ b/AutoDuck/py2d.py @@ -8,7 +8,6 @@ def ad_escape(s): Print = __builtins__.__dict__["print"] -long = int class DocInfo: diff --git a/Pythonwin/pywin/framework/stdin.py b/Pythonwin/pywin/framework/stdin.py index b08311083a..26c8895fd2 100644 --- a/Pythonwin/pywin/framework/stdin.py +++ b/Pythonwin/pywin/framework/stdin.py @@ -5,7 +5,7 @@ # any purpose. """Provides a class Stdin which can be used to emulate the regular old sys.stdin for the PythonWin interactive window. Right now it just pops -up a raw_input() dialog. With luck, someone will integrate it into the +up a input() dialog. With luck, someone will integrate it into the actual PythonWin interactive window someday. WARNING: Importing this file automatically replaces sys.stdin with an @@ -18,15 +18,12 @@ """ import sys -try: - get_input_line = raw_input # py2x -except NameError: - get_input_line = input # py3k +get_input_line = input class Stdin: def __init__(self): - self.real_file = sys.stdin # NOTE: Likely to be None in py3k + self.real_file = sys.stdin # NOTE: Likely to be None self.buffer = "" self.closed = False @@ -142,7 +139,7 @@ def readlines(self, *sizehint): Sell you soul to the devil, baby """ - def fake_raw_input(prompt=None): + def fake_input(prompt=None): """Replacement for raw_input() which pulls lines out of global test_input. For testing only! """ @@ -157,7 +154,7 @@ def fake_raw_input(prompt=None): raise EOFError() return result - get_input_line = fake_raw_input + get_input_line = fake_input # Some completely inadequate tests, just to make sure the code's not totally broken try: @@ -169,6 +166,6 @@ def fake_raw_input(prompt=None): print(x.readline(3)) print(x.readlines()) finally: - get_input_line = raw_input + get_input_line = input else: sys.stdin = Stdin() diff --git a/Pythonwin/pywin/idle/AutoIndent.py b/Pythonwin/pywin/idle/AutoIndent.py index c5adc5f866..0ed506e5ab 100644 --- a/Pythonwin/pywin/idle/AutoIndent.py +++ b/Pythonwin/pywin/idle/AutoIndent.py @@ -1,20 +1,9 @@ -import sys import tokenize from pywin import default_scintilla_encoding from . import PyParse -if sys.version_info < (3,): - # in py2k, tokenize() takes a 'token eater' callback, while - # generate_tokens is a generator that works with str objects. - token_generator = tokenize.generate_tokens -else: - # in py3k tokenize() is the generator working with 'byte' objects, and - # token_generator is the 'undocumented b/w compat' function that - # theoretically works with str objects - but actually seems to fail) - token_generator = tokenize.tokenize - class AutoIndent: menudefs = [ @@ -516,7 +505,7 @@ def readline(self): val = "" else: val = self.text.get(mark, mark + " lineend+1c") - # hrm - not sure this is correct in py3k - the source code may have + # hrm - not sure this is correct - the source code may have # an encoding declared, but the data will *always* be in # default_scintilla_encoding - so if anyone looks at the encoding decl # in the source they will be wrong. I think. Maybe. Or something... @@ -531,7 +520,7 @@ def run(self): tokenize.tabsize = self.tabwidth try: try: - for typ, token, start, end, line in token_generator(self.readline): + for typ, token, start, end, line in tokenize.tokenize(self.readline): if typ == NAME and token in OPENERS: self.blkopenline = line elif typ == INDENT and self.blkopenline: diff --git a/Pythonwin/pywin/mfc/activex.py b/Pythonwin/pywin/mfc/activex.py index 596bbef5e8..a9828e78dc 100644 --- a/Pythonwin/pywin/mfc/activex.py +++ b/Pythonwin/pywin/mfc/activex.py @@ -5,13 +5,6 @@ from . import window -# XXX - we are still "classic style" classes in py2x, so we need can't yet -# use 'type()' everywhere - revisit soon, as py2x will move to new-style too... -try: - from types import ClassType as new_type -except ImportError: - new_type = type # py3k - class Control(window.Wnd): """An ActiveX control base class. A new class must be derived from both @@ -78,7 +71,7 @@ def MakeControlClass(controlClass, name=None): """ if name is None: name = controlClass.__name__ - return new_type("OCX" + name, (Control, controlClass), {}) + return type("OCX" + name, (Control, controlClass), {}) def MakeControlInstance(controlClass, name=None): diff --git a/com/win32com/client/__init__.py b/com/win32com/client/__init__.py index 2a6b7d1c9a..3ce1120462 100644 --- a/com/win32com/client/__init__.py +++ b/com/win32com/client/__init__.py @@ -332,16 +332,10 @@ class object that derives from three classes: # If the clsid was an object, get the clsid clsid = disp_class.CLSID # Create a new class that derives from 3 classes - the dispatch class, the event sink class and the user class. - # XXX - we are still "classic style" classes in py2x, so we need can't yet - # use 'type()' everywhere - revisit soon, as py2x will move to new-style too... - try: - from types import ClassType as new_type - except ImportError: - new_type = type # py3k events_class = getevents(clsid) if events_class is None: raise ValueError("This COM object does not support events.") - result_class = new_type( + result_class = type( "COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__": _event_setattr_}, @@ -401,14 +395,10 @@ def WithEvents(disp, user_event_class): clsid = disp_class.CLSID # Create a new class that derives from 2 classes - the event sink # class and the user class. - try: - from types import ClassType as new_type - except ImportError: - new_type = type # py3k events_class = getevents(clsid) if events_class is None: raise ValueError("This COM object does not support events.") - result_class = new_type("COMEventClass", (events_class, user_event_class), {}) + result_class = type("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. if hasattr(user_event_class, "__init__"): user_event_class.__init__(instance) diff --git a/com/win32com/client/genpy.py b/com/win32com/client/genpy.py index 8cda87debd..a494815244 100644 --- a/com/win32com/client/genpy.py +++ b/com/win32com/client/genpy.py @@ -34,22 +34,22 @@ # does not use this map at runtime - all Alias/Enum have already # been translated. mapVTToTypeString = { - pythoncom.VT_I2: "types.IntType", - pythoncom.VT_I4: "types.IntType", - pythoncom.VT_R4: "types.FloatType", - pythoncom.VT_R8: "types.FloatType", - pythoncom.VT_BSTR: "types.StringType", - pythoncom.VT_BOOL: "types.IntType", - pythoncom.VT_VARIANT: "types.TypeType", - pythoncom.VT_I1: "types.IntType", - pythoncom.VT_UI1: "types.IntType", - pythoncom.VT_UI2: "types.IntType", - pythoncom.VT_UI4: "types.IntType", - pythoncom.VT_I8: "types.LongType", - pythoncom.VT_UI8: "types.LongType", - pythoncom.VT_INT: "types.IntType", - pythoncom.VT_DATE: "pythoncom.PyTimeType", - pythoncom.VT_UINT: "types.IntType", + pythoncom.VT_I2: "int", + pythoncom.VT_I4: "int", + pythoncom.VT_R4: "float", + pythoncom.VT_R8: "float", + pythoncom.VT_BSTR: "str", + pythoncom.VT_BOOL: "int", + pythoncom.VT_VARIANT: "type", + pythoncom.VT_I1: "int", + pythoncom.VT_UI1: "int", + pythoncom.VT_UI2: "int", + pythoncom.VT_UI4: "int", + pythoncom.VT_I8: "int", + pythoncom.VT_UI8: "int", + pythoncom.VT_INT: "int", + pythoncom.VT_DATE: "datetime.date", + pythoncom.VT_UINT: "int", } diff --git a/com/win32com/test/testPyComTest.py b/com/win32com/test/testPyComTest.py index e7b065b239..59b601bc67 100644 --- a/com/win32com/test/testPyComTest.py +++ b/com/win32com/test/testPyComTest.py @@ -16,7 +16,6 @@ import win32com.client.connect import win32timezone import winerror -from pywin32_testutil import str2memory from win32com.client import VARIANT, CastTo, DispatchBaseClass, constants from win32com.test.util import CheckClean, RegisterPythonServer @@ -264,7 +263,7 @@ def TestCommon(o, is_generated): ) # and binary - TestApplyResult(o.SetBinSafeArray, (str2memory("foo\0bar"),), 7) + TestApplyResult(o.SetBinSafeArray, (memoryview(b"foo\0bar"),), 7) progress("Checking properties") o.LongProp = 3 diff --git a/com/win32com/test/testShell.py b/com/win32com/test/testShell.py index d6a164caa2..3d1b51b892 100644 --- a/com/win32com/test/testShell.py +++ b/com/win32com/test/testShell.py @@ -3,17 +3,11 @@ import struct import sys -import win32timezone - -try: - sys_maxsize = sys.maxsize # 2.6 and later - maxsize != maxint on 64bits -except AttributeError: - sys_maxsize = sys.maxint - import pythoncom import pywintypes import win32com.test.util import win32con +import win32timezone from win32com.shell import shell from win32com.shell.shellcon import * from win32com.storagecon import * @@ -168,7 +162,7 @@ def testComplex(self): ftCreationTime=ctime, ftLastAccessTime=atime, ftLastWriteTime=wtime, - nFileSize=sys_maxsize + 1, + nFileSize=sys.maxsize + 1, ) self._testRT(d) @@ -184,7 +178,7 @@ def testUnicode(self): ftCreationTime=ctime, ftLastAccessTime=atime, ftLastWriteTime=wtime, - nFileSize=sys_maxsize + 1, + nFileSize=sys.maxsize + 1, ), dict( cFileName="foo2.txt", @@ -194,7 +188,7 @@ def testUnicode(self): ftCreationTime=ctime, ftLastAccessTime=atime, ftLastWriteTime=wtime, - nFileSize=sys_maxsize + 1, + nFileSize=sys.maxsize + 1, ), dict( cFileName="foo\xa9.txt", @@ -204,7 +198,7 @@ def testUnicode(self): ftCreationTime=ctime, ftLastAccessTime=atime, ftLastWriteTime=wtime, - nFileSize=sys_maxsize + 1, + nFileSize=sys.maxsize + 1, ), ] s = shell.FILEGROUPDESCRIPTORAsString(d, 1) diff --git a/com/win32com/test/testvb.py b/com/win32com/test/testvb.py index 369bdca859..6c6dad6ba9 100644 --- a/com/win32com/test/testvb.py +++ b/com/win32com/test/testvb.py @@ -11,7 +11,6 @@ import win32com.client.dynamic import win32com.client.gencache import winerror -from pywin32_testutil import str2memory from win32com.server.util import NewCollection, wrap from win32com.test import util @@ -86,8 +85,8 @@ def TestVB(vbtest, bUseGenerated): vbtest.VariantProperty = 10 if vbtest.VariantProperty != 10: raise error("Could not set the variant integer property correctly.") - vbtest.VariantProperty = str2memory("raw\0data") - if vbtest.VariantProperty != str2memory("raw\0data"): + vbtest.VariantProperty = memoryview(b"raw\0data") + if vbtest.VariantProperty != memoryview(b"raw\0data"): raise error("Could not set the variant buffer property correctly.") vbtest.StringProperty = "Hello from Python" if vbtest.StringProperty != "Hello from Python": diff --git a/com/win32comext/mapi/mapiutil.py b/com/win32comext/mapi/mapiutil.py index 8a5ffb6323..b0f20dc882 100644 --- a/com/win32comext/mapi/mapiutil.py +++ b/com/win32comext/mapi/mapiutil.py @@ -1,8 +1,5 @@ # General utilities for MAPI and MAPI objects. # We used to use these old names from the 'types' module... -TupleType = tuple -ListType = list -IntType = int import pythoncom from pywintypes import TimeType @@ -103,13 +100,13 @@ def GetProperties(obj, propList): If the property fetch fails, the result is None. """ bRetList = 1 - if not isinstance(propList, (TupleType, ListType)): + if not isinstance(propList, (tuple, list)): bRetList = 0 propList = (propList,) realPropList = [] rc = [] for prop in propList: - if not isinstance(prop, IntType): # Integer + if not isinstance(prop, int): props = ((mapi.PS_PUBLIC_STRINGS, prop),) propIds = obj.GetIDsFromNames(props, 0) prop = mapitags.PROP_TAG( @@ -145,19 +142,17 @@ def GetAllProperties(obj, make_tag_names=True): _MapiTypeMap = { - type(0.0): mapitags.PT_DOUBLE, - type(0): mapitags.PT_I4, - type(b""): mapitags.PT_STRING8, # bytes - type(""): mapitags.PT_UNICODE, # str + float: mapitags.PT_DOUBLE, + int: mapitags.PT_I4, + bytes: mapitags.PT_STRING8, + str: mapitags.PT_UNICODE, type(None): mapitags.PT_UNSPECIFIED, - # In Python 2.2.2, bool isn't a distinct type (type(1==1) is type(0)). - # (markh thinks the above is trying to say that in 2020, we probably *do* - # want bool in this map? :) + bool: mapitags.PT_BOOLEAN, } def SetPropertyValue(obj, prop, val): - if not isinstance(prop, IntType): + if not isinstance(prop, int): props = ((mapi.PS_PUBLIC_STRINGS, prop),) propIds = obj.GetIDsFromNames(props, mapi.MAPI_CREATE) if val == (1 == 1) or val == (1 == 0): diff --git a/isapi/samples/redirector.py b/isapi/samples/redirector.py index 40698bb2c0..da62d40228 100644 --- a/isapi/samples/redirector.py +++ b/isapi/samples/redirector.py @@ -17,17 +17,12 @@ # any excludes. import sys - -from isapi import isapicon, threaded_extension - -try: - from urllib.request import urlopen -except ImportError: - # py3k spelling... - from urllib.request import urlopen +from urllib.request import urlopen import win32api +from isapi import isapicon, threaded_extension + # sys.isapidllhandle will exist when we are loaded by the IIS framework. # In this case we redirect our output to the win32traceutil collector. if hasattr(sys, "isapidllhandle"): @@ -84,15 +79,11 @@ def Dispatch(self, ecb): print("Opening %s" % new_url) fp = urlopen(new_url) headers = fp.info() - # subtle py3k breakage: in py3k, str(headers) has normalized \r\n - # back to \n and also stuck an extra \n term. py2k leaves the - # \r\n from the server in tact and finishes with a single term. - if sys.version_info < (3, 0): - header_text = str(headers) + "\r\n" - else: - # take *all* trailing \n off, replace remaining with - # \r\n, then add the 2 trailing \r\n. - header_text = str(headers).rstrip("\n").replace("\n", "\r\n") + "\r\n\r\n" + # subtle breakage: str(headers) normalizes \r\n + # back to \n and also sticks an extra \n term. + # take *all* trailing \n off, replace remaining with + # \r\n, then add the 2 trailing \r\n. + header_text = str(headers).rstrip("\n").replace("\n", "\r\n") + "\r\n\r\n" ecb.SendResponseHeaders("200 OK", header_text, False) ecb.WriteClient(fp.read()) ecb.DoneWithSession() diff --git a/win32/Demos/BackupRead_BackupWrite.py b/win32/Demos/BackupRead_BackupWrite.py index 1f88af8fd6..02aae91038 100644 --- a/win32/Demos/BackupRead_BackupWrite.py +++ b/win32/Demos/BackupRead_BackupWrite.py @@ -8,7 +8,6 @@ import win32con import win32file import win32security -from pywin32_testutil import ob2memory from win32com import storagecon all_sd_info = ( @@ -115,7 +114,7 @@ open(tempfile + ":anotherstream").read() == open(outfile + ":anotherstream").read() ), "anotherstream contents differ !" assert ( - ob2memory(win32security.GetFileSecurity(tempfile, all_sd_info))[:] - == ob2memory(win32security.GetFileSecurity(outfile, all_sd_info))[:] + memoryview(win32security.GetFileSecurity(tempfile, all_sd_info))[:] + == memoryview(win32security.GetFileSecurity(outfile, all_sd_info))[:] ), "Security descriptors are different !" ## also should check Summary Info programatically diff --git a/win32/Lib/netbios.py b/win32/Lib/netbios.py index c2e6638682..3f80b6b62c 100644 --- a/win32/Lib/netbios.py +++ b/win32/Lib/netbios.py @@ -1,5 +1,4 @@ import struct -import sys import win32wnet @@ -266,14 +265,6 @@ def ACTION_HEADER(): return NCBStruct(ACTION_HEADER_ITEMS) -def byte_to_int(b): - """Given an element in a binary buffer, return its integer value""" - if sys.version_info >= (3, 0): - # a byte is already an int in py3k - return b - return ord(b) # its a char from a string in py2k. - - if __name__ == "__main__": # code ported from "HOWTO: Get the MAC Address for an Ethernet Adapter" # MS KB ID: Q118623 @@ -287,18 +278,18 @@ def byte_to_int(b): for i in range(la_enum.length): ncb.Reset() ncb.Command = NCBRESET - ncb.Lana_num = byte_to_int(la_enum.lana[i]) + ncb.Lana_num = la_enum.lana[i] rc = Netbios(ncb) if rc != 0: raise RuntimeError("Unexpected result %d" % (rc,)) ncb.Reset() ncb.Command = NCBASTAT - ncb.Lana_num = byte_to_int(la_enum.lana[i]) + ncb.Lana_num = la_enum.lana[i] ncb.Callname = b"* " adapter = ADAPTER_STATUS() ncb.Buffer = adapter Netbios(ncb) print("Adapter address:", end=" ") for ch in adapter.adapter_address: - print("%02x" % (byte_to_int(ch),), end=" ") + print("%02x" % (ch,), end=" ") print() diff --git a/win32/Lib/pywin32_testutil.py b/win32/Lib/pywin32_testutil.py index 42d41f3ecf..63cd87ea21 100644 --- a/win32/Lib/pywin32_testutil.py +++ b/win32/Lib/pywin32_testutil.py @@ -7,28 +7,6 @@ import winerror -## -## General purpose utilities for the test suite. -## - - -# Sometimes we want to pass a string that should explicitly be treated as -# a memory blob. -def str2memory(sval): - if sys.version_info < (3, 0): - return buffer(sval) - # py3k. - return memoryview(sval.encode("latin1")) - - -# Sometimes we want to pass an object that exposes its memory -def ob2memory(ob): - if sys.version_info < (3, 0): - return buffer(ob) - # py3k. - return memoryview(ob) - - ## ## unittest related stuff ## diff --git a/win32/Lib/win32gui_struct.py b/win32/Lib/win32gui_struct.py index 86623ae323..288fed6bf4 100644 --- a/win32/Lib/win32gui_struct.py +++ b/win32/Lib/win32gui_struct.py @@ -30,28 +30,21 @@ import array import struct import sys +from collections import namedtuple import commctrl import pywintypes import win32con import win32gui -is64bit = "64 bit" in sys.version - -try: - from collections import namedtuple - - def _MakeResult(names_str, values): - names = names_str.split() - nt = namedtuple(names[0], names[1:]) - return nt(*values) -except ImportError: - # no namedtuple support - just return the values as a normal tuple. - def _MakeResult(names_str, values): - return values +def _MakeResult(names_str, values): + names = names_str.split() + nt = namedtuple(names[0], names[1:]) + return nt(*values) +is64bit = "64 bit" in sys.version _nmhdr_fmt = "PPi" if is64bit: # When the item past the NMHDR gets aligned (eg, when it is a struct) @@ -87,23 +80,6 @@ def _make_empty_text_buffer(cch): return _make_text_buffer("\0" * cch) -if sys.version_info < (3, 0): - - def _make_memory(ob): - return str(buffer(ob)) - - def _make_bytes(sval): - return sval - -else: - - def _make_memory(ob): - return bytes(memoryview(ob)) - - def _make_bytes(sval): - return sval.encode("ascii") - - # Generic WM_NOTIFY unpacking def UnpackWMNOTIFY(lparam): format = "PPi" @@ -898,11 +874,11 @@ def PackHDITEM( # Generic function for packing a DEV_BROADCAST_* structure - generally used # by the other PackDEV_BROADCAST_* functions in this module. -def PackDEV_BROADCAST(devicetype, rest_fmt, rest_data, extra_data=_make_bytes("")): +def PackDEV_BROADCAST(devicetype, rest_fmt, rest_data, extra_data=b""): # It seems a requirement is 4 byte alignment, even for the 'BYTE data[1]' # field (eg, that would make DEV_BROADCAST_HANDLE 41 bytes, but we must # be 44. - extra_data += _make_bytes("\0" * (4 - len(extra_data) % 4)) + extra_data += b"\0" * (4 - len(extra_data) % 4) format = "iii" + rest_fmt full_size = struct.calcsize(format) + len(extra_data) data = (full_size, devicetype, 0) + rest_data @@ -912,14 +888,14 @@ def PackDEV_BROADCAST(devicetype, rest_fmt, rest_data, extra_data=_make_bytes("" def PackDEV_BROADCAST_HANDLE( handle, hdevnotify=0, - guid=_make_bytes("\0" * 16), + guid=b"\0" * 16, name_offset=0, - data=_make_bytes("\0"), + data=b"\0", ): return PackDEV_BROADCAST( win32con.DBT_DEVTYP_HANDLE, "PP16sl", - (int(handle), int(hdevnotify), _make_memory(guid), name_offset), + (int(handle), int(hdevnotify), bytes(memoryview(guid)), name_offset), data, ) @@ -941,8 +917,8 @@ def PackDEV_BROADCAST_DEVICEINTERFACE(classguid, name=""): # 16 bytes for the IID followed by \0 term'd string. rest_fmt = "16s%ds" % len(name) - # _make_memory(iid) hoops necessary to get the raw IID bytes. - rest_data = (_make_memory(pywintypes.IID(classguid)), name) + # bytes(memoryview(iid)) hoops necessary to get the raw IID bytes. + rest_data = (bytes(memoryview(pywintypes.IID(classguid))), name) return PackDEV_BROADCAST(win32con.DBT_DEVTYP_DEVICEINTERFACE, rest_fmt, rest_data) diff --git a/win32/test/handles.py b/win32/test/handles.py index 98b73625db..b1f2240ba3 100644 --- a/win32/test/handles.py +++ b/win32/test/handles.py @@ -138,17 +138,13 @@ def testHandleNonZero(self): self.assertTrue(h) def testLong(self): - # sys.maxint+1 should always be a 'valid' handle, treated as an + # sys.maxsize+1 should always be a 'valid' handle, treated as an # unsigned int, even though it is a long. Although pywin32 should not # directly create such longs, using struct.unpack() with a P format # may well return them. eg: # >>> struct.unpack("P", struct.pack("P", -1)) # (4294967295L,) - try: - big = sys.maxsize - except AttributeError: - big = sys.maxint - pywintypes.HANDLE(big + 1) + pywintypes.HANDLE(sys.maxsize + 1) def testGC(self): # This used to provoke: diff --git a/win32/test/test_odbc.py b/win32/test/test_odbc.py index 808ebfce11..8cba6310f3 100644 --- a/win32/test/test_odbc.py +++ b/win32/test/test_odbc.py @@ -6,7 +6,7 @@ import odbc import pythoncom -from pywin32_testutil import TestSkipped, str2memory +from pywin32_testutil import TestSkipped from win32com.client import constants # We use the DAO ODBC driver @@ -185,11 +185,7 @@ def testBit(self): def testInt(self): self._test_val("intfield", 1) self._test_val("intfield", 0) - try: - big = sys.maxsize - except AttributeError: - big = sys.maxint - self._test_val("intfield", big) + self._test_val("intfield", sys.maxsize) def testFloat(self): self._test_val("floatfield", 1.01) @@ -206,11 +202,11 @@ def testLongVarchar(self): def testLongBinary(self): """Test a long raw field in excess of internal cursor data size (65536)""" - self._test_val("longbinaryfield", str2memory("\0\1\2" * 70000)) + self._test_val("longbinaryfield", memoryview(b"\0\1\2" * 70000)) def testRaw(self): ## Test binary data - self._test_val("rawfield", str2memory("\1\2\3\4\0\5\6\7\8")) + self._test_val("rawfield", memoryview(b"\1\2\3\4\0\5\6\7\8")) def test_widechar(self): """Test a unicode character that would be mangled if bound as plain character. diff --git a/win32/test/test_pywintypes.py b/win32/test/test_pywintypes.py index 1f9cd9e7df..35962be32c 100644 --- a/win32/test/test_pywintypes.py +++ b/win32/test/test_pywintypes.py @@ -5,7 +5,6 @@ import unittest import pywintypes -from pywin32_testutil import ob2memory class TestCase(unittest.TestCase): @@ -85,7 +84,7 @@ def testPyTimeTooLarge(self): def testGUID(self): s = "{00020400-0000-0000-C000-000000000046}" iid = pywintypes.IID(s) - iid2 = pywintypes.IID(ob2memory(iid), True) + iid2 = pywintypes.IID(memoryview(iid), True) self.assertEqual(iid, iid2) self.assertRaises(ValueError, pywintypes.IID, b"00", True) # too short self.assertRaises(TypeError, pywintypes.IID, 0, True) # no buffer diff --git a/win32/test/test_security.py b/win32/test/test_security.py index dc80fb4295..52be9f328c 100644 --- a/win32/test/test_security.py +++ b/win32/test/test_security.py @@ -7,7 +7,7 @@ import win32con import win32security import winerror -from pywin32_testutil import TestSkipped, ob2memory, testmain +from pywin32_testutil import TestSkipped, testmain class SecurityTests(unittest.TestCase): @@ -53,8 +53,8 @@ def testBuffer(self): if self.admin_sid is None: raise TestSkipped("No 'Administrator' account is available") self.assertEqual( - ob2memory(win32security.LookupAccountName("", "Administrator")[0]), - ob2memory(win32security.LookupAccountName("", "Administrator")[0]), + memoryview(win32security.LookupAccountName("", "Administrator")[0]), + memoryview(win32security.LookupAccountName("", "Administrator")[0]), ) def testMemory(self): diff --git a/win32/test/test_win32file.py b/win32/test/test_win32file.py index 3784bfed14..c57e94ad5b 100644 --- a/win32/test/test_win32file.py +++ b/win32/test/test_win32file.py @@ -19,11 +19,6 @@ import winerror from pywin32_testutil import TestSkipped, testmain -try: - set -except NameError: - from sets import Set as set - class TestReadBuffer(unittest.TestCase): def testLen(self): diff --git a/win32/test/test_win32wnet.py b/win32/test/test_win32wnet.py index 11769fc926..da8e99a9a5 100644 --- a/win32/test/test_win32wnet.py +++ b/win32/test/test_win32wnet.py @@ -107,12 +107,12 @@ def testNetbios(self): for i in range(la_enum.length): ncb.Reset() ncb.Command = netbios.NCBRESET - ncb.Lana_num = netbios.byte_to_int(la_enum.lana[i]) + ncb.Lana_num = la_enum.lana[i] rc = Netbios(ncb) self.assertEqual(rc, 0) ncb.Reset() ncb.Command = netbios.NCBASTAT - ncb.Lana_num = byte_to_int(la_enum.lana[i]) + ncb.Lana_num = la_enum.lana[i] ncb.Callname = b"* " adapter = netbios.ADAPTER_STATUS() ncb.Buffer = adapter