Commit b7e834c2 authored by Olivier Aubert's avatar Olivier Aubert

python/vlcglue.c: exception-related code fixes

parent 3d26787a
...@@ -49,6 +49,17 @@ vlcMODINIT_FUNC initvlc(void) ...@@ -49,6 +49,17 @@ vlcMODINIT_FUNC initvlc(void)
PyPosition_Type.tp_new = PyType_GenericNew; PyPosition_Type.tp_new = PyType_GenericNew;
PyPosition_Type.tp_alloc = PyType_GenericAlloc; PyPosition_Type.tp_alloc = PyType_GenericAlloc;
/* PyEval_InitThreads(); */
/* Have a look at
http://base.bel-epa.com/pyapache/Python/MySQL-python/MySQL-python-0.3.0/_mysqlmodule.c */
m = Py_InitModule3( "vlc", vlc_methods,
"VLC media player embedding module.");
if (! m)
return;
if (PyType_Ready(&PyPosition_Type) < 0) if (PyType_Ready(&PyPosition_Type) < 0)
return; return;
if (PyType_Ready(&MediaControl_Type) < 0) if (PyType_Ready(&MediaControl_Type) < 0)
...@@ -58,42 +69,41 @@ vlcMODINIT_FUNC initvlc(void) ...@@ -58,42 +69,41 @@ vlcMODINIT_FUNC initvlc(void)
return; return;
#endif #endif
/* PyEval_InitThreads(); */
/* Have a look at
http://base.bel-epa.com/pyapache/Python/MySQL-python/MySQL-python-0.3.0/_mysqlmodule.c */
m = Py_InitModule3( "vlc", vlc_methods,
"VLC media player embedding module.");
/* Exceptions */ /* Exceptions */
MediaControl_InternalException = MediaControl_InternalException =
PyErr_NewException("vlc.InternalException", NULL, NULL); PyErr_NewException("vlc.InternalException", NULL, NULL);
Py_INCREF(MediaControl_InternalException);
PyModule_AddObject(m, "InternalException", MediaControl_InternalException); PyModule_AddObject(m, "InternalException", MediaControl_InternalException);
MediaControl_PositionKeyNotSupported = MediaControl_PositionKeyNotSupported =
PyErr_NewException("vlc.PositionKeyNotSupported", NULL, NULL); PyErr_NewException("vlc.PositionKeyNotSupported", NULL, NULL);
Py_INCREF(MediaControl_PositionKeyNotSupported);
PyModule_AddObject(m, "PositionKeyNotSupported", PyModule_AddObject(m, "PositionKeyNotSupported",
MediaControl_PositionKeyNotSupported); MediaControl_PositionKeyNotSupported);
MediaControl_PositionOriginNotSupported= MediaControl_PositionOriginNotSupported=
PyErr_NewException("vlc.InvalidPosition", NULL, NULL); PyErr_NewException("vlc.InvalidPosition", NULL, NULL);
Py_INCREF(MediaControl_PositionOriginNotSupported);
PyModule_AddObject(m, "PositionOriginNotSupported", PyModule_AddObject(m, "PositionOriginNotSupported",
MediaControl_PositionOriginNotSupported); MediaControl_PositionOriginNotSupported);
MediaControl_InvalidPosition = MediaControl_InvalidPosition =
PyErr_NewException("vlc.InvalidPosition", NULL, NULL); PyErr_NewException("vlc.InvalidPosition", NULL, NULL);
Py_INCREF(MediaControl_InvalidPosition);
PyModule_AddObject(m, "InvalidPosition", MediaControl_InvalidPosition); PyModule_AddObject(m, "InvalidPosition", MediaControl_InvalidPosition);
MediaControl_PlaylistException = MediaControl_PlaylistException =
PyErr_NewException("vlc.PlaylistException", NULL, NULL); PyErr_NewException("vlc.PlaylistException", NULL, NULL);
Py_INCREF(MediaControl_PlaylistException);
PyModule_AddObject(m, "PlaylistException", MediaControl_PlaylistException); PyModule_AddObject(m, "PlaylistException", MediaControl_PlaylistException);
/* Types */ /* Types */
Py_INCREF(&PyPosition_Type); Py_INCREF(&PyPosition_Type);
PyModule_AddObject(m, "Position", (PyObject *)&PyPosition_Type); PyModule_AddObject(m, "Position", (PyObject *)&PyPosition_Type);
Py_INCREF(&MediaControl_Type); Py_INCREF(&MediaControl_Type);
PyModule_AddObject(m, "MediaControl", (PyObject *)&MediaControl_Type); PyModule_AddObject(m, "MediaControl", (PyObject *)&MediaControl_Type);
#ifdef VLCOBJECT_SUPPORT #ifdef VLCOBJECT_SUPPORT
Py_INCREF(&vlcObject_Type); Py_INCREF(&vlcObject_Type);
PyModule_AddObject(m, "Object", (PyObject *)&vlcObject_Type); PyModule_AddObject(m, "Object", (PyObject *)&vlcObject_Type);
...@@ -284,10 +294,7 @@ static PyObject * vlcObject_find_id(PyObject *self, PyObject *args) ...@@ -284,10 +294,7 @@ static PyObject * vlcObject_find_id(PyObject *self, PyObject *args)
int i_id; int i_id;
if ( !PyArg_ParseTuple(args, "i", &i_id) ) if ( !PyArg_ParseTuple(args, "i", &i_id) )
{ return NULL;
PyErr_SetString(PyExc_StandardError, "Error: no id was given.\n");
return Py_None;
}
p_object = (vlc_object_t*)vlc_current_object(i_id); p_object = (vlc_object_t*)vlc_current_object(i_id);
...@@ -314,17 +321,12 @@ static PyObject * vlcObject_var_get(PyObject *self, PyObject *args) ...@@ -314,17 +321,12 @@ static PyObject * vlcObject_var_get(PyObject *self, PyObject *args)
int i_type; int i_type;
if ( !PyArg_ParseTuple(args, "s", &psz_name) ) if ( !PyArg_ParseTuple(args, "s", &psz_name) )
{ return NULL;
PyErr_SetString(PyExc_StandardError, "Error: no variable name was given.\n");
Py_INCREF(Py_None);
return Py_None;
}
if( var_Get( VLCSELF->p_object, psz_name, &value ) != VLC_SUCCESS ) if( var_Get( VLCSELF->p_object, psz_name, &value ) != VLC_SUCCESS )
{ {
PyErr_SetString(PyExc_StandardError, "Error: no variable name was given.\n"); PyErr_SetString(PyExc_StandardError, "Error: no variable name was given.\n");
Py_INCREF(Py_None); return NULL;
return Py_None;
} }
i_type = var_Type (VLCSELF->p_object, psz_name); i_type = var_Type (VLCSELF->p_object, psz_name);
...@@ -384,11 +386,7 @@ static PyObject * vlcObject_var_type(PyObject *self, ...@@ -384,11 +386,7 @@ static PyObject * vlcObject_var_type(PyObject *self,
int i_type; int i_type;
if ( !PyArg_ParseTuple(args, "s", &psz_name)) if ( !PyArg_ParseTuple(args, "s", &psz_name))
{ return NULL;
PyErr_SetString(PyExc_StandardError, "Error: no variable name was given.\n");
Py_INCREF(Py_None);
return Py_None;
}
i_type = var_Type(VLCSELF->p_object, psz_name); i_type = var_Type(VLCSELF->p_object, psz_name);
...@@ -454,11 +452,7 @@ static PyObject * vlcObject_var_set(PyObject *self, ...@@ -454,11 +452,7 @@ static PyObject * vlcObject_var_set(PyObject *self,
vlc_object_t *p_obj; vlc_object_t *p_obj;
if ( !PyArg_ParseTuple(args, "sO", &psz_name, &py_value) ) if ( !PyArg_ParseTuple(args, "sO", &psz_name, &py_value) )
{ return NULL;
PyErr_SetString(PyExc_StandardError, "Error: no variable name was given.\n");
Py_INCREF(Py_None);
return Py_None;
}
p_obj = VLCSELF->p_object; p_obj = VLCSELF->p_object;
i_type = var_Type(p_obj, psz_name); i_type = var_Type(p_obj, psz_name);
...@@ -537,11 +531,7 @@ static PyObject * vlcObject_config_get(PyObject *self, ...@@ -537,11 +531,7 @@ static PyObject * vlcObject_config_get(PyObject *self,
module_config_t *p_config; module_config_t *p_config;
if ( !PyArg_ParseTuple(args, "s", &psz_name) ) if ( !PyArg_ParseTuple(args, "s", &psz_name) )
{ return NULL;
PyErr_SetString(PyExc_StandardError, "Error: no config variable name was given.\n");
Py_INCREF(Py_None);
return Py_None;
}
p_config = config_FindConfig( VLCSELF->p_object, psz_name ); p_config = config_FindConfig( VLCSELF->p_object, psz_name );
...@@ -600,12 +590,7 @@ static PyObject * vlcObject_config_set(PyObject *self, ...@@ -600,12 +590,7 @@ static PyObject * vlcObject_config_set(PyObject *self,
if ( !PyArg_ParseTuple(args, "sO", &psz_name, &py_value) ) if ( !PyArg_ParseTuple(args, "sO", &psz_name, &py_value) )
{ return NULL;
PyErr_SetString(PyExc_StandardError,
"Error: no variable name was given.\n");
Py_INCREF(Py_None);
return Py_None;
}
p_obj = VLCSELF->p_object; p_obj = VLCSELF->p_object;
p_config = config_FindConfig( p_obj, psz_name ); p_config = config_FindConfig( p_obj, psz_name );
...@@ -780,7 +765,7 @@ static PyObject *MediaControl_new(PyTypeObject *type, PyObject *args, PyObject * ...@@ -780,7 +765,7 @@ static PyObject *MediaControl_new(PyTypeObject *type, PyObject *args, PyObject *
else else
{ {
/* No arguments were given. Clear the exception raised /* No arguments were given. Clear the exception raised
* by PyArg_ParseTuple. */ by PyArg_ParseTuple. */
PyErr_Clear(); PyErr_Clear();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment