OBJ importer: Inconsistent handling of decoding errors between Windows and Linux #86783
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
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-addons#86783
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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.18362 64 Bits
Graphics card: Quadro M1200/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 452.41
Blender Version
Broken: version: 2.92 & 2.80/2.83/2.93
Short description of error
The obj importer does not provide the same error handling behavior on Linux and Windows. If an *.obj is imported that is not encoded as UTF-8, the name of the referenced *.mtl can't be properly decoded. On Windows this immediately raises an
UnicodeError
and the import fails in its entirety. This is because of the use ofos.fsdecode
that applieserror='strict'
on Windows. On Linux it attempts to decode the filename and doesn't throw an error. Instead it skips the loading of the *.mtl later on as it cannot find a file with the garbled filename. The object itself is still imported.Original description:
Obj importer from Blender 2.8-2.93 on my machine/Win10 seems unable to import non UTF-8 encoded .obj , gives UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 3: invalid start byte.
However, Blender 2.79 on my machine/Win10 is able to import with no problem.
Attached a test example. obj_name.7z
Exact steps for others to reproduce the error
open Blender 2.80+, import attached .obj, get error.
Added subscriber: @tiancaipipi110
Here're the log files from failed import in Blender 2.92 & 2.80rc3. bug_tracker.7z
Added subscriber: @deadpin
Notes to other triagers:
2.79 loads the geometry, however, it fails to load the material- [x]. It doesn't seem like the file was written correctly; perhaps the software used was also not unicode friendly.
2.93 does not load anything, it fails with the material like 2.79 and then stops processing[2]
Here's the console output from 2.79
I didn't include textures because I don't think it matters. Here's the updated files with textures, Blender 2.79 should import everything correctly. obj_name_tex.7z
Actually I do get them to load. The output on the command line was weird.
Well the .mtl is in the .7z. This is what I see.
Added subscriber: @rjg
The .obj appears to be encoded as GB2312 and it fails to import properly on both Windows and Linux.
On Linux it imports the model, because it fails gracefully. It attempts to decode the filename of the *.mtl and doesn't throw an error in this step. However, since the attempt to decode the GB2312 encoded name as UTF-8 results in a mangled string, it doesn't load the material definition since it can't find a file with that name.
On Windows it already fails in the decoding step as https://docs.python.org/3/library/os.html#os.fsdecode uses
'strict'
on this platform as the default for error handling. This results in the raising of theUnicodeError
as shown in the log file by @deadpin.Since there is no code that attempts to detect the encoding of the text file and use that to interpret it, anything other than UTF-8 can't be properly imported. At best if fails gracefully ignoring parts it can't decode, as it does on Linux.
The importer can be improved for Windows to fail as graceful as it does on Linux by replacing
with
All other usages of
os.fsdecode()
would have to be replaced as well.In conclusion:
UnicodeError
.Changed status from 'Needs Triage' to: 'Confirmed'
I'm setting the status of the ticket to confirmed with the goal to adjust the error handling behavior on Windows to match Linux and macOS. The fact that files that aren't UTF-8 encoded can't be properly imported is not a bug though.
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa7 in position 3: invalid start byteto OBJ importer: Inconsistent handling of decoding errors between Windows and LinuxChanged status from 'Confirmed' to: 'Archived'
The new OBJ importer (experimental in 3.2, default since 3.3) imports this better on Windows. It still can't find the MTL file of course, since the OBJ file is not UTF-8 encoded, but happens to load some of the textures as a side effect of "if we don't have a valid MTL file, look for the one named exactly like the OBJ file" logic.
I'm archiving this since the python based importer is unlikely to get any further fixes, if anything it is likely to get removed soon-ish.