When starting ipy
on MacOS I get LookupError: unknown encoding: cp0
.
I compiled IronPython for Mac from source as I did not find any binary releases for IronPython (homebrew?)
➜ ironpython3 git:(35cc2274) ✗ pwsh make.ps1 -frameworks net6.0 debug
➜ ironpython3 git:(35cc2274) ✗ ./bin/Debug/net6.0/ipy
Traceback (most recent call last):
File "<string>", line 1567, in load_module
File "<string>", line 596, in _load_module_shim
File "<string>", line 1210, in load
File "<string>", line 1190, in _load_unlocked
File "<string>", line 1119, in _exec
File "<string>", line 1461, in exec_module
File "<string>", line 539, in _check_name_wrapper
File "<string>", line 321, in _call_with_frames_removed
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 564, in <module>
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 550, in main
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 281, in addusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 257, in getusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 247, in getuserbase
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 595, in get_config_var
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 575, in get_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 393, in customize_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 135, in _supports_universal_builds
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 103, in _get_system_version
LookupError: unknown encoding: cp0IronPython 3.4.0b1 DEBUG (3.4.0.0010)
[.NETCoreApp,Version=v6.0 on .NET 6.0.7 (64-bit)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
When printing out the current encoding, utf_8
is returned:
➜ ironpython3 git:(35cc2274) ✗ bin/Debug/net6.0/ipy -c "import sys; print('The enncoding is='+sys.stdin.encoding)"
Traceback (most recent call last):
File "<string>", line 1567, in load_module
File "<string>", line 596, in _load_module_shim
File "<string>", line 1210, in load
File "<string>", line 1190, in _load_unlocked
File "<string>", line 1119, in _exec
File "<string>", line 1461, in exec_module
File "<string>", line 539, in _check_name_wrapper
File "<string>", line 321, in _call_with_frames_removed
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 564, in <module>
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 550, in main
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 281, in addusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 257, in getusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 247, in getuserbase
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 595, in get_config_var
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 575, in get_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 393, in customize_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 135, in _supports_universal_builds
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 103, in _get_system_version
LookupError: unknown encoding: cp0The enncoding is=utf_8
Looking into the code reveals that f = open('/System/Library/CoreServices/SystemVersion.plist')
is raising the error.
➜ ironpython3 git:(35cc2274) ✗ cat /System/Library/CoreServices/SystemVersion.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string>19H2026</string>
<key>ProductCopyright</key>
<string>1983-2022 Apple Inc.</string>
<key>ProductName</key>
<string>Mac OS X</string>
<key>ProductUserVisibleVersion</key>
<string>10.15.7</string>
<key>ProductVersion</key>
<string>10.15.7</string>
<key>iOSSupportVersion</key>
<string>13.6</string>
</dict>
</plist>
➜ ironpython3 git:(35cc2274) ✗ file /System/Library/CoreServices/SystemVersion.plist
/System/Library/CoreServices/SystemVersion.plist: XML 1.0 document text, ASCII text
Reading this file with the default encoding yields to the error:
>>> f = open('/System/Library/CoreServices/SystemVersion.plist')
>>> print(f.readlines())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
LookupError: unknown encoding: cp0
>>> f = open('/System/Library/CoreServices/SystemVersion.plist', encoding='utf-8')
>>> print(f.readlines())
['<?xml version="1.0" encoding="UTF-8"?>\n', '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n', '<plist version="1.0">\n', '<dict>\n', '\t<key>ProductBuildVersion</key>\n', '\t<string>19H2026</string>\n', '\t<key>ProductCopyright</key>\n', '\t<string>1983-2022 Apple Inc.</string>\n', '\t<key>ProductName</key>\n', '\t<string>Mac OS X</string>\n', '\t<key>ProductUserVisibleVersion</key>\n', '\t<string>10.15.7</string>\n', '\t<key>ProductVersion</key>\n', '\t<string>10.15.7</string>\n', '\t<key>iOSSupportVersion</key>\n', '\t<string>13.6</string>\n', '</dict>\n', '</plist>\n']
Setting PYTHONIOENCODING
did not change the behavior:
➜ ironpython3 git:(35cc2274) ✗ PYTHONIOENCODING=utf_8 bin/Debug/net6.0/ipy
Traceback (most recent call last):
File "<string>", line 1567, in load_module
File "<string>", line 596, in _load_module_shim
File "<string>", line 1210, in load
File "<string>", line 1190, in _load_unlocked
File "<string>", line 1119, in _exec
File "<string>", line 1461, in exec_module
File "<string>", line 539, in _check_name_wrapper
File "<string>", line 321, in _call_with_frames_removed
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 564, in <module>
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 550, in main
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 281, in addusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 257, in getusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 247, in getuserbase
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 595, in get_config_var
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 575, in get_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 393, in customize_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 135, in _supports_universal_builds
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 103, in _get_system_version
LookupError: unknown encoding: cp0IronPython 3.4.0b1 DEBUG (3.4.0.0010)
[.NETCoreApp,Version=v6.0 on .NET 6.0.7 (64-bit)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
➜ ironpython3 git:(35cc2274) ✗ PYTHONIOENCODING=utf-8 bin/Debug/net6.0/ipy
Traceback (most recent call last):
File "<string>", line 1567, in load_module
File "<string>", line 596, in _load_module_shim
File "<string>", line 1210, in load
File "<string>", line 1190, in _load_unlocked
File "<string>", line 1119, in _exec
File "<string>", line 1461, in exec_module
File "<string>", line 539, in _check_name_wrapper
File "<string>", line 321, in _call_with_frames_removed
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 564, in <module>
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 550, in main
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 281, in addusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 257, in getusersitepackages
File "/Users/sascha/Dev/ironpython3/bin/Debug/net6.0/../../../Src/StdLib/Lib/site.py", line 247, in getuserbase
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 595, in get_config_var
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/sysconfig.py", line 575, in get_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 393, in customize_config_vars
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 135, in _supports_universal_builds
File "/Users/sascha/Dev/ironpython3/Src/StdLib/Lib/_osx_support.py", line 103, in _get_system_version
LookupError: unknown encoding: cp0IronPython 3.4.0b1 DEBUG (3.4.0.0010)
[.NETCoreApp,Version=v6.0 on .NET 6.0.7 (64-bit)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Forcefully editing _osx_support.py
to open the file with utf-8
works:
f = open('/System/Library/CoreServices/SystemVersion.plist', encoding='utf-8')
Any suggested work-around or fix?
Environment
➜ ~ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.302
Commit: c857713418
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/6.0.302/
global.json file:
Not found
Host:
Version: 6.0.7
Architecture: x64
Commit: 0ec02c8c96
.NET SDKs installed:
6.0.302 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]