[ Web Proxy ]
URL:
Viewing:
https://github-redirect.dependabot.com/python/cpython/blob/main/Modules/_testcapi/list.c
[Back]
[Original]
cpython/Modules/_testcapi/list.c at main python/cpython GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
[]
[]
GitHub
Repository hosting, code review, and collaboration
[]
[]
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
[]
[]
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
[]
[]
GitHub Universe
The event for developers, by developers talks, workshops, and whats next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
python
cpython
Repository navigation
Code
Issues
5k+
(5k+)
Pull requests
2.3k
(2.3k)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
cpython
/
Modules
/
_testcapi
/
list.c
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
120 lines (102 loc) 2.71 KB
main
Breadcrumbs
cpython
/
Modules
/
_testcapi
/
list.c
Copy path
Top
File metadata and controls
Code
Blame
120 lines (102 loc) 2.71 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include
"parts.h"
#include
"util.h"
static
PyObject
*
list_get_size
(
PyObject
*
Py_UNUSED
(
module
),
PyObject
*
obj
)
{
NULLABLE
(
obj
);
RETURN_SIZE
(
PyList_GET_SIZE
(
obj
));
}
static
PyObject
*
list_get_item
(
PyObject
*
Py_UNUSED
(
module
),
PyObject
*
args
)
{
PyObject
*
obj
;
Py_ssize_t
i
;
if
(!
PyArg_ParseTuple
(
args
,
"On"
,
&
obj
,
&
i
)) {
return
NULL
;
}
NULLABLE
(
obj
);
return
Py_XNewRef
(
PyList_GET_ITEM
(
obj
,
i
));
}
static
PyObject
*
list_set_item
(
PyObject
*
Py_UNUSED
(
module
),
PyObject
*
args
)
{
PyObject
*
obj
,
*
value
;
Py_ssize_t
i
;
if
(!
PyArg_ParseTuple
(
args
,
"OnO"
,
&
obj
,
&
i
,
&
value
)) {
return
NULL
;
}
NULLABLE
(
obj
);
NULLABLE
(
value
);
PyList_SET_ITEM
(
obj
,
i
,
Py_XNewRef
(
value
));
Py_RETURN_NONE
;
}
static
PyObject
*
list_clear
(
PyObject
*
Py_UNUSED
(
module
),
PyObject
*
obj
)
{
NULLABLE
(
obj
);
RETURN_INT
(
PyList_Clear
(
obj
));
}
static
PyObject
*
list_extend
(
PyObject
*
Py_UNUSED
(
module
),
PyObject
*
args
)
{
PyObject
*
obj
,
*
arg
;
if
(!
PyArg_ParseTuple
(
args
,
"OO"
,
&
obj
,
&
arg
)) {
return
NULL
;
}
NULLABLE
(
obj
);
NULLABLE
(
arg
);
RETURN_INT
(
PyList_Extend
(
obj
,
arg
));
}
static
PyObject
*
test_list_api
(
PyObject
*
self
,
PyObject
*
Py_UNUSED
(
ignored
))
{
PyObject
*
list
;
int
i
;
/* SF bug 132008: PyList_Reverse segfaults */
#define
NLIST
30
list
=
PyList_New
(
NLIST
);
if
(
list
==
(
PyObject
*
)
NULL
)
return
(
PyObject
*
)
NULL
;
/* list = range(NLIST) */
for
(
i
=
0
;
i
<
NLIST
;
++
i
) {
PyObject
*
anint
=
PyLong_FromLong
(
i
);
if
(
anint
==
(
PyObject
*
)
NULL
) {
Py_DECREF
(
list
);
return
(
PyObject
*
)
NULL
;
}
PyList_SET_ITEM
(
list
,
i
,
anint
);
}
/* list.reverse(), via PyList_Reverse() */
i
=
PyList_Reverse
(
list
);
/* should not blow up! */
if
(
i
!=
0
) {
Py_DECREF
(
list
);
return
(
PyObject
*
)
NULL
;
}
/* Check that list == range(29, -1, -1) now */
for
(
i
=
0
;
i
<
NLIST
;
++
i
) {
PyObject
*
anint
=
PyList_GET_ITEM
(
list
,
i
);
if
(
PyLong_AS_LONG
(
anint
)
!=
NLIST
-
1
-
i
) {
PyErr_SetString
(
PyExc_AssertionError
,
"test_list_api: reverse screwed up"
);
Py_DECREF
(
list
);
return
(
PyObject
*
)
NULL
;
}
}
Py_DECREF
(
list
);
#undef
NLIST
Py_RETURN_NONE
;
}
static
PyMethodDef
test_methods
[]
=
{
{
"list_get_size"
,
list_get_size
,
METH_O
},
{
"list_get_item"
,
list_get_item
,
METH_VARARGS
},
{
"list_set_item"
,
list_set_item
,
METH_VARARGS
},
{
"list_clear"
,
list_clear
,
METH_O
},
{
"list_extend"
,
list_extend
,
METH_VARARGS
},
{
"test_list_api"
,
test_list_api
,
METH_NOARGS
},
{
NULL
},
};
int
_PyTestCapi_Init_List
(
PyObject
*
m
)
{
return
PyModule_AddFunctions
(
m
,
test_methods
);
}
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
Manage cookies
Do not share my personal information
You cant perform that action at this time.
Web Proxy Viewer |
New URL
|
Original Page