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
40a5313e
Commit
40a5313e
authored
Sep 10, 2019
by
Dino Viehland
Committed by
T. Wouters
Sep 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38072: PEP-384 grpmodule (GH-15788)
Make the grp module PEP-384 compliant.
parent
9e610663
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
19 deletions
+41
-19
Misc/NEWS.d/next/Core and Builtins/2019-09-09-15-00-42.bpo-38072.Y1xpDO.rst
...ore and Builtins/2019-09-09-15-00-42.bpo-38072.Y1xpDO.rst
+1
-0
Modules/grpmodule.c
Modules/grpmodule.c
+40
-19
No files found.
Misc/NEWS.d/next/Core and Builtins/2019-09-09-15-00-42.bpo-38072.Y1xpDO.rst
0 → 100644
View file @
40a5313e
grp module made PEP-384 compatible
\ No newline at end of file
Modules/grpmodule.c
View file @
40a5313e
...
...
@@ -34,8 +34,13 @@ static PyStructSequence_Desc struct_group_type_desc = {
};
static
int
initialized
;
static
PyTypeObject
StructGrpType
;
typedef
struct
{
PyTypeObject
*
StructGrpType
;
}
grpmodulestate
;
#define modulestate(o) ((grpmodulestate *)PyModule_GetState(o))
#define modulestate_global modulestate(PyState_FindModule(&grpmodule))
static
struct
PyModuleDef
grpmodule
;
#define DEFAULT_BUFFER_SIZE 1024
...
...
@@ -43,10 +48,10 @@ static PyObject *
mkgrent
(
struct
group
*
p
)
{
int
setIndex
=
0
;
PyObject
*
v
=
PyStructSequence_New
(
&
StructGrpType
)
,
*
w
;
PyObject
*
v
,
*
w
;
char
**
member
;
if
(
v
==
NULL
)
if
(
(
v
=
PyStructSequence_New
(
modulestate_global
->
StructGrpType
))
==
NULL
)
return
NULL
;
if
((
w
=
PyList_New
(
0
))
==
NULL
)
{
...
...
@@ -314,36 +319,52 @@ users are not explicitly listed as members of the groups they are in\n\
according to the password database. Check both databases to get
\n
\
complete membership information.)"
);
static
int
grpmodule_traverse
(
PyObject
*
m
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
modulestate
(
m
)
->
StructGrpType
);
return
0
;
}
static
int
grpmodule_clear
(
PyObject
*
m
)
{
Py_CLEAR
(
modulestate
(
m
)
->
StructGrpType
);
return
0
;
}
static
void
grpmodule_free
(
void
*
m
)
{
grpmodule_clear
((
PyObject
*
)
m
);
}
static
struct
PyModuleDef
grpmodule
=
{
PyModuleDef_HEAD_INIT
,
"grp"
,
grp__doc__
,
-
1
,
sizeof
(
grpmodulestate
)
,
grp_methods
,
NULL
,
NULL
,
NULL
,
NULL
grpmodule_traverse
,
grpmodule_clear
,
grpmodule_free
,
};
PyMODINIT_FUNC
PyInit_grp
(
void
)
{
PyObject
*
m
,
*
d
;
m
=
PyModule_Create
(
&
grpmodule
);
if
(
m
==
NULL
)
PyObject
*
m
;
if
((
m
=
PyState_FindModule
(
&
grpmodule
))
!=
NULL
)
{
Py_INCREF
(
m
);
return
m
;
}
if
((
m
=
PyModule_Create
(
&
grpmodule
))
==
NULL
)
{
return
NULL
;
d
=
PyModule_GetDict
(
m
);
if
(
!
initialized
)
{
if
(
PyStructSequence_InitType2
(
&
StructGrpType
,
&
struct_group_type_desc
)
<
0
)
return
NULL
;
}
if
(
PyDict_SetItemString
(
d
,
"struct_group"
,
(
PyObject
*
)
&
StructGrpType
)
<
0
)
grpmodulestate
*
state
=
PyModule_GetState
(
m
);
state
->
StructGrpType
=
PyStructSequence_NewType
(
&
struct_group_type_desc
);
if
(
state
->
StructGrpType
==
NULL
)
{
return
NULL
;
initialized
=
1
;
}
Py_INCREF
(
state
->
StructGrpType
);
PyModule_AddObject
(
m
,
"struct_group"
,
(
PyObject
*
)
state
->
StructGrpType
);
return
m
;
}
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