Skip to content

Commit

Permalink
Merge branch 'main' into superbadgetattro
Browse files Browse the repository at this point in the history
* main:
  CI: Temporarily skip paths with spaces to avoid error (python#105110)
  pythongh-105071: add missing versionadded directive (python#105097)
  pythongh-80064: Fix is_valid_wide_char() return type (python#105099)
  Small speedup for dataclass __eq__ and __repr__ (python#104904)
  pythongh-103921: Minor PEP-695 fixes to the `ast` module docs (python#105093)
  pythongh-105091: stable_abi.py: Remove "Unixy" check from --all on other platforms (pythonGH-105092)
  • Loading branch information
carljm committed May 30, 2023
2 parents 8fff072 + 4c77061 commit 24e1159
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,20 @@ jobs:
with:
filter: |
Doc/**
Misc/**
# Temporarily skip paths with spaces
# (i.e. "C API", "Core and Builtins")
# to avoid "Error: One of your files includes a space".
# Pending https://github.com/python/core-workflow/issues/186
# Misc/**
Misc/NEWS.d/next/Build/**
Misc/NEWS.d/next/Documentation/**
Misc/NEWS.d/next/IDLE/**
Misc/NEWS.d/next/Library/**
Misc/NEWS.d/next/Security/**
Misc/NEWS.d/next/Tests/**
Misc/NEWS.d/next/Tools-Demos/**
Misc/NEWS.d/next/Windows/**
Misc/NEWS.d/next/macOS/**
.github/workflows/reusable-docs.yml
- name: Check for docs changes
if: >-
Expand Down
2 changes: 2 additions & 0 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ Exception Objects
Return the :exc:`ExceptionGroup` that needs to be reraised in the end, or
``None`` if there is nothing to reraise.
.. versionadded:: 3.12
.. _unicodeexceptions:
Unicode Exception Objects
Expand Down
10 changes: 5 additions & 5 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1744,17 +1744,17 @@ aliases.
Function and class definitions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. class:: FunctionDef(name, type_params, args, body, decorator_list, returns, type_comment)
.. class:: FunctionDef(name, args, body, decorator_list, returns, type_comment, type_params)

A function definition.

* ``name`` is a raw string of the function name.
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.
* ``args`` is an :class:`arguments` node.
* ``body`` is the list of nodes inside the function.
* ``decorator_list`` is the list of decorators to be applied, stored outermost
first (i.e. the first in the list will be applied last).
* ``returns`` is the return annotation.
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.

.. attribute:: type_comment

Expand Down Expand Up @@ -1917,19 +1917,19 @@ Function and class definitions
type_ignores=[])


.. class:: ClassDef(name, type_params, bases, keywords, body, decorator_list)
.. class:: ClassDef(name, bases, keywords, body, decorator_list, type_params)

A class definition.

* ``name`` is a raw string for the class name
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.
* ``bases`` is a list of nodes for explicitly specified base classes.
* ``keywords`` is a list of :class:`keyword` nodes, principally for 'metaclass'.
Other keywords will be passed to the metaclass, as per `PEP-3115
<https://peps.python.org/pep-3115/>`_.
* ``body`` is a list of nodes representing the code within the class
definition.
* ``decorator_list`` is a list of nodes, as in :class:`FunctionDef`.
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.

.. doctest::

Expand Down Expand Up @@ -1961,7 +1961,7 @@ Function and class definitions
Async and await
^^^^^^^^^^^^^^^

.. class:: AsyncFunctionDef(name, args, body, decorator_list, returns, type_comment)
.. class:: AsyncFunctionDef(name, args, body, decorator_list, returns, type_comment, type_params)

An ``async def`` function definition. Has the same fields as
:class:`FunctionDef`.
Expand Down
20 changes: 12 additions & 8 deletions Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def _init_fn(fields, std_fields, kw_only_fields, frozen, has_post_init,
def _repr_fn(fields, globals):
fn = _create_fn('__repr__',
('self',),
['return self.__class__.__qualname__ + f"(' +
['return f"{self.__class__.__qualname__}(' +
', '.join([f"{f.name}={{self.{f.name}!r}}"
for f in fields]) +
')"'],
Expand Down Expand Up @@ -1085,13 +1085,17 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
if eq:
# Create __eq__ method. There's no need for a __ne__ method,
# since python will call __eq__ and negate it.
flds = [f for f in field_list if f.compare]
self_tuple = _tuple_str('self', flds)
other_tuple = _tuple_str('other', flds)
_set_new_attribute(cls, '__eq__',
_cmp_fn('__eq__', '==',
self_tuple, other_tuple,
globals=globals))
cmp_fields = (field for field in field_list if field.compare)
terms = [f'self.{field.name}==other.{field.name}' for field in cmp_fields]
field_comparisons = ' and '.join(terms) or 'True'
body = [f'if other.__class__ is self.__class__:',
f' return {field_comparisons}',
f'return NotImplemented']
func = _create_fn('__eq__',
('self', 'other'),
body,
globals=globals)
_set_new_attribute(cls, '__eq__', func)

if order:
# Create and set the ordering methods.
Expand Down
2 changes: 1 addition & 1 deletion Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ _Py_device_encoding(int fd)
}


static size_t
static int
is_valid_wide_char(wchar_t ch)
{
#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
Expand Down
3 changes: 2 additions & 1 deletion Tools/build/stable_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ def main():

if args.all:
run_all_generators = True
args.unixy_check = True
if UNIXY:
args.unixy_check = True

try:
file = args.file.open('rb')
Expand Down

0 comments on commit 24e1159

Please sign in to comment.