Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5f5a7781
Commit
5f5a7781
authored
Oct 04, 2018
by
Serhiy Storchaka
Committed by
GitHub
Oct 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34740: Get rid of tp_getattro in ossaudiodev.oss_audio_device. (GH-9421)
Use tp_members and tp_getset instead.
parent
b2953fa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
35 deletions
+34
-35
Modules/ossaudiodev.c
Modules/ossaudiodev.c
+34
-35
No files found.
Modules/ossaudiodev.c
View file @
5f5a7781
...
...
@@ -921,46 +921,43 @@ static PyMethodDef oss_mixer_methods[] = {
{
NULL
,
NULL
}
};
static
PyMemberDef
oss_members
[]
=
{
{
"name"
,
T_STRING
,
offsetof
(
oss_audio_t
,
devicename
),
READONLY
,
NULL
},
{
NULL
}
};
static
PyObject
*
oss_
getattro
(
oss_audio_t
*
self
,
PyObject
*
nameobj
)
oss_
closed_getter
(
oss_audio_t
*
self
,
void
*
closure
)
{
const
char
*
name
=
""
;
PyObject
*
rval
=
NULL
;
if
(
PyUnicode_Check
(
nameobj
))
{
name
=
PyUnicode_AsUTF8
(
nameobj
);
if
(
name
==
NULL
)
return
NULL
;
}
return
PyBool_FromLong
(
self
->
fd
==
-
1
);
}
if
(
strcmp
(
name
,
"closed"
)
==
0
)
{
rval
=
(
self
->
fd
==
-
1
)
?
Py_True
:
Py_False
;
Py_INCREF
(
rval
);
}
else
if
(
strcmp
(
name
,
"name"
)
==
0
)
{
rval
=
PyUnicode_FromString
(
self
->
devicename
);
}
else
if
(
strcmp
(
name
,
"mode"
)
==
0
)
{
/* No need for a "default" in this switch: from newossobject(),
self->mode can only be one of these three values. */
switch
(
self
->
mode
)
{
case
O_RDONLY
:
rval
=
PyUnicode_FromString
(
"r"
);
break
;
case
O_RDWR
:
rval
=
PyUnicode_FromString
(
"rw"
);
break
;
case
O_WRONLY
:
rval
=
PyUnicode_FromString
(
"w"
);
break
;
}
}
else
{
rval
=
PyObject_GenericGetAttr
((
PyObject
*
)
self
,
nameobj
);
static
PyObject
*
oss_mode_getter
(
oss_audio_t
*
self
,
void
*
closure
)
{
switch
(
self
->
mode
)
{
case
O_RDONLY
:
return
PyUnicode_FromString
(
"r"
);
break
;
case
O_RDWR
:
return
PyUnicode_FromString
(
"rw"
);
break
;
case
O_WRONLY
:
return
PyUnicode_FromString
(
"w"
);
break
;
default:
/* From newossobject(), self->mode can only be one
of these three values. */
Py_UNREACHABLE
();
}
return
rval
;
}
static
PyGetSetDef
oss_getsetlist
[]
=
{
{
"closed"
,
(
getter
)
oss_closed_getter
,
(
setter
)
NULL
,
NULL
},
{
"mode"
,
(
getter
)
oss_mode_getter
,
(
setter
)
NULL
,
NULL
},
{
NULL
},
};
static
PyTypeObject
OSSAudioType
=
{
PyVarObject_HEAD_INIT
(
&
PyType_Type
,
0
)
"ossaudiodev.oss_audio_device"
,
/*tp_name*/
...
...
@@ -979,7 +976,7 @@ static PyTypeObject OSSAudioType = {
0
,
/*tp_hash*/
0
,
/*tp_call*/
0
,
/*tp_str*/
(
getattrofunc
)
oss_getattro
,
/*tp_getattro*/
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
0
,
/*tp_as_buffer*/
Py_TPFLAGS_DEFAULT
,
/*tp_flags*/
...
...
@@ -991,6 +988,8 @@ static PyTypeObject OSSAudioType = {
0
,
/*tp_iter*/
0
,
/*tp_iternext*/
oss_methods
,
/*tp_methods*/
oss_members
,
/*tp_members*/
oss_getsetlist
,
/*tp_getset*/
};
static
PyTypeObject
OSSMixerType
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment