Skip to content

Commit

Permalink
Merge in main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Apr 28, 2023
2 parents 1701688 + 81387fe commit db5d49b
Show file tree
Hide file tree
Showing 55 changed files with 594 additions and 376 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Objects/frameobject.c @markshannon
Objects/call.c @markshannon
Python/ceval.c @markshannon
Python/compile.c @markshannon @iritkatriel
Python/assemble.c @markshannon @iritkatriel
Python/flowgraph.c @markshannon @iritkatriel
Python/ast_opt.c @isidentical
Lib/test/test_patma.py @brandtbucher
Lib/test/test_peepholer.py @brandtbucher
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ jobs:
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
# This build doesn't use problem matchers or check annotations
# It also does not run 'make check', as sphinx-lint is not installed into the
# environment.
build_doc_oldest_supported_sphinx:
name: 'Docs (Oldest Sphinx)'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: '3.11' # known to work with Sphinx 3.2
cache: 'pip'
cache-dependency-path: 'Doc/requirements-oldest-sphinx.txt'
- name: 'Install build dependencies'
run: make -C Doc/ venv REQUIREMENTS="requirements-oldest-sphinx.txt"
- name: 'Build HTML documentation'
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html

# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
doctest:
name: 'Doctest'
Expand Down
5 changes: 3 additions & 2 deletions Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ JOBS = auto
PAPER =
SOURCES =
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
REQUIREMENTS = requirements.txt
SPHINXERRORHANDLING = -W

# Internal variables.
Expand Down Expand Up @@ -154,8 +155,8 @@ venv:
echo "To recreate it, remove it first with \`make clean-venv'."; \
else \
$(PYTHON) -m venv $(VENVDIR); \
$(VENVDIR)/bin/python3 -m pip install -U pip setuptools; \
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
$(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

Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)

.. data:: Py_TPFLAGS_MANAGED_DICT

This bit indicates that instances of the class have a ``__dict___``
This bit indicates that instances of the class have a ``__dict__``
attribute, and that the space for the dictionary is managed by the VM.

If this flag is set, :const:`Py_TPFLAGS_HAVE_GC` should also be set.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/__main__.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ This is where using the ``if __name__ == '__main__'`` code block comes in
handy. Code within this block won't run unless the module is executed in the
top-level environment.

Putting as few statements as possible in the block below ``if __name___ ==
Putting as few statements as possible in the block below ``if __name__ ==
'__main__'`` can improve code clarity and correctness. Most often, a function
named ``main`` encapsulates the program's primary behavior::

Expand Down
9 changes: 7 additions & 2 deletions Doc/library/asyncio-subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ their completion.
Interact with process:

1. send data to *stdin* (if *input* is not ``None``);
2. read data from *stdout* and *stderr*, until EOF is reached;
3. wait for process to terminate.
2. closes *stdin*;
3. read data from *stdout* and *stderr*, until EOF is reached;
4. wait for process to terminate.

The optional *input* argument is the data (:class:`bytes` object)
that will be sent to the child process.
Expand All @@ -229,6 +230,10 @@ their completion.
Note, that the data read is buffered in memory, so do not use
this method if the data size is large or unlimited.

.. versionchanged:: 3.12

*stdin* gets closed when `input=None` too.

.. method:: send_signal(signal)

Sends the signal *signal* to the child process.
Expand Down
8 changes: 8 additions & 0 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,10 @@ Other constructors, all class methods:
in UTC. As such, the recommended way to create an object representing the
current time in UTC is by calling ``datetime.now(timezone.utc)``.

.. deprecated:: 3.12

Use :meth:`datetime.now` with :attr:`UTC` instead.


.. classmethod:: datetime.fromtimestamp(timestamp, tz=None)

Expand Down Expand Up @@ -964,6 +968,10 @@ Other constructors, all class methods:
:c:func:`gmtime` function. Raise :exc:`OSError` instead of
:exc:`ValueError` on :c:func:`gmtime` failure.

.. deprecated:: 3.12

Use :meth:`datetime.fromtimestamp` with :attr:`UTC` instead.


.. classmethod:: datetime.fromordinal(ordinal)

Expand Down
17 changes: 12 additions & 5 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Module functions
to avoid data corruption.
See :attr:`threadsafety` for more information.

:param Connection factory:
:param ~sqlite3.Connection factory:
A custom subclass of :class:`Connection` to create the connection with,
if not the default :class:`Connection` class.

