[Bf-committers] patch for 'object is not callable' exception in .obj importer
Mark Ivey
zovirl1 at sbcglobal.net
Wed Dec 19 06:46:29 CET 2007
Greetings,
I ran into a simple problem with the wavefront .obj importer. If the
vertices are all integer values, it crashes with this error message:
importing obj "/Users/mivey/crash.obj"
passing obj file "/Users/mivey/crash.obj"...
Traceback (most recent call last):
File "<string>", line 831, in load_obj_ui
File "<string>", line 594, in load_obj
TypeError: 'NoneType' object is not callable
The culprit is that get_float_func() can fall off the end of the
function, implicitly returning None instead of a function reference.
The fix is simple: make sure get_float_func returns float by
default. I couldn't figure out how to add a patch to the tracker on
projects.blender.org, but it is really simple so I'll include it here:
Index: release/scripts/import_obj.py
===================================================================
--- release/scripts/import_obj.py (revision 12940)
+++ release/scripts/import_obj.py (working copy)
@@ -542,6 +542,7 @@
return lambda f: float(f.replace
(',', '.'))
elif '.' in line:
return float
+ return float # Maybe file only contained integers? float is
a good default.
def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True,
CREATE_SMOOTH_GROUPS= True, CREATE_EDGES= True, SPLIT_OBJECTS= True,
SPLIT_GROUPS= True, SPLIT_MATERIALS= True, IMAGE_SEARCH=True):
'''
Here's a simple .obj file that exposes the problem:
v 0 0 0
v 0 0 1
v 1 0 1
v 1 0 0
f 1 2 3 4
More information about the Bf-committers
mailing list