Keymap is not exported with the correct encoding #82292
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#82292
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 452.06
Blender Version
Broken: version: 2.90.1, branch: master, commit date: 2020-09-23 06:43, hash:
3e85bb34d0
Worked: (newest version of Blender that worked as expected)
Short description of error
The exported keymap is not encoded with UTF-8 but an encoding depending on the locale. This produces a file which cannot be properly imported afterwards.
The
keyconfig_export_as_data
should specify the encoding when usingopen()
.Exact steps for others to reproduce the error
operator-to-reproduce-bug.py
Added subscriber: @Guai_Wo_Ge_EMM
Added subscriber: @rjg
Changed status from 'Needs Triage' to: 'Needs User Info'
The files you've attached appear to be encoded with GB2312 for simplified Chinese. Blender requires these files to be encoded with UTF-8. Additionally the
keymap.py
appears to be generally broken withNULL
bytes at the beginning and seemingly corrupted output at the end of the file.Could you please explain how you created these files and the exact steps to reproduce the issue? If Blender has saved these files that can't be imported, then this would be a bug. However, should you have manually edited the keymap and saved it with the unsupported encoding, then this is not a bug in Blender.
EMM.py
QQ录屏20201101191923.mp4
我没有做其它多余的操作,我点击导出之后,立刻点击导入,然后它就出现了这样的报错,而且两个报错还不同,我也不知道还有其它什么地方注意的,会不会是因为我使用的中文系统导致的呢,另外附上我操作的视频
我还发现一个问题,就是新建一个 keymap 选择它也会出现BUG
@Guai_Wo_Ge_EMM Unfortunately the video in your last comment doesn't play for me. If you could re-upload it, that would be very helpful.
Just to avoid any misunderstandings, is it correct that you're doing the following steps?
Was the first keymap that resulted in the export/import error created by editing one of the built-in keymaps through Edit > Preferences > Keymap? Is the
EMM.py
or.py
(from your original report) the keymap what you get after exporting and you're trying to import this file again? Iskeymap.py
what you get after attempting to importEMM.py
or.py
?Added subscriber: @jenkm
I don't know what the "Blender-PME" addon is, but you use non-English names in it, I think so.
It could be something like this {86c4ca71ef18}.
Yes, I'm using a PIE plugin, it can use custom UI.
Its forum address is this:https://blenderartists.org/t/pie-menu-editor-1-18-0/662456/3680
是的,我正在使用一个PIE插件,它能使用自定义UI.是这个原因吗
它的论坛地址是这个:https://blenderartists.org/t/pie-menu-editor-1-18-0/662456/3680
I can reproduce the import error by attempting to import
EMM.py
. This is caused by the pie menu entries as @jenkm said and as I've noted in my first comment the encoding for these characters is not in UTF-8 but seem to be GB2312.It appears that the Blender-PME add-on doesn't handled encoding properly and stores non UTF-8 characters in the keymap. We can't provide support for the paid third-party add-on,however Blender shouldn't let an add-on store invalid characters in the keymap either.I'll try to reproduce this issue through the Python API.
Edit: It's Blender's fault.
Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
@Guai_Wo_Ge_EMM As a workaround I've edited the
EMM.py
file which can now be imported. The Chinese characters have been replaced with the (poorly machine translated) English words and it's been saved with UTF-8 encoding.EMM_edit.py
Thank you, the file you sent can be imported, thank you very much, in addition to this bug I have feedback to the plug-in developers there, should be resolved!
谢谢您,您发的文件可以导入了,十分感谢,另外这个BUG我已经反馈到插件开发者那里了,应该会得到解决
I've tried to intentionally break the keymap through the Python API, but haven't been successful so far. Will continue to investigate.
It seems that the problem is caused when an operator has a string property, there is a shortcut registered for it in the keymap and the shortcut uses a value for the operators string property that is not UTF-8 encoded. However, I can't get a keymap to export after assigning e.g. Chinese characters to the property in the keymap preferences. It gives the following exception:
As of now I cannot reproduce the exact error from the original bug report with my current system configuration, but I have an idea. Since the error references
cp1252.py
Blender always seems to be using the system locale to determine the encoding. Reproducing the exact error from the original report may be possible with a different system locale configuration, which then presumably fails to import it later on. I would guess that in order to reproduce this bug you would have to set Windows' system locale to Simplified Chinese, which then results in code page 936 being used. This would then have GB2312 encoding applied to the input, which is what I've seen in the keymap included in the bug report.If anyone wants to test this and investigate further, below is a script that implements a simple operator which is added to the keymap when registered.
operator-to-reproduce-bug.py
I think I found the issue. The code page error in my last comment means that Blender isn't using UTF-8 for the export on my system either. The function
keyconfig_export_as_data
that writes the keymap doesn't set the encoding to UTF-8. The encoding should be explicitly set in Python'sopen()
function.Currently:
Possible fix:
Edit: @jenkm was spot on with his comment.
@rjg
:)
@jenkm Yes, I know. Would've found/verified the problem quicker if I checked
keyconfig_export_as_data
or greppedopen(
first, instead of attempting to reproduce the reported error condition.Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
Cannot import the same version of exported shortcuts 无法导入同一个版本导出的 快捷键to Keymap is not exported with the correct encodingThis issue was referenced by
4988f5f39c
This issue was referenced by
f7320c3bf1
Changed status from 'Confirmed' to: 'Resolved'