Skip to content

Commit c405c0a

Browse files
authored
Merge branch '3.12' into mortal-interns-3.12
2 parents 0b10ee5 + 8edfa0b commit c405c0a

File tree

5 files changed

+93
-21
lines changed

5 files changed

+93
-21
lines changed

Doc/Makefile

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,54 +188,69 @@ dist:
188188
mkdir -p dist
189189

190190
# archive the HTML
191-
make html
191+
@echo "Building HTML..."
192+
$(MAKE) html
192193
cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
193194
tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
194195
bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
195196
(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
196197
rm -r dist/python-$(DISTVERSION)-docs-html
197198
rm dist/python-$(DISTVERSION)-docs-html.tar
199+
@echo "Build finished and archived!"
198200

199201
# archive the text build
200-
make text
202+
@echo "Building text..."
203+
$(MAKE) text
201204
cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
202205
tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
203206
bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
204207
(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
205208
rm -r dist/python-$(DISTVERSION)-docs-text
206209
rm dist/python-$(DISTVERSION)-docs-text.tar
210+
@echo "Build finished and archived!"
207211

208212
# archive the A4 latex
213+
@echo "Building LaTeX (A4 paper)..."
209214
rm -rf build/latex
210-
make latex PAPER=a4
211-
-sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
212-
(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
215+
$(MAKE) latex PAPER=a4
216+
# remove zip & bz2 dependency on all-pdf,
217+
# as otherwise the full latexmk process is run twice.
218+
# ($$ is needed to escape the $; https://www.gnu.org/software/make/manual/make.html#Basics-of-Variable-References)
219+
-sed -i 's/: all-$$(FMT)/:/' build/latex/Makefile
220+
(cd build/latex; $(MAKE) clean && $(MAKE) --jobs=$((`nproc`+1)) --output-sync LATEXMKOPTS='-quiet' all-pdf && $(MAKE) FMT=pdf zip bz2)
213221
cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
214222
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
223+
@echo "Build finished and archived!"
215224

216225
# archive the letter latex
226+
@echo "Building LaTeX (US paper)..."
217227
rm -rf build/latex
218-
make latex PAPER=letter
219-
-sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
220-
(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
228+
$(MAKE) latex PAPER=letter
229+
-sed -i 's/: all-$$(FMT)/:/' build/latex/Makefile
230+
(cd build/latex; $(MAKE) clean && $(MAKE) --jobs=$((`nproc`+1)) --output-sync LATEXMKOPTS='-quiet' all-pdf && $(MAKE) FMT=pdf zip bz2)
221231
cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
222232
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
233+
@echo "Build finished and archived!"
223234

224235
# copy the epub build
236+
@echo "Building EPUB..."
225237
rm -rf build/epub
226-
make epub
238+
$(MAKE) epub
227239
cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
240+
@echo "Build finished and archived!"
228241

229242
# archive the texinfo build
243+
@echo "Building Texinfo..."
230244
rm -rf build/texinfo
231-
make texinfo
232-
make info --directory=build/texinfo
245+
$(MAKE) texinfo
246+
$(MAKE) info --directory=build/texinfo
233247
cp -pPR build/texinfo dist/python-$(DISTVERSION)-docs-texinfo
234248
tar -C dist -cf dist/python-$(DISTVERSION)-docs-texinfo.tar python-$(DISTVERSION)-docs-texinfo
235249
bzip2 -9 -k dist/python-$(DISTVERSION)-docs-texinfo.tar
236250
(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-texinfo.zip python-$(DISTVERSION)-docs-texinfo)
237251
rm -r dist/python-$(DISTVERSION)-docs-texinfo
238252
rm dist/python-$(DISTVERSION)-docs-texinfo.tar
253+
@echo "Build finished and archived!"
239254

240255
.PHONY: _ensure-package
241256
_ensure-package: venv
@@ -247,11 +262,11 @@ _ensure-package: venv
247262

248263
.PHONY: _ensure-pre-commit
249264
_ensure-pre-commit:
250-
make _ensure-package PACKAGE=pre-commit
265+
$(MAKE) _ensure-package PACKAGE=pre-commit
251266

252267
.PHONY: _ensure-sphinx-autobuild
253268
_ensure-sphinx-autobuild:
254-
make _ensure-package PACKAGE=sphinx-autobuild
269+
$(MAKE) _ensure-package PACKAGE=sphinx-autobuild
255270

256271
.PHONY: check
257272
check: _ensure-pre-commit
@@ -271,12 +286,12 @@ serve:
271286
# for development releases: always build
272287
.PHONY: autobuild-dev
273288
autobuild-dev:
274-
make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
289+
$(MAKE) dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
275290

276291
# for quick rebuilds (HTML only)
277292
.PHONY: autobuild-dev-html
278293
autobuild-dev-html:
279-
make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
294+
$(MAKE) html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
280295

281296
# for stable releases: only build if not in pre-release stage (alpha, beta)
282297
# release candidate downloads are okay, since the stable tree can be in that stage
@@ -286,12 +301,12 @@ autobuild-stable:
286301
echo "Not building; $(DISTVERSION) is not a release version."; \
287302
exit 1;; \
288303
esac
289-
@make autobuild-dev
304+
@$(MAKE) autobuild-dev
290305

291306
.PHONY: autobuild-stable-html
292307
autobuild-stable-html:
293308
@case $(DISTVERSION) in *[ab]*) \
294309
echo "Not building; $(DISTVERSION) is not a release version."; \
295310
exit 1;; \
296311
esac
297-
@make autobuild-dev-html
312+
@$(MAKE) autobuild-dev-html

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ iterations of the loop.
14621462

14631463
end = STACK.pop()
14641464
start = STACK.pop()
1465-
STACK.append(slice(start, stop))
1465+
STACK.append(slice(start, end))
14661466

14671467
if it is 3, implements::
14681468

Doc/library/socket.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,13 @@ Constants
695695

696696
.. versionadded:: 3.12
697697

698+
.. data:: SHUT_RD
699+
SHUT_WR
700+
SHUT_RDWR
701+
702+
These constants are used by the :meth:`~socket.socket.shutdown` method of socket objects.
703+
704+
.. availability:: not WASI.
698705

699706
Functions
700707
^^^^^^^^^

Doc/library/struct.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ Notes:
275275
(1)
276276
.. index:: single: ? (question mark); in struct format strings
277277

278-
The ``'?'`` conversion code corresponds to the :c:expr:`_Bool` type defined by
279-
C99. If this type is not available, it is simulated using a :c:expr:`char`. In
280-
standard mode, it is always represented by one byte.
278+
The ``'?'`` conversion code corresponds to the :c:expr:`_Bool` type
279+
defined by C standards since C99. In standard mode, it is
280+
represented by one byte.
281281

282282
(2)
283283
When attempting to pack a non-integer using any of the integer conversion

Lib/test/test_inspect/test_inspect.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,56 @@ def f(self):
13641364
self.assertIn(('f', b.f), inspect.getmembers(b))
13651365
self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
13661366

1367+
def test_getmembers_custom_dir(self):
1368+
class CorrectDir:
1369+
def __init__(self, attr):
1370+
self.attr = attr
1371+
def method(self):
1372+
return self.attr + 1
1373+
def __dir__(self):
1374+
return ['attr', 'method']
1375+
1376+
cd = CorrectDir(5)
1377+
self.assertEqual(inspect.getmembers(cd), [
1378+
('attr', 5),
1379+
('method', cd.method),
1380+
])
1381+
self.assertEqual(inspect.getmembers(cd, inspect.ismethod), [
1382+
('method', cd.method),
1383+
])
1384+
1385+
def test_getmembers_custom_broken_dir(self):
1386+
# inspect.getmembers calls `dir()` on the passed object inside.
1387+
# if `__dir__` mentions some non-existent attribute,
1388+
# we still need to return others correctly.
1389+
class BrokenDir:
1390+
existing = 1
1391+
def method(self):
1392+
return self.existing + 1
1393+
def __dir__(self):
1394+
return ['method', 'missing', 'existing']
1395+
1396+
bd = BrokenDir()
1397+
self.assertEqual(inspect.getmembers(bd), [
1398+
('existing', 1),
1399+
('method', bd.method),
1400+
])
1401+
self.assertEqual(inspect.getmembers(bd, inspect.ismethod), [
1402+
('method', bd.method),
1403+
])
1404+
1405+
def test_getmembers_custom_duplicated_dir(self):
1406+
# Duplicates in `__dir__` must not fail and return just one result.
1407+
class DuplicatedDir:
1408+
attr = 1
1409+
def __dir__(self):
1410+
return ['attr', 'attr']
1411+
1412+
dd = DuplicatedDir()
1413+
self.assertEqual(inspect.getmembers(dd), [
1414+
('attr', 1),
1415+
])
1416+
13671417
def test_getmembers_VirtualAttribute(self):
13681418
class M(type):
13691419
def __getattr__(cls, name):

0 commit comments

Comments
 (0)