Page MenuHome

Py3.5/windows regression: os.walk does not work anymore with bytes filenames
Closed, ResolvedPublic


Blender version: blender-2.76-ef49632-win64 (19.12.2015)
File: ( )

(  0.0010 sec |   0.0010 sec) Importing OBJ 'C:\\Downloads\\crytek-sponza\\cryte
  (  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\", lin
e 147, in execute
    return import_obj.load(context, **keywords)
  File "C:\Blender\2015_02_19\2.76\scripts\addons\io_scene_obj\", 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\", 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\", 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\", l
ine 67, in obj_image_load
    image = load_image(imagepath.replace(b'_', b' '), DIR, recursive=recursive,
  File "C:\Blender\2015_02_19\2.76\scripts\modules\bpy_extras\", 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\", l
ine 132, in _recursive_search
    for dirpath, dirnames, filenames in os.walk(path):
  File "C:\Blender\2015_02_19\2.76\python\lib\", line 366, in walk
    scandir_it = scandir(top)
TypeError: os.scandir() doesn't support bytes path on Windows, use Unicode inste

Event Timeline

Ivan (1vanK) raised the priority of this task from to Needs Triage by Developer.
Ivan (1vanK) updated the task description. (Show Details)
Ivan (1vanK) added a project: BF Blender.
Ivan (1vanK) set Type to Bug.
Ivan (1vanK) added a subscriber: Ivan (1vanK).
Bastien Montagne (mont29) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Dec 19 2015, 4:41 PM

@Campbell Barton (campbellbarton), this sounds like a python3.5 regression, made a report on their tracker (

Bastien Montagne (mont29) renamed this task from Error when import from OBJ to Py3.5/windows regression: os.walk does not work anymore with bytes filenames.Dec 19 2015, 4:54 PM

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


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

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?


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

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