@@ -803,9 +803,14 @@ static PyMethodDef oss_mixer_methods[] = {
803803};
804804
805805static PyObject *
806- oss_getattr (oss_audio_t * self , char * name )
806+ oss_getattro (oss_audio_t * self , PyObject * nameobj )
807807{
808+ char * name = "" ;
808809 PyObject * rval = NULL ;
810+
811+ if (PyUnicode_Check (nameobj ))
812+ name = PyUnicode_AsString (nameobj );
813+
809814 if (strcmp (name , "closed" ) == 0 ) {
810815 rval = (self -> fd == -1 ) ? Py_True : Py_False ;
811816 Py_INCREF (rval );
@@ -829,17 +834,11 @@ oss_getattr(oss_audio_t *self, char *name)
829834 }
830835 }
831836 else {
832- rval = Py_FindMethod ( oss_methods , (PyObject * )self , name );
837+ rval = PyObject_GenericGetAttr ( (PyObject * )self , nameobj );
833838 }
834839 return rval ;
835840}
836841
837- static PyObject *
838- oss_mixer_getattr (oss_mixer_t * self , char * name )
839- {
840- return Py_FindMethod (oss_mixer_methods , (PyObject * )self , name );
841- }
842-
843842static PyTypeObject OSSAudioType = {
844843 PyVarObject_HEAD_INIT (& PyType_Type , 0 )
845844 "ossaudiodev.oss_audio_device" , /*tp_name*/
@@ -848,10 +847,28 @@ static PyTypeObject OSSAudioType = {
848847 /* methods */
849848 (destructor )oss_dealloc , /*tp_dealloc*/
850849 0 , /*tp_print*/
851- ( getattrfunc ) oss_getattr , /*tp_getattr*/
850+ 0 , /*tp_getattr*/
852851 0 , /*tp_setattr*/
853852 0 , /*tp_compare*/
854853 0 , /*tp_repr*/
854+ 0 , /*tp_as_number*/
855+ 0 , /*tp_as_sequence*/
856+ 0 , /*tp_as_mapping*/
857+ 0 , /*tp_hash*/
858+ 0 , /*tp_call*/
859+ 0 , /*tp_str*/
860+ (getattrofunc )oss_getattro , /*tp_getattro*/
861+ 0 , /*tp_setattro*/
862+ 0 , /*tp_as_buffer*/
863+ Py_TPFLAGS_DEFAULT , /*tp_flags*/
864+ 0 , /*tp_doc*/
865+ 0 , /*tp_traverse*/
866+ 0 , /*tp_clear*/
867+ 0 , /*tp_richcompare*/
868+ 0 , /*tp_weaklistoffset*/
869+ 0 , /*tp_iter*/
870+ 0 , /*tp_iternext*/
871+ oss_methods , /*tp_methods*/
855872};
856873
857874static PyTypeObject OSSMixerType = {
@@ -862,10 +879,28 @@ static PyTypeObject OSSMixerType = {
862879 /* methods */
863880 (destructor )oss_mixer_dealloc , /*tp_dealloc*/
864881 0 , /*tp_print*/
865- ( getattrfunc ) oss_mixer_getattr , /*tp_getattr*/
882+ 0 , /*tp_getattr*/
866883 0 , /*tp_setattr*/
867884 0 , /*tp_compare*/
868885 0 , /*tp_repr*/
886+ 0 , /*tp_as_number*/
887+ 0 , /*tp_as_sequence*/
888+ 0 , /*tp_as_mapping*/
889+ 0 , /*tp_hash*/
890+ 0 , /*tp_call*/
891+ 0 , /*tp_str*/
892+ 0 , /*tp_getattro*/
893+ 0 , /*tp_setattro*/
894+ 0 , /*tp_as_buffer*/
895+ Py_TPFLAGS_DEFAULT , /*tp_flags*/
896+ 0 , /*tp_doc*/
897+ 0 , /*tp_traverse*/
898+ 0 , /*tp_clear*/
899+ 0 , /*tp_richcompare*/
900+ 0 , /*tp_weaklistoffset*/
901+ 0 , /*tp_iter*/
902+ 0 , /*tp_iternext*/
903+ oss_mixer_methods , /*tp_methods*/
869904};
870905
871906
0 commit comments