From 309a8b061ae6b852539e089220a2462821c3cbb2 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 1 Nov 2023 15:36:52 -0400 Subject: [PATCH] Change `mbcs` encoding to `utf-8` in `com/win32com/client` (#2097) --- Pythonwin/pywin/__init__.py | 3 --- Pythonwin/pywin/tools/hierlist.py | 2 -- com/win32com/client/genpy.py | 4 ++-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Pythonwin/pywin/__init__.py b/Pythonwin/pywin/__init__.py index 2e44fba5ca..43d5c446fd 100644 --- a/Pythonwin/pywin/__init__.py +++ b/Pythonwin/pywin/__init__.py @@ -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 diff --git a/Pythonwin/pywin/tools/hierlist.py b/Pythonwin/pywin/tools/hierlist.py index 580d4dcc3f..cc76f1905a 100644 --- a/Pythonwin/pywin/tools/hierlist.py +++ b/Pythonwin/pywin/tools/hierlist.py @@ -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, diff --git a/com/win32com/client/genpy.py b/com/win32com/client/genpy.py index 739f3ddd00..06f11889cd 100644 --- a/com/win32com/client/genpy.py +++ b/com/win32com/client/genpy.py @@ -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 @@ -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)