Skip to content

Commit

Permalink
Merge branch 'main' into test-inspect-ismethoddescriptor-isdatadescri…
Browse files Browse the repository at this point in the history
…ptor
  • Loading branch information
zuo committed Aug 5, 2024
2 parents ec79a04 + 1422500 commit 8e2ea46
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
trigger: ['main', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7']
trigger: ['main', '3.13', '3.12', '3.11', '3.10', '3.9', '3.8']

jobs:
- job: Prebuild
Expand Down
36 changes: 20 additions & 16 deletions Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# You can set these variables from the command line.
PYTHON = python3
VENVDIR = ./venv
UV = uv
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
JOBS = auto
Expand Down Expand Up @@ -150,14 +151,10 @@ gettext: build
htmlview: html
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"

.PHONY: ensure-sphinx-autobuild
ensure-sphinx-autobuild: venv
$(call ensure_package,sphinx-autobuild)

.PHONY: htmllive
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
htmllive: SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
htmllive: ensure-sphinx-autobuild html
htmllive: _ensure-sphinx-autobuild html

.PHONY: clean
clean: clean-venv
Expand All @@ -174,15 +171,15 @@ venv:
echo "To recreate it, remove it first with \`make clean-venv'."; \
else \
echo "Creating venv in $(VENVDIR)"; \
if uv --version > /dev/null; then \
uv venv $(VENVDIR); \
VIRTUAL_ENV=$(VENVDIR) uv pip install -r $(REQUIREMENTS); \
if $(UV) --version >/dev/null 2>&1; then \
$(UV) venv $(VENVDIR); \
VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS); \
else \
$(PYTHON) -m venv $(VENVDIR); \
$(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
$(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \
echo "The venv has been created in the $(VENVDIR) directory"; \
fi; \
echo "The venv has been created in the $(VENVDIR) directory"; \
fi

.PHONY: dist
Expand Down Expand Up @@ -240,17 +237,24 @@ dist:
rm -r dist/python-$(DISTVERSION)-docs-texinfo
rm dist/python-$(DISTVERSION)-docs-texinfo.tar

define ensure_package
if uv --version > /dev/null; then \
$(VENVDIR)/bin/python3 -m $(1) --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install $(1); \
.PHONY: _ensure-package
_ensure-package: venv
if $(UV) --version >/dev/null 2>&1; then \
VIRTUAL_ENV=$(VENVDIR) $(UV) pip install $(PACKAGE); \
else \
$(VENVDIR)/bin/python3 -m $(1) --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install $(1); \
$(VENVDIR)/bin/python3 -m pip install $(PACKAGE); \
fi
endef

.PHONY: _ensure-pre-commit
_ensure-pre-commit:
make _ensure-package PACKAGE=pre-commit

.PHONY: _ensure-sphinx-autobuild
_ensure-sphinx-autobuild:
make _ensure-package PACKAGE=sphinx-autobuild

.PHONY: check
check: venv
$(call ensure_package,pre_commit)
check: _ensure-pre-commit
$(VENVDIR)/bin/python3 -m pre_commit run --all-files

.PHONY: serve
Expand Down
9 changes: 7 additions & 2 deletions Doc/c-api/bytearray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ Direct API functions
Return a new bytearray object from any object, *o*, that implements the
:ref:`buffer protocol <bufferobjects>`.
On failure, return ``NULL`` with an exception set.
.. c:function:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
Create a new bytearray object from *string* and its length, *len*. On
failure, ``NULL`` is returned.
Create a new bytearray object from *string* and its length, *len*.
On failure, return ``NULL`` with an exception set.
.. c:function:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
Concat bytearrays *a* and *b* and return a new bytearray with the result.
On failure, return ``NULL`` with an exception set.
.. c:function:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
Expand Down
12 changes: 8 additions & 4 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1081,11 +1081,15 @@ iterations of the loop.
.. opcode:: BUILD_TUPLE (count)

Creates a tuple consuming *count* items from the stack, and pushes the
resulting tuple onto the stack.::
resulting tuple onto the stack::

assert count > 0
STACK, values = STACK[:-count], STACK[-count:]
STACK.append(tuple(values))
if count == 0:
value = ()
else:
STACK = STACK[:-count]
value = tuple(STACK[-count:])

STACK.append(value)


.. opcode:: BUILD_LIST (count)
Expand Down
28 changes: 14 additions & 14 deletions Lib/test/mathdata/cmath_testcases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ acosh1002 acosh 0.0 inf -> inf 1.5707963267948966
acosh1003 acosh 2.3 inf -> inf 1.5707963267948966
acosh1004 acosh -0.0 inf -> inf 1.5707963267948966
acosh1005 acosh -2.3 inf -> inf 1.5707963267948966
acosh1006 acosh 0.0 nan -> nan nan
acosh1006 acosh 0.0 nan -> nan 1.5707963267948966 ignore-imag-sign
acosh1007 acosh 2.3 nan -> nan nan
acosh1008 acosh -0.0 nan -> nan nan
acosh1008 acosh -0.0 nan -> nan 1.5707963267948966 ignore-imag-sign
acosh1009 acosh -2.3 nan -> nan nan
acosh1010 acosh -inf 0.0 -> inf 3.1415926535897931
acosh1011 acosh -inf 2.3 -> inf 3.1415926535897931
Expand Down Expand Up @@ -1992,9 +1992,9 @@ tanh0065 tanh 1.797e+308 0.0 -> 1.0 0.0

--special values
tanh1000 tanh 0.0 0.0 -> 0.0 0.0
tanh1001 tanh 0.0 inf -> nan nan invalid
tanh1001 tanh 0.0 inf -> 0.0 nan invalid
tanh1002 tanh 2.3 inf -> nan nan invalid
tanh1003 tanh 0.0 nan -> nan nan
tanh1003 tanh 0.0 nan -> 0.0 nan
tanh1004 tanh 2.3 nan -> nan nan
tanh1005 tanh inf 0.0 -> 1.0 0.0
tanh1006 tanh inf 0.7 -> 1.0 0.0
Expand All @@ -2009,7 +2009,7 @@ tanh1014 tanh nan 2.3 -> nan nan
tanh1015 tanh nan inf -> nan nan
tanh1016 tanh nan nan -> nan nan
tanh1017 tanh 0.0 -0.0 -> 0.0 -0.0
tanh1018 tanh 0.0 -inf -> nan nan invalid
tanh1018 tanh 0.0 -inf -> 0.0 nan invalid
tanh1019 tanh 2.3 -inf -> nan nan invalid
tanh1020 tanh inf -0.0 -> 1.0 -0.0
tanh1021 tanh inf -0.7 -> 1.0 -0.0
Expand All @@ -2022,9 +2022,9 @@ tanh1027 tanh nan -0.0 -> nan -0.0
tanh1028 tanh nan -2.3 -> nan nan
tanh1029 tanh nan -inf -> nan nan
tanh1030 tanh -0.0 -0.0 -> -0.0 -0.0
tanh1031 tanh -0.0 -inf -> nan nan invalid
tanh1031 tanh -0.0 -inf -> -0.0 nan invalid
tanh1032 tanh -2.3 -inf -> nan nan invalid
tanh1033 tanh -0.0 nan -> nan nan
tanh1033 tanh -0.0 nan -> -0.0 nan
tanh1034 tanh -2.3 nan -> nan nan
tanh1035 tanh -inf -0.0 -> -1.0 -0.0
tanh1036 tanh -inf -0.7 -> -1.0 -0.0
Expand All @@ -2035,7 +2035,7 @@ tanh1040 tanh -inf -3.5 -> -1.0 -0.0
tanh1041 tanh -inf -inf -> -1.0 0.0 ignore-imag-sign
tanh1042 tanh -inf nan -> -1.0 0.0 ignore-imag-sign
tanh1043 tanh -0.0 0.0 -> -0.0 0.0
tanh1044 tanh -0.0 inf -> nan nan invalid
tanh1044 tanh -0.0 inf -> -0.0 nan invalid
tanh1045 tanh -2.3 inf -> nan nan invalid
tanh1046 tanh -inf 0.0 -> -1.0 0.0
tanh1047 tanh -inf 0.7 -> -1.0 0.0
Expand Down Expand Up @@ -2307,9 +2307,9 @@ tan0066 tan -8.79645943005142 0.0 -> 0.7265425280053614098 0.0

-- special values
tan1000 tan -0.0 0.0 -> -0.0 0.0
tan1001 tan -inf 0.0 -> nan nan invalid
tan1001 tan -inf 0.0 -> nan 0.0 invalid
tan1002 tan -inf 2.2999999999999998 -> nan nan invalid
tan1003 tan nan 0.0 -> nan nan
tan1003 tan nan 0.0 -> nan 0.0
tan1004 tan nan 2.2999999999999998 -> nan nan
tan1005 tan -0.0 inf -> -0.0 1.0
tan1006 tan -0.69999999999999996 inf -> -0.0 1.0
Expand All @@ -2324,7 +2324,7 @@ tan1014 tan -2.2999999999999998 nan -> nan nan
tan1015 tan -inf nan -> nan nan
tan1016 tan nan nan -> nan nan
tan1017 tan 0.0 0.0 -> 0.0 0.0
tan1018 tan inf 0.0 -> nan nan invalid
tan1018 tan inf 0.0 -> nan 0.0 invalid
tan1019 tan inf 2.2999999999999998 -> nan nan invalid
tan1020 tan 0.0 inf -> 0.0 1.0
tan1021 tan 0.69999999999999996 inf -> 0.0 1.0
Expand All @@ -2337,9 +2337,9 @@ tan1027 tan 0.0 nan -> 0.0 nan
tan1028 tan 2.2999999999999998 nan -> nan nan
tan1029 tan inf nan -> nan nan
tan1030 tan 0.0 -0.0 -> 0.0 -0.0
tan1031 tan inf -0.0 -> nan nan invalid
tan1031 tan inf -0.0 -> nan -0.0 invalid
tan1032 tan inf -2.2999999999999998 -> nan nan invalid
tan1033 tan nan -0.0 -> nan nan
tan1033 tan nan -0.0 -> nan -0.0
tan1034 tan nan -2.2999999999999998 -> nan nan
tan1035 tan 0.0 -inf -> 0.0 -1.0
tan1036 tan 0.69999999999999996 -inf -> 0.0 -1.0
Expand All @@ -2350,7 +2350,7 @@ tan1040 tan 3.5 -inf -> 0.0 -1.0
tan1041 tan inf -inf -> -0.0 -1.0 ignore-real-sign
tan1042 tan nan -inf -> -0.0 -1.0 ignore-real-sign
tan1043 tan -0.0 -0.0 -> -0.0 -0.0
tan1044 tan -inf -0.0 -> nan nan invalid
tan1044 tan -inf -0.0 -> nan -0.0 invalid
tan1045 tan -inf -2.2999999999999998 -> nan nan invalid
tan1046 tan -0.0 -inf -> -0.0 -1.0
tan1047 tan -0.69999999999999996 -inf -> -0.0 -1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adjusts ``cmath.acosh(complex('0+nanj'))`` for recent C standards.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adjust ``cmath.tanh(nanj)`` and ``cmath.tanh(infj)`` for recent C standards.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Windows build of CPython now requires 3.10 or newer.
8 changes: 4 additions & 4 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,8 @@ cmath_exec(PyObject *mod)
INIT_SPECIAL_VALUES(acosh_special_values, {
C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,P12)
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,P12)
C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)
Expand Down Expand Up @@ -1339,8 +1339,8 @@ cmath_exec(PyObject *mod)
INIT_SPECIAL_VALUES(tanh_special_values, {
C(-1.,0.) C(U,U) C(-1.,-0.) C(-1.,0.) C(U,U) C(-1.,0.) C(-1.,0.)
C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
C(N,N) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(N,N) C(N,N)
C(N,N) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(N,N) C(N,N)
C(-0.0,N) C(U,U) C(-0.,-0.) C(-0.,0.) C(U,U) C(-0.0,N) C(-0.,N)
C(0.0,N) C(U,U) C(0.,-0.) C(0.,0.) C(U,U) C(0.0,N) C(0.,N)
C(N,N) C(U,U) C(U,U) C(U,U) C(U,U) C(N,N) C(N,N)
C(1.,0.) C(U,U) C(1.,-0.) C(1.,0.) C(U,U) C(1.,0.) C(1.,0.)
C(N,N) C(N,N) C(N,-0.) C(N,0.) C(N,N) C(N,N) C(N,N)
Expand Down
6 changes: 3 additions & 3 deletions PCbuild/find_python.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
@if "%_Py_EXTERNALS_DIR%"=="" (set _Py_EXTERNALS_DIR=%_Py_D%\..\externals)

@rem If we have Python in externals, use that one
@if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" ("%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" -Ec "import sys; assert sys.version_info[:2] >= (3, 8)" >nul 2>nul) && (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") && (set _Py_Python_Source=found in externals directory) && goto :found || rmdir /Q /S "%_Py_EXTERNALS_DIR%\pythonx86"
@if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" ("%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" -Ec "import sys; assert sys.version_info[:2] >= (3, 10)" >nul 2>nul) && (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") && (set _Py_Python_Source=found in externals directory) && goto :found || rmdir /Q /S "%_Py_EXTERNALS_DIR%\pythonx86"

@rem If HOST_PYTHON is recent enough, use that
@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -Ec "import sys; assert sys.version_info[:2] >= (3, 9)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found
@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -Ec "import sys; assert sys.version_info[:2] >= (3, 10)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found

@rem If py.exe finds a recent enough version, use that one
@rem It is fine to add new versions to this list when they have released,
@rem but we do not use prerelease builds here.
@for %%p in (3.12 3.11 3.10 3.9) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found
@for %%p in (3.12 3.11 3.10) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found

@if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%"
@set _Py_NUGET=%NUGET%
Expand Down
4 changes: 3 additions & 1 deletion Tools/clinic/libclinic/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,9 @@ def closure(f: CConverterClassT) -> CConverterClassT:
if not kwargs:
added_f = f
else:
added_f = functools.partial(f, **kwargs)
# type ignore due to a mypy regression :(
# https://github.com/python/mypy/issues/17646
added_f = functools.partial(f, **kwargs) # type: ignore[misc]
if format_unit:
legacy_converters[format_unit] = added_f
return f
Expand Down
2 changes: 1 addition & 1 deletion Tools/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Requirements file for external linters and checks we run on
# Tools/clinic, Tools/cases_generator/, and Tools/peg_generator/ in CI
mypy==1.10.1
mypy==1.11.1

# needed for peg_generator:
types-psutil==6.0.0.20240621
Expand Down

0 comments on commit 8e2ea46

Please sign in to comment.