Python API

----------
Bugfix #3233: throw an IOError exception in Library.Open() if the specified
library file cannot be opened.

This had been changed to a "feature request" but should have been a bug, even
though it worked as documented (or rather, the documentation described what
the function did).
This commit is contained in:
Ken Hughes
2007-01-22 22:59:34 +00:00
parent 5dd1a39288
commit 42ef81d88b
2 changed files with 6 additions and 8 deletions

View File

@@ -158,7 +158,7 @@ PyObject *M_Library_Open( PyObject * self, PyObject * args )
Py_DECREF( Py_None ); /* incref'ed by above function */
}
/* copy the name to make it absolute so BLO_blendhandle_from_file dosnt complain */
/* copy the name to make it absolute so BLO_blendhandle_from_file doesn't complain */
BLI_strncpy(fname1, fname, sizeof(fname1));
BLI_convertstringcode(fname1, G.sce, 0); /* make absolute */
@@ -167,9 +167,8 @@ PyObject *M_Library_Open( PyObject * self, PyObject * args )
bpy_openlib = BLO_blendhandle_from_file( fname1 );
BLI_strncpy(G.sce, filename, sizeof(filename));
if( !bpy_openlib )
return Py_BuildValue( "i", 0 );
return EXPP_ReturnPyObjError( PyExc_IOError, "file not found" );
/* "//someblend.blend" enables relative paths */
if (sizeof(fname) > 2 && fname[0] == '/' && fname[1] == '/')
@@ -200,8 +199,7 @@ PyObject *M_Library_Close( PyObject * self )
bpy_openlibname = NULL;
}
Py_INCREF( Py_None );
return Py_None;
Py_RETURN_NONE;
}
/**

View File

@@ -46,9 +46,9 @@ def Open (filename):
Open an existing .blend file. If there was already one open file, it is
closed first.
@type filename: string
@param filename: The filename of a Blender file. Filenames starting with // will be loaded relative to the blend files location.
@param filename: The filename of a Blender file. Filenames starting with "//" will be loaded relative to the blend file's location.
@rtype: bool
@return: 1 if successful, 0 otherwise.
@return: 1 if successful. An IOError exception is thrown if the file cannot be opened.
"""
def Close ():