Skip to content

Commit f47a400

Browse files
committed
Issue #25533: Update documentation regarding the frozen modules table
* "ctypes" documentation was using Python 2 bytes-str equivalence. * PyImport_FrozenModules is a pointer to const as of Python 3.4
1 parent 2dc1bbb commit f47a400

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

Doc/c-api/import.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Importing Modules
272272
};
273273
274274
275-
.. c:var:: struct _frozen* PyImport_FrozenModules
275+
.. c:var:: const struct _frozen* PyImport_FrozenModules
276276
277277
This pointer is initialized to point to an array of :c:type:`struct _frozen`
278278
records, terminated by one whose members are all *NULL* or zero. When a frozen

Doc/library/ctypes.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -1100,14 +1100,15 @@ access violation or whatever, so it's better to break out of the loop when we
11001100
hit the NULL entry::
11011101

11021102
>>> for item in table:
1103-
... print(item.name, item.size)
11041103
... if item.name is None:
11051104
... break
1105+
... print(item.name.decode("ascii"), item.size)
11061106
...
1107-
__hello__ 104
1108-
__phello__ -104
1109-
__phello__.spam 104
1110-
None 0
1107+
_frozen_importlib 31764
1108+
_frozen_importlib_external 41499
1109+
__hello__ 161
1110+
__phello__ -161
1111+
__phello__.spam 161
11111112
>>>
11121113

11131114
The fact that standard Python has a frozen module and a frozen package

Doc/library/pkgutil.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ support.
140140
.. function:: iter_modules(path=None, prefix='')
141141

142142
Yields ``(module_finder, name, ispkg)`` for all submodules on *path*, or, if
143-
path is ``None``, all top-level modules on ``sys.path``.
143+
*path* is ``None``, all top-level modules on ``sys.path``.
144144

145145
*path* should be either ``None`` or a list of paths to look for modules in.
146146

@@ -161,7 +161,7 @@ support.
161161
.. function:: walk_packages(path=None, prefix='', onerror=None)
162162

163163
Yields ``(module_finder, name, ispkg)`` for all modules recursively on
164-
*path*, or, if path is ``None``, all accessible modules.
164+
*path*, or, if *path* is ``None``, all accessible modules.
165165

166166
*path* should be either ``None`` or a list of paths to look for modules in.
167167

Lib/ctypes/test/test_values.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ class struct_frozen(Structure):
7777
self.assertTrue(entry.size,
7878
"{!r} was reported as having no size".format(entry.name))
7979
continue
80-
items.append((entry.name, entry.size))
80+
items.append((entry.name.decode("ascii"), entry.size))
8181

82-
expected = [(b"__hello__", 161),
83-
(b"__phello__", -161),
84-
(b"__phello__.spam", 161),
82+
expected = [("__hello__", 161),
83+
("__phello__", -161),
84+
("__phello__.spam", 161),
8585
]
86-
self.assertEqual(items, expected)
86+
self.assertEqual(items, expected, "PyImport_FrozenModules example "
87+
"in Doc/library/ctypes.rst may be out of date")
8788

8889
self.assertEqual(sorted(bootstrap_seen), bootstrap_expected,
8990
"frozen bootstrap modules did not match PyImport_FrozenModules")

0 commit comments

Comments
 (0)