Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete and broken unicode compatibility in pywintypes #2200

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions com/win32com/test/testMSOffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import win32api
import win32com
import win32com.client.dynamic
from pywintypes import Unicode
from win32com.client import gencache
from win32com.test.util import CheckClean

Expand Down Expand Up @@ -112,7 +111,7 @@ def TextExcel(xl):
if not xl.Visible:
raise error("Visible property not true.")

if int(xl.Version[0]) >= 8:
if int(xl.Version.split(".")[0]) >= 8:
xl.Workbooks.Add()
else:
xl.Workbooks().Add()
Expand All @@ -127,24 +126,24 @@ def TextExcel(xl):
if xl.Range("A1").Value != "Hi 0":
raise error("Single cell range failed")

if xl.Range("A1:B1").Value != ((Unicode("Hi 0"), 2),):
if xl.Range("A1:B1").Value != (("Hi 0", 2),):
raise error("flat-horizontal cell range failed")

if xl.Range("A1:A2").Value != ((Unicode("Hi 0"),), (Unicode("x"),)):
if xl.Range("A1:A2").Value != (("Hi 0",), ("x",)):
raise error("flat-vertical cell range failed")

if xl.Range("A1:C3").Value != (
(Unicode("Hi 0"), 2, 3),
(Unicode("x"), Unicode("Hi 1"), Unicode("z")),
(3, 2, Unicode("Hi 2")),
("Hi 0", 2, 3),
("x", "Hi 1", "z"),
(3, 2, "Hi 2"),
):
raise error("square cell range failed")

xl.Range("A1:C3").Value = ((3, 2, 1), ("x", "y", "z"), (1, 2, 3))

if xl.Range("A1:C3").Value != (
(3, 2, 1),
(Unicode("x"), Unicode("y"), Unicode("z")),
("x", "y", "z"),
(1, 2, 3),
):
raise error("Range was not what I set it to!")
Expand Down
2 changes: 0 additions & 2 deletions win32/Lib/win32serviceutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ def ControlService(serviceName, code, machine=None):


def __FindSvcDeps(findName):
if isinstance(findName, pywintypes.UnicodeType):
findName = str(findName)
dict = {}
k = win32api.RegOpenKey(
win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services"
Expand Down
15 changes: 0 additions & 15 deletions win32/src/PyWinTypesmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,6 @@ PyObject *PyWin_SetBasicCOMError(HRESULT hr)
return NULL;
}

// @pymethod string|pywintypes|Unicode|Creates a new Unicode object
PYWINTYPES_EXPORT PyObject *PyWin_NewUnicode(PyObject *self, PyObject *args)
{
char *string;
int slen;
if (!PyArg_ParseTuple(args, "t#", &string, &slen))
return NULL;
return PyUnicode_DecodeMBCS(string, slen, NULL);
}

// @pymethod string|pywintypes|UnicodeFromRaw|Creates a new Unicode object from raw binary data
static PyObject *PyWin_NewUnicodeFromRaw(PyObject *self, PyObject *args)
{
Expand Down Expand Up @@ -760,7 +750,6 @@ static struct PyMethodDef pywintypes_functions[] = {
{"DosDateTimeToTime", PyWin_DosDateTimeToTime,
1}, // @pymeth DosDateTimeToTime|Converts an MS-DOS Date/Time to a standard Time object
#endif
{"Unicode", PyWin_NewUnicode, 1}, // @pymeth Unicode|Creates a new string object
{"UnicodeFromRaw", PyWin_NewUnicodeFromRaw,
1}, // @pymeth UnicodeFromRaw|Creates a new string object from raw binary data
{"IsTextUnicode", PyWin_IsTextUnicode,
Expand Down Expand Up @@ -960,10 +949,6 @@ PYWIN_MODULE_INIT_FUNC(pywintypes)
PYWIN_MODULE_INIT_RETURN_ERROR;
ADD_CONSTANT(WAVE_FORMAT_PCM);

// Add a few types.
if (PyDict_SetItemString(dict, "UnicodeType", (PyObject *)&PyUnicode_Type) == -1)
PYWIN_MODULE_INIT_RETURN_ERROR;

if (!_PyWinDateTime_PrepareModuleDict(dict))
PYWIN_MODULE_INIT_RETURN_ERROR;
#ifndef NO_PYWINTYPES_IID
Expand Down
4 changes: 0 additions & 4 deletions win32/src/win32apimodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5177,9 +5177,6 @@ PyObject *PyEnumResourceLanguages(PyObject *self, PyObject *args)
return ret;
}

// @pymethod <o PyUnicode>|win32api|Unicode|Creates a new Unicode object
PYWINTYPES_EXPORT PyObject *PyWin_NewUnicode(PyObject *self, PyObject *args);

///////////////////
//
// Win32 Exception Handler.
Expand Down Expand Up @@ -6182,7 +6179,6 @@ static struct PyMethodDef win32api_functions[] = {
{"TerminateProcess", PyTerminateProcess, 1}, // @pymeth TerminateProcess|Terminates a process.
{"ToAsciiEx", PyToAsciiEx, 1}, // @pymeth ToAsciiEx|Translates the specified virtual-key code and keyboard state to
// the corresponding character or characters.
{"Unicode", PyWin_NewUnicode, 1}, // @pymeth Unicode|Creates a new <o PyUnicode> object
{"UpdateResource", PyUpdateResource, 1}, // @pymeth UpdateResource|Updates a resource in a PE file.
{"VkKeyScan", PyVkKeyScan,
1}, // @pymeth VkKeyScan|Translates a character to the corresponding virtual-key code and shift state.
Expand Down
Loading