render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

Blame 0001-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch

a6540d
From a32df3463befa04913fd1934ed264038a9eae00f Mon Sep 17 00:00:00 2001
a6540d
Message-Id: <a32df3463befa04913fd1934ed264038a9eae00f.1596577611.git.crobinso@redhat.com>
a6540d
From: Cole Robinson <crobinso@redhat.com>
a6540d
Date: Tue, 4 Aug 2020 17:04:50 -0400
a6540d
Subject: [PATCH 1/2] BaseTools: fix ucs-2 lookup on python 3.9
a6540d
a6540d
python3.9 changed/fixed codec.register behavior to always replace
a6540d
hyphen with underscore for passed in codec names:
a6540d
a6540d
  https://bugs.python.org/issue37751
a6540d
a6540d
So the custom Ucs2Search needs to be adapted to handle 'ucs_2' in
a6540d
addition to existing 'ucs-2' for back compat.
a6540d
a6540d
This fixes test failures on python3.9, example:
a6540d
a6540d
======================================================================
a6540d
FAIL: testUtf16InUniFile (CheckUnicodeSourceFiles.Tests)
a6540d
----------------------------------------------------------------------
a6540d
Traceback (most recent call last):
a6540d
  File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 375, in PreProcess
a6540d
    FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path))
a6540d
  File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 303, in OpenUniFile
a6540d
    UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding)
a6540d
  File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 312, in VerifyUcs2Data
a6540d
    Ucs2Info = codecs.lookup('ucs-2')
a6540d
LookupError: unknown encoding: ucs-2
a6540d
a6540d
Signed-off-by: Cole Robinson <crobinso@redhat.com>
a6540d
---
a6540d
 BaseTools/Source/Python/AutoGen/UniClassObject.py | 2 +-
a6540d
 1 file changed, 1 insertion(+), 1 deletion(-)
a6540d
a6540d
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
a6540d
index b2895f7e5c..883c2356e0 100644
a6540d
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
a6540d
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
a6540d
@@ -152,7 +152,7 @@ class Ucs2Codec(codecs.Codec):
a6540d
 
a6540d
 TheUcs2Codec = Ucs2Codec()
a6540d
 def Ucs2Search(name):
a6540d
-    if name == 'ucs-2':
a6540d
+    if name in ['ucs-2', 'ucs_2']:
a6540d
         return codecs.CodecInfo(
a6540d
             name=name,
a6540d
             encode=TheUcs2Codec.encode,
a6540d
-- 
a6540d
2.26.2
a6540d