Expand All @@ -337,7 +337,7 @@ Module functions
The default will change to ``False`` in a future Python release.
:type autocommit: bool

:rtype: Connection
:rtype: ~sqlite3.Connection

.. audit-event:: sqlite3.connect database sqlite3.connect
.. audit-event:: sqlite3.connect/handle connection_handle sqlite3.connect
Expand Down Expand Up @@ -1129,7 +1129,7 @@ Connection objects
Works even if the database is being accessed by other clients
or concurrently by the same connection.

:param Connection target:
:param ~sqlite3.Connection target:
The database connection to save the backup to.

:param int pages:
Expand Down Expand Up @@ -1530,12 +1530,12 @@ Cursor objects

For every item in *parameters*,
repeatedly execute the :ref:`parameterized <sqlite3-placeholders>`
SQL statement *sql*.
:abbr:`DML (Data Manipulation Language)` SQL statement *sql*.

Uses the same implicit transaction handling as :meth:`~Cursor.execute`.

:param str sql:
A single SQL :abbr:`DML (Data Manipulation Language)` statement.
A single SQL DML statement.

:param parameters:
An :term:`!iterable` of parameters to bind with
Expand All @@ -1558,6 +1558,13 @@ Cursor objects
# cur is an sqlite3.Cursor object
cur.executemany("INSERT INTO data VALUES(?)", rows)

.. note::

Any resulting rows are discarded,
including DML statements with `RETURNING clauses`_.

.. _RETURNING clauses: https://www.sqlite.org/lang_returning.html

.. deprecated-removed:: 3.12 3.14

:exc:`DeprecationWarning` is emitted if
Expand Down
38 changes: 38 additions & 0 deletions Doc/requirements-oldest-sphinx.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Requirements to build the Python documentation, for the oldest supported
# Sphinx version.
#
# We pin Sphinx and all of its dependencies to ensure a consistent environment.

blurb
python-docs-theme>=2022.1

# Generated from:
# pip install "Sphinx~=3.2.0" "docutils<0.17" "Jinja2<3" "MarkupSafe<2"
# pip freeze
#
# Sphinx 3.2 comes from ``needs_sphinx = '3.2'`` in ``Doc/conf.py``.
# Docutils<0.17, Jinja2<3, and MarkupSafe<2 are additionally specified as
# Sphinx 3.2 is incompatible with newer releases of these packages.

Sphinx==3.2.1
alabaster==0.7.13
Babel==2.12.1
certifi==2022.12.7
charset-normalizer==3.1.0
colorama==0.4.6
docutils==0.16
idna==3.4
imagesize==1.4.1
Jinja2==2.11.3
MarkupSafe==1.1.1
packaging==23.1
Pygments==2.15.1
requests==2.29.0
snowballstemmer==2.2.0
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
urllib3==1.26.15
5 changes: 0 additions & 5 deletions Include/internal/pycore_bytesobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ extern "C" {
#endif


/* runtime lifecycle */

extern PyStatus _PyBytes_InitTypes(PyInterpreterState *);


/* Substring Search.
Returns the index of the first occurrence of
Expand Down
18 changes: 18 additions & 0 deletions Include/internal/pycore_fileutils_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ static inline BOOL _Py_GetFileInformationByName(
return GetFileInformationByName(FileName, FileInformationClass, FileInfoBuffer, FileInfoBufferSize);
}

static inline BOOL _Py_GetFileInformationByName_ErrorIsTrustworthy(int error)
{
switch(error) {
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
case ERROR_NOT_READY:
case ERROR_BAD_NET_NAME:
case ERROR_BAD_NETPATH:
case ERROR_BAD_PATHNAME:
case ERROR_INVALID_NAME:
case ERROR_FILENAME_EXCED_RANGE:
return TRUE;
case ERROR_NOT_SUPPORTED:
return FALSE;
}
return FALSE;
}

#endif

#endif
1 change: 0 additions & 1 deletion Include/internal/pycore_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ extern "C" {
/* runtime lifecycle */

extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);
extern PyStatus _PyTuple_InitTypes(PyInterpreterState *);
extern void _PyTuple_Fini(PyInterpreterState *);


Expand Down
25 changes: 6 additions & 19 deletions Lib/_strptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,6 @@ def _calc_julian_from_U_or_W(year, week_of_year, day_of_week, week_starts_Mon):
return 1 + days_to_week + day_of_week


