Py3.5/windows regression: os.walk does not work anymore with bytes filenames #47018

Closed
opened 2015-12-19 07:49:36 +01:00 by Ivan · 13 comments

Blender version: blender-2.76-ef49632-win64 (19.12.2015)
File: http:*graphics.cs.williams.edu/data/meshes/crytek-sponza.zip ( http:*graphics.cs.williams.edu/data/meshes.xml )

(  0.0010 sec |   0.0010 sec) Importing OBJ 'C:\\Downloads\\crytek-sponza\\cryte
k-sponza\\sponza.obj'...
  (  0.0210 sec |   0.0200 sec) Parsing OBJ file...
    ( 21.1332 sec |  21.1112 sec) Done, loading materials and images...
Progress:  33.33%

Traceback (most recent call last):
  File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\__init__.py", lin
e 147, in execute
    return import_obj.load(context, **keywords)
  File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l
ine 1162, in load
    unique_material_images, use_image_search, float_func)
  File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l
ine 401, in create_materials
    load_material_image(context_material, context_material_name, img_data, 'Ka')

  File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l
ine 102, in load_material_image
    image = obj_image_load(imagepath, DIR, use_image_search, relpath)
  File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l
ine 67, in obj_image_load
    image = load_image(imagepath.replace(b'_', b' '), DIR, recursive=recursive,
relpath=relpath)
  File "C:\Blender\2015_02_19\2.76\scripts\modules\bpy_extras\image_utils.py", l
ine 187, in load_image
    nfilepath = next(_recursive_search(search_paths, image_filter), None)
  File "C:\Blender\2015_02_19\2.76\scripts\modules\bpy_extras\image_utils.py", l
ine 132, in _recursive_search
    for dirpath, dirnames, filenames in os.walk(path):
  File "C:\Blender\2015_02_19\2.76\python\lib\os.py", line 366, in walk
    scandir_it = scandir(top)
TypeError: os.scandir() doesn't support bytes path on Windows, use Unicode inste
ad
Blender version: blender-2.76-ef49632-win64 (19.12.2015) File: http:*graphics.cs.williams.edu/data/meshes/crytek-sponza.zip ( http:*graphics.cs.williams.edu/data/meshes.xml ) ``` ( 0.0010 sec | 0.0010 sec) Importing OBJ 'C:\\Downloads\\crytek-sponza\\cryte k-sponza\\sponza.obj'... ( 0.0210 sec | 0.0200 sec) Parsing OBJ file... ( 21.1332 sec | 21.1112 sec) Done, loading materials and images... Progress: 33.33% Traceback (most recent call last): File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\__init__.py", lin e 147, in execute return import_obj.load(context, **keywords) File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l ine 1162, in load unique_material_images, use_image_search, float_func) File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l ine 401, in create_materials load_material_image(context_material, context_material_name, img_data, 'Ka') File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l ine 102, in load_material_image image = obj_image_load(imagepath, DIR, use_image_search, relpath) File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\import_obj.py", l ine 67, in obj_image_load image = load_image(imagepath.replace(b'_', b' '), DIR, recursive=recursive, relpath=relpath) File "C:\Blender\2015_02_19\2.76\scripts\modules\bpy_extras\image_utils.py", l ine 187, in load_image nfilepath = next(_recursive_search(search_paths, image_filter), None) File "C:\Blender\2015_02_19\2.76\scripts\modules\bpy_extras\image_utils.py", l ine 132, in _recursive_search for dirpath, dirnames, filenames in os.walk(path): File "C:\Blender\2015_02_19\2.76\python\lib\os.py", line 366, in walk scandir_it = scandir(top) TypeError: os.scandir() doesn't support bytes path on Windows, use Unicode inste ad ```

blender/blender#47056 was marked as duplicate of this issue

blender/blender#47056 was marked as duplicate of this issue

#47053 was marked as duplicate of this issue

#47053 was marked as duplicate of this issue
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @1vanK

Added subscriber: @1vanK

Added subscribers: @ideasman42, @mont29

Added subscribers: @ideasman42, @mont29

@ideasman42, this sounds like a python3.5 regression, made a report on their tracker (http://bugs.python.org/issue25911).

@ideasman42, this sounds like a python3.5 regression, made a report on their tracker (http://bugs.python.org/issue25911).
Bastien Montagne changed title from Error when import from OBJ to Py3.5/windows regression: os.walk does not work anymore with bytes filenames 2015-12-19 16:54:39 +01:00

Added subscriber: @Sum.Al

Added subscriber: @Sum.Al

Python3.3 deprecated byte-filepath support (only on Windows).

See: https://docs.python.org/3/whatsnew/3.3.html#deprecated-python-modules-functions-and-methods

Looks like we'll need to have code-paths for passing regular strings to file IO functions (and handle encoding issues).

Python3.3 deprecated byte-filepath support (only on Windows). See: https://docs.python.org/3/whatsnew/3.3.html#deprecated-python-modules-functions-and-methods Looks like we'll need to have code-paths for passing regular strings to file IO functions (and handle encoding issues).

Added subscriber: @PeterBoos

Added subscriber: @PeterBoos

This issue was referenced by 7d832c33d5

This issue was referenced by 7d832c33d5cf1632823ebfc673c9d74343e8fb3b

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Is this solved? Does the solution work for 2.76 as well?
Can you please elaborate a little more on what has to be done?

Thanks.

Is this solved? Does the solution work for 2.76 as well? Can you please elaborate a little more on what has to be done? Thanks.

This bug doesn't impact 2.76x official release, since that used Python3.4x.

And you can test the fix in any recent daily build from http://builder.blender.org


The change uses os.fsdecode to convert bytes to strings for use as paths.

This bug doesn't impact 2.76x official release, since that used Python3.4x. And you can test the fix in any recent daily build from http://builder.blender.org ---- The change uses `os.fsdecode` to convert bytes to strings for use as paths.
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#47018
No description provided.