Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Tools/c-analyzer/must-resolve.sh
12 views
1
#!/usr/bin/env bash
2
3
# Any PyObject exposed via the public API is problematic since it must
4
# be made per-interpreter. This involves the following:
5
#
6
# singletons:
7
# - None
8
# - True
9
# - False
10
# - NotImplemented
11
# - Ellipsis
12
# PyTypeObject:
13
# - PyExc* [97]
14
# - static types [81]
15
#
16
# In the non-stable API we could use #defines to do the conversion
17
# transparently (though Py_None is perhaps problematic for performance
18
# reasons). However, we can't take that approach with the stable API.
19
# That means we must find all functions (& macros) in the stable API
20
# (and probably the full public API, for sanity sake) and adjust them.
21
# This will involve internally converting from the public object to the
22
# corresponding per-interpreter object.
23
#
24
# Note that the only place this solution fails is with direct pointer
25
# equality checks with the public objects.
26
27
# XXX What about saying that the stable API is not sub-interpreter
28
# compatible?
29
30
31
function run_capi() {
32
./python Tools/c-analyzer/c-analyzer.py capi \
33
--no-progress \
34
--group-by kind \
35
--func --inline --macro \
36
--no-show-empty \
37
--ignore '<must-resolve.ignored>' \
38
$@
39
}
40
41
echo ''
42
echo '#################################################'
43
echo '# All API'
44
echo '#################################################'
45
run_capi --format summary Include/*.h Include/cpython/*.h
46
run_capi --format table Include/*.h Include/cpython/*.h
47
echo ''
48
echo ''
49
echo '#################################################'
50
echo '# stable API'
51
echo '#################################################'
52
echo ''
53
echo '# public:'
54
run_capi --format summary --public --no-show-empty Include/*.h
55
echo ''
56
echo '# private:'
57
run_capi --format summary --private --no-show-empty Include/*.h
58
echo ''
59
run_capi --format full -v Include/*.h
60
#run_capi --format full -v --public Include/*.h
61
#run_capi --format full -v --private Include/*.h
62
echo ''
63
echo '#################################################'
64
echo '# cpython API'
65
echo '#################################################'
66
echo ''
67
echo '# public:'
68
run_capi --format summary --public --no-show-empty Include/cpython/*.h
69
echo ''
70
echo '# private:'
71
run_capi --format summary --private --no-show-empty Include/cpython/*.h
72
echo ''
73
run_capi --format full -v Include/cpython/*.h
74
#run_capi --format full -v --public Include/cpython/*.h
75
#run_capi --format full -v --private Include/cpython/*.h
76
77