def _calc_julian_from_V(iso_year, iso_week, iso_weekday):
"""Calculate the Julian day based on the ISO 8601 year, week, and weekday.
ISO weeks start on Mondays, with week 01 being the week containing 4 Jan.
ISO week days range from 1 (Monday) to 7 (Sunday).
"""
correction = datetime_date(iso_year, 1, 4).isoweekday() + 3
ordinal = (iso_week * 7) + iso_weekday - correction
# ordinal may be negative or 0 now, which means the date is in the previous
# calendar year
if ordinal < 1:
ordinal += datetime_date(iso_year, 1, 1).toordinal()
iso_year -= 1
ordinal -= datetime_date(iso_year, 1, 1).toordinal()
return iso_year, ordinal


def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
"""Return a 2-tuple consisting of a time struct and an int containing
the number of microseconds based on the input string and the
Expand Down Expand Up @@ -483,7 +467,8 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
else:
tz = value
break
# Deal with the cases where ambiguities arize

# Deal with the cases where ambiguities arise
# don't assume default values for ISO week/year
if year is None and iso_year is not None:
if iso_week is None or weekday is None:
Expand Down Expand Up @@ -511,7 +496,6 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
elif year is None:
year = 1900


# If we know the week of the year and what day of that week, we can figure
# out the Julian day of the year.
if julian is None and weekday is not None:
Expand All @@ -520,7 +504,10 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
julian = _calc_julian_from_U_or_W(year, week_of_year, weekday,
week_starts_Mon)
elif iso_year is not None and iso_week is not None:
year, julian = _calc_julian_from_V(iso_year, iso_week, weekday + 1)
datetime_result = datetime_date.fromisocalendar(iso_year, iso_week, weekday + 1)
year = datetime_result.year
month = datetime_result.month
day = datetime_result.day
if julian is not None and julian <= 0:
year -= 1
yday = 366 if calendar.isleap(year) else 365
Expand Down
11 changes: 6 additions & 5 deletions Lib/asyncio/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ def kill(self):

async def _feed_stdin(self, input):
debug = self._loop.get_debug()
self.stdin.write(input)
if debug:
logger.debug(
'%r communicate: feed stdin (%s bytes)', self, len(input))
if input is not None:
self.stdin.write(input)
if debug:
logger.debug(
'%r communicate: feed stdin (%s bytes)', self, len(input))
try:
await self.stdin.drain()
except (BrokenPipeError, ConnectionResetError) as exc:
Expand Down Expand Up @@ -180,7 +181,7 @@ async def _read_stream(self, fd):
return output

async def communicate(self, input=None):
if input is not None:
if self.stdin is not None:
stdin = self._feed_stdin(input)
else:
stdin = self._noop()
Expand Down
3 changes: 2 additions & 1 deletion Lib/cProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import _lsprof
import importlib.machinery
import io
import profile as _pyprofile

# ____________________________________________________________
Expand Down Expand Up @@ -168,7 +169,7 @@ def main():
else:
progname = args[0]
sys.path.insert(0, os.path.dirname(progname))
with open(progname, 'rb') as fp:
with io.open_code(progname) as fp:
code = compile(fp.read(), progname, 'exec')
spec = importlib.machinery.ModuleSpec(name='__main__', loader=None,
origin=progname)
Expand Down
16 changes: 15 additions & 1 deletion Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,13 @@ def fromtimestamp(cls, timestamp, tz=None):
@classmethod
def utcfromtimestamp(cls, t):
"""Construct a naive UTC datetime from a POSIX timestamp."""
import warnings
warnings.warn("datetime.utcfromtimestamp() is deprecated and scheduled "
"for removal in a future version. Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.fromtimestamp(t, datetime.UTC).",
DeprecationWarning,
stacklevel=2)
return cls._fromtimestamp(t, True, None)

@classmethod
Expand All @@ -1812,8 +1819,15 @@ def now(cls, tz=None):
@classmethod
def utcnow(cls):
"Construct a UTC datetime from time.time()."
import warnings
warnings.warn("datetime.utcnow() is deprecated and scheduled for "
"removal in a future version. Instead, Use timezone-aware "
"objects to represent datetimes in UTC: "
"datetime.now(datetime.UTC).",
DeprecationWarning,
stacklevel=2)
t = _time.time()
return cls.utcfromtimestamp(t)
return cls._fromtimestamp(t, True, None)

@classmethod
def combine(cls, date, time, tzinfo=True):
Expand Down
Loading

0 comments on commit db5d49b

Please sign in to comment.