Skip to content

Commit 83e7675

Browse files
committed
Merge branch 'main' into gh-158304
2 parents 13f2615 + 5637f4e commit 83e7675

98 files changed

Lines changed: 3469 additions & 3158 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Doc/library/ctypes.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,9 @@ These prefabricated library loaders are available:
17551755
:c:expr:`int`, which is of course not always the truth, so you have to assign
17561756
the correct :attr:`!restype` attribute to use these functions.
17571757

1758+
Note that if the Python interpreter is statically linked, this will be
1759+
``None``, as ``dlopen`` is not possible in this case.
1760+
17581761
.. audit-event:: ctypes.dlopen name ctypes.LibraryLoader
17591762

17601763
Loading a library through any of these objects raises an

‎Doc/library/turtle.rst‎

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,12 +2689,51 @@ These modified docstrings are created automatically together with the function
26892689
definitions that are derived from the methods at import time.
26902690

26912691

2692+
.. _turtle-docstring-translation:
2693+
26922694
Translation of docstrings into different languages
26932695
--------------------------------------------------
26942696

2695-
There is a utility to create a dictionary the keys of which are the method names
2696-
and the values of which are the docstrings of the public methods of the classes
2697-
Screen and Turtle.
2697+
The docstrings of the public methods of the Screen and Turtle classes, and of
2698+
the corresponding functions, can be replaced with translations, so that
2699+
:func:`help` and IDE tooltips are shown in another language. However, only the help
2700+
text is translated, the names of the functions and methods stay the same.
2701+
2702+
Translations are distributed on PyPI in the :pypi:`turtle-translations`
2703+
package. To use them, install the package with :program:`pip` and select the
2704+
language with the :envvar:`PYTHON_TURTLE_LANG` environment variable. For
2705+
example, to show the help text in Spanish:
2706+
2707+
.. code-block:: console
2708+
2709+
$ python -m pip install turtle-translations
2710+
$ PYTHON_TURTLE_LANG=es python
2711+
>>> import turtle
2712+
>>> help(turtle.forward)
2713+
2714+
The language can also be set permanently with the *language* entry of the
2715+
:file:`turtle.cfg` file (see :ref:`turtle-configuration`). If no translation
2716+
is found for the selected language, the English docstrings are kept.
2717+
2718+
To add a new language or improve an existing translation, see the
2719+
contribution instructions in the :pypi:`turtle-translations` project.
2720+
2721+
A translation is a docstring dictionary. It is a top-level module named
2722+
:samp:`turtle_docstringdict_{language}.py` on :data:`sys.path` defining a
2723+
dictionary named ``docsdict``, the keys of which are method names such as
2724+
``Turtle.forward`` and the values of which are the translated docstrings. It is
2725+
read in at import time. Entries naming a method which does not exist in the
2726+
running version are ignored.
2727+
2728+
.. versionchanged:: 3.16
2729+
Entries naming an unknown method are ignored instead of reported.
2730+
2731+
.. envvar:: PYTHON_TURTLE_LANG
2732+
2733+
The name of the language to read the translation for. It takes precedence
2734+
over the *language* entry of the :file:`turtle.cfg` file.
2735+
2736+
.. versionadded:: 3.16
26982737

26992738
.. function:: write_docstringdict(filename="turtle_docstringdict")
27002739

@@ -2706,17 +2745,8 @@ Screen and Turtle.
27062745
Python script :file:`{filename}.py`. It is intended to serve as a template
27072746
for translation of the docstrings into different languages.
27082747

2709-
If you (or your students) want to use :mod:`!turtle` with online help in your
2710-
native language, you have to translate the docstrings and save the resulting
2711-
file as e.g. :file:`turtle_docstringdict_german.py`.
2712-
2713-
If you have an appropriate entry in your :file:`turtle.cfg` file this dictionary
2714-
will be read in at import time and will replace the original English docstrings.
2715-
2716-
At the time of this writing there are docstring dictionaries in German and in
2717-
Italian. (Requests please to glingl@aon.at.)
2718-
27192748

2749+
.. _turtle-configuration:
27202750

27212751
How to configure Screen and Turtles
27222752
-----------------------------------
@@ -2767,9 +2797,9 @@ Short explanation of selected entries:
27672797
the cfg file).
27682798
- If you want to reflect the turtle its state, you have to use ``resizemode =
27692799
auto``.
2770-
- If you set e.g. ``language = italian`` the docstringdict
2771-
:file:`turtle_docstringdict_italian.py` will be loaded at import time (if
2772-
present on the import path, e.g. in the same directory as :mod:`!turtle`).
2800+
- The *language* entry selects the language of the docstrings, unless the
2801+
:envvar:`PYTHON_TURTLE_LANG` environment variable is set. See
2802+
:ref:`turtle-docstring-translation` for more information.
27732803
- The entries *exampleturtle* and *examplescreen* define the names of these
27742804
objects as they occur in the docstrings. The transformation of
27752805
method-docstrings to function-docstrings will delete these names from the

‎Doc/whatsnew/3.16.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,16 @@ tkinter
712712
with no unit suffix to :class:`int` or :class:`float`.
713713
(Contributed by Serhiy Storchaka in :gh:`153513`.)
714714

715+
716+
turtle
717+
------
718+
719+
* Translations of the :mod:`turtle` docstrings are now distributed on PyPI
720+
in the :pypi:`turtle-translations` package. Additionally, added the
721+
:envvar:`PYTHON_TURTLE_LANG` environment variable to select the language.
722+
(Contributed by Stan Ulbrych in :gh:`156360`.)
723+
724+
715725
unicodedata
716726
-----------
717727

‎Include/internal/pycore_global_objects_fini_generated.h‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_global_strings.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ struct _Py_global_strings {
500500
STRUCT_FOR_ID(filter)
501501
STRUCT_FOR_ID(filters)
502502
STRUCT_FOR_ID(final)
503+
STRUCT_FOR_ID(finalizer)
503504
STRUCT_FOR_ID(find_class)
505+
STRUCT_FOR_ID(firstiter)
504506
STRUCT_FOR_ID(fix_imports)
505507
STRUCT_FOR_ID(flags)
506508
STRUCT_FOR_ID(flush)

‎Include/internal/pycore_modsupport.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ extern "C" {
1010
#endif
1111

1212

13-
extern int _PyArg_NoKwnames(const char *funcname, PyObject *kwnames);
13+
// Export for 'array' shared extension
14+
PyAPI_FUNC(int) _PyArg_NoKwnames(const char *funcname, PyObject *kwnames);
1415
#define _PyArg_NoKwnames(funcname, kwnames) \
1516
((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
1617

‎Include/internal/pycore_runtime_init_generated.h‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_unicodeobject_generated.h‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Lib/ctypes/__init__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,10 @@ def LoadLibrary(self, name):
561561
elif _sys.platform == "cygwin":
562562
pythonapi = PyDLL(_sysconfig.get_config_var("DLLLIBRARY"))
563563
else:
564-
pythonapi = PyDLL(None)
564+
try:
565+
pythonapi = PyDLL(None)
566+
except OSError:
567+
pythonapi = None
565568

566569

567570
if _os.name == "nt":

‎Lib/test/clinic.test.c‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6032,23 +6032,13 @@ static PyObject *
60326032
Test__pyarg_parsestackandkeywords(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
60336033
{
60346034
PyObject *return_value = NULL;
6035-
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6036-
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
6037-
#else
6038-
# define KWTUPLE NULL
6039-
#endif
6040-
6041-
static const char * const _keywords[] = {"", NULL};
6042-
static _PyArg_Parser _parser = {
6043-
.keywords = _keywords,
6044-
.format = "s#:_pyarg_parsestackandkeywords",
6045-
.kwtuple = KWTUPLE,
6046-
};
6047-
#undef KWTUPLE
60486035
const char *key;
60496036
Py_ssize_t key_length;
60506037

6051-
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
6038+
if (!_PyArg_NoKwnames("_pyarg_parsestackandkeywords", kwnames)) {
6039+
goto exit;
6040+
}
6041+
if (!_PyArg_ParseStack(args, nargs, "s#:_pyarg_parsestackandkeywords",
60526042
&key, &key_length)) {
60536043
goto exit;
60546044
}
@@ -6062,7 +6052,7 @@ static PyObject *
60626052
Test__pyarg_parsestackandkeywords_impl(TestObj *self, PyTypeObject *cls,
60636053
const char *key,
60646054
Py_ssize_t key_length)
6065-
/*[clinic end generated code: output=7060c213d7b8200e input=fc72ef4b4cfafabc]*/
6055+
/*[clinic end generated code: output=21bbb9a8d0100d72 input=fc72ef4b4cfafabc]*/
60666056

60676057

60686058
/*[clinic input]

0 commit comments

Comments
 (0)