Skip to content

Commit bf2932d

Browse files
sync with cpython aebf072a
1 parent 4e1b09f commit bf2932d

File tree

2 files changed

+103
-108
lines changed

2 files changed

+103
-108
lines changed

howto/descriptor.po

Lines changed: 85 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.13\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2024-11-27 00:14+0000\n"
10+
"POT-Creation-Date: 2025-09-01 00:19+0000\n"
1111
"PO-Revision-Date: 2018-05-23 14:36+0000\n"
1212
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -75,9 +75,8 @@ msgstr ""
7575
msgid ""
7676
"The last section has pure Python equivalents for built-in descriptors that "
7777
"are written in C. Read this if you're curious about how functions turn into "
78-
"bound methods or about the implementation of common tools "
79-
"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, "
80-
"and :term:`__slots__`."
78+
"bound methods or about the implementation of common tools like :func:"
79+
"`classmethod`, :func:`staticmethod`, :func:`property`, and :term:`__slots__`."
8180
msgstr ""
8281

8382
#: ../../howto/descriptor.rst:36
@@ -231,9 +230,8 @@ msgid ""
231230
"A popular use for descriptors is managing access to instance data. The "
232231
"descriptor is assigned to a public attribute in the class dictionary while "
233232
"the actual data is stored as a private attribute in the instance "
234-
"dictionary. The descriptor's :meth:`~object.__get__` "
235-
"and :meth:`~object.__set__` methods are triggered when the public attribute "
236-
"is accessed."
233+
"dictionary. The descriptor's :meth:`~object.__get__` and :meth:`~object."
234+
"__set__` methods are triggered when the public attribute is accessed."
237235
msgstr ""
238236

239237
#: ../../howto/descriptor.rst:139
@@ -371,10 +369,9 @@ msgstr ""
371369

372370
#: ../../howto/descriptor.rst:256
373371
msgid ""
374-
"An interactive session shows that the :class:`!Person` class has "
375-
"called :meth:`~object.__set_name__` so that the field names would be "
376-
"recorded. Here we call :func:`vars` to look up the descriptor without "
377-
"triggering it:"
372+
"An interactive session shows that the :class:`!Person` class has called :"
373+
"meth:`~object.__set_name__` so that the field names would be recorded. Here "
374+
"we call :func:`vars` to look up the descriptor without triggering it:"
378375
msgstr ""
379376

380377
#: ../../howto/descriptor.rst:260
@@ -431,9 +428,8 @@ msgstr ""
431428

432429
#: ../../howto/descriptor.rst:297
433430
msgid ""
434-
"A :term:`descriptor` is what we call any object that "
435-
"defines :meth:`~object.__get__`, :meth:`~object.__set__`, "
436-
"or :meth:`~object.__delete__`."
431+
"A :term:`descriptor` is what we call any object that defines :meth:`~object."
432+
"__get__`, :meth:`~object.__set__`, or :meth:`~object.__delete__`."
437433
msgstr ""
438434

439435
#: ../../howto/descriptor.rst:300
@@ -473,9 +469,9 @@ msgstr ""
473469
#: ../../howto/descriptor.rst:319
474470
msgid ""
475471
"Descriptors are used throughout the language. It is how functions turn into "
476-
"bound methods. Common tools "
477-
"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, "
478-
"and :func:`functools.cached_property` are all implemented as descriptors."
472+
"bound methods. Common tools like :func:`classmethod`, :func:"
473+
"`staticmethod`, :func:`property`, and :func:`functools.cached_property` are "
474+
"all implemented as descriptors."
479475
msgstr ""
480476

481477
#: ../../howto/descriptor.rst:326
@@ -565,9 +561,9 @@ msgstr ""
565561

566562
#: ../../howto/descriptor.rst:374
567563
msgid ""
568-
":class:`!Number` verifies that a value is either an :class:`int` "
569-
"or :class:`float`. Optionally, it verifies that a value is between a given "
570-
"minimum or maximum."
564+
":class:`!Number` verifies that a value is either an :class:`int` or :class:"
565+
"`float`. Optionally, it verifies that a value is between a given minimum or "
566+
"maximum."
571567
msgstr ""
572568

573569
#: ../../howto/descriptor.rst:378
@@ -618,7 +614,7 @@ msgid ""
618614
"\n"
619615
" def validate(self, value):\n"
620616
" if not isinstance(value, str):\n"
621-
" raise TypeError(f'Expected {value!r} to be an str')\n"
617+
" raise TypeError(f'Expected {value!r} to be a str')\n"
622618
" if self.minsize is not None and len(value) < self.minsize:\n"
623619
" raise ValueError(\n"
624620
" f'Expected {value!r} to be no smaller than {self.minsize!"
@@ -720,10 +716,9 @@ msgstr ""
720716
#: ../../howto/descriptor.rst:503
721717
msgid ""
722718
"In general, a descriptor is an attribute value that has one of the methods "
723-
"in the descriptor protocol. Those methods "
724-
"are :meth:`~object.__get__`, :meth:`~object.__set__`, "
725-
"and :meth:`~object.__delete__`. If any of those methods are defined for an "
726-
"attribute, it is said to be a :term:`descriptor`."
719+
"in the descriptor protocol. Those methods are :meth:`~object.__get__`, :"
720+
"meth:`~object.__set__`, and :meth:`~object.__delete__`. If any of those "
721+
"methods are defined for an attribute, it is said to be a :term:`descriptor`."
727722
msgstr ""
728723

729724
#: ../../howto/descriptor.rst:508
@@ -741,10 +736,10 @@ msgstr ""
741736
#: ../../howto/descriptor.rst:517
742737
msgid ""
743738
"Descriptors are a powerful, general purpose protocol. They are the "
744-
"mechanism behind properties, methods, static methods, class methods, "
745-
"and :func:`super`. They are used throughout Python itself. Descriptors "
746-
"simplify the underlying C code and offer a flexible set of new tools for "
747-
"everyday Python programs."
739+
"mechanism behind properties, methods, static methods, class methods, and :"
740+
"func:`super`. They are used throughout Python itself. Descriptors simplify "
741+
"the underlying C code and offer a flexible set of new tools for everyday "
742+
"Python programs."
748743
msgstr ""
749744

750745
#: ../../howto/descriptor.rst:525
@@ -773,9 +768,9 @@ msgstr ""
773768
#: ../../howto/descriptor.rst:537
774769
msgid ""
775770
"If an object defines :meth:`~object.__set__` or :meth:`~object.__delete__`, "
776-
"it is considered a data descriptor. Descriptors that only "
777-
"define :meth:`~object.__get__` are called non-data descriptors (they are "
778-
"often used for methods but other uses are possible)."
771+
"it is considered a data descriptor. Descriptors that only define :meth:"
772+
"`~object.__get__` are called non-data descriptors (they are often used for "
773+
"methods but other uses are possible)."
779774
msgstr ""
780775

781776
#: ../../howto/descriptor.rst:542
@@ -790,10 +785,9 @@ msgstr ""
790785
#: ../../howto/descriptor.rst:548
791786
msgid ""
792787
"To make a read-only data descriptor, define both :meth:`~object.__get__` "
793-
"and :meth:`~object.__set__` with the :meth:`~object.__set__` raising "
794-
"an :exc:`AttributeError` when called. Defining the :meth:`~object.__set__` "
795-
"method with an exception raising placeholder is enough to make it a data "
796-
"descriptor."
788+
"and :meth:`~object.__set__` with the :meth:`~object.__set__` raising an :exc:"
789+
"`AttributeError` when called. Defining the :meth:`~object.__set__` method "
790+
"with an exception raising placeholder is enough to make it a data descriptor."
797791
msgstr ""
798792

799793
#: ../../howto/descriptor.rst:555
@@ -802,8 +796,8 @@ msgstr ""
802796

803797
#: ../../howto/descriptor.rst:557
804798
msgid ""
805-
"A descriptor can be called directly with ``desc.__get__(obj)`` or "
806-
"``desc.__get__(None, cls)``."
799+
"A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc."
800+
"__get__(None, cls)``."
807801
msgstr ""
808802

809803
#: ../../howto/descriptor.rst:560
@@ -840,8 +834,8 @@ msgstr ""
840834

841835
#: ../../howto/descriptor.rst:580
842836
msgid ""
843-
"If a descriptor is found for ``a.x``, then it is invoked with: "
844-
"``desc.__get__(a, type(a))``."
837+
"If a descriptor is found for ``a.x``, then it is invoked with: ``desc."
838+
"__get__(a, type(a))``."
845839
msgstr ""
846840

847841
#: ../../howto/descriptor.rst:583
@@ -881,19 +875,18 @@ msgstr ""
881875

882876
#: ../../howto/descriptor.rst:722
883877
msgid ""
884-
"Note, there is no :meth:`~object.__getattr__` hook in "
885-
"the :meth:`~object.__getattribute__` code. That is why "
886-
"calling :meth:`~object.__getattribute__` directly or with "
887-
"``super().__getattribute__`` will bypass :meth:`~object.__getattr__` "
888-
"entirely."
878+
"Note, there is no :meth:`~object.__getattr__` hook in the :meth:`~object."
879+
"__getattribute__` code. That is why calling :meth:`~object."
880+
"__getattribute__` directly or with ``super().__getattribute__`` will bypass :"
881+
"meth:`~object.__getattr__` entirely."
889882
msgstr ""
890883

891884
#: ../../howto/descriptor.rst:726
892885
msgid ""
893886
"Instead, it is the dot operator and the :func:`getattr` function that are "
894-
"responsible for invoking :meth:`~object.__getattr__` "
895-
"whenever :meth:`~object.__getattribute__` raises an :exc:`AttributeError`. "
896-
"Their logic is encapsulated in a helper function:"
887+
"responsible for invoking :meth:`~object.__getattr__` whenever :meth:`~object."
888+
"__getattribute__` raises an :exc:`AttributeError`. Their logic is "
889+
"encapsulated in a helper function:"
897890
msgstr ""
898891

899892
#: ../../howto/descriptor.rst:731
@@ -922,10 +915,10 @@ msgstr ""
922915

923916
#: ../../howto/descriptor.rst:778
924917
msgid ""
925-
"The logic for a dotted lookup such as ``A.x`` is in :meth:`!"
926-
"type.__getattribute__`. The steps are similar to those for :meth:`!"
927-
"object.__getattribute__` but the instance dictionary lookup is replaced by a "
928-
"search through the class's :term:`method resolution order`."
918+
"The logic for a dotted lookup such as ``A.x`` is in :meth:`!type."
919+
"__getattribute__`. The steps are similar to those for :meth:`!object."
920+
"__getattribute__` but the instance dictionary lookup is replaced by a search "
921+
"through the class's :term:`method resolution order`."
929922
msgstr ""
930923

931924
#: ../../howto/descriptor.rst:783
@@ -934,8 +927,8 @@ msgstr ""
934927

935928
#: ../../howto/descriptor.rst:785
936929
msgid ""
937-
"The full C implementation can be found in :c:func:`!type_getattro` "
938-
"and :c:func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`."
930+
"The full C implementation can be found in :c:func:`!type_getattro` and :c:"
931+
"func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`."
939932
msgstr ""
940933

941934
#: ../../howto/descriptor.rst:790
@@ -944,23 +937,22 @@ msgstr ""
944937

945938
#: ../../howto/descriptor.rst:792
946939
msgid ""
947-
"The logic for super's dotted lookup is in "
948-
"the :meth:`~object.__getattribute__` method for object returned "
949-
"by :func:`super`."
940+
"The logic for super's dotted lookup is in the :meth:`~object."
941+
"__getattribute__` method for object returned by :func:`super`."
950942
msgstr ""
951943

952944
#: ../../howto/descriptor.rst:795
953945
msgid ""
954-
"A dotted lookup such as ``super(A, obj).m`` searches "
955-
"``obj.__class__.__mro__`` for the base class ``B`` immediately following "
956-
"``A`` and then returns ``B.__dict__['m'].__get__(obj, A)``. If not a "
957-
"descriptor, ``m`` is returned unchanged."
946+
"A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__."
947+
"__mro__`` for the base class ``B`` immediately following ``A`` and then "
948+
"returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is "
949+
"returned unchanged."
958950
msgstr ""
959951

960952
#: ../../howto/descriptor.rst:800
961953
msgid ""
962-
"The full C implementation can be found in :c:func:`!super_getattro` "
963-
"in :source:`Objects/typeobject.c`. A pure Python equivalent can be found in "
954+
"The full C implementation can be found in :c:func:`!super_getattro` in :"
955+
"source:`Objects/typeobject.c`. A pure Python equivalent can be found in "
964956
"`Guido's Tutorial <https://www.python.org/download/releases/2.2.3/descrintro/"
965957
"#cooperation>`_."
966958
msgstr ""
@@ -971,9 +963,9 @@ msgstr ""
971963

972964
#: ../../howto/descriptor.rst:809
973965
msgid ""
974-
"The mechanism for descriptors is embedded in "
975-
"the :meth:`~object.__getattribute__` methods "
976-
"for :class:`object`, :class:`type`, and :func:`super`."
966+
"The mechanism for descriptors is embedded in the :meth:`~object."
967+
"__getattribute__` methods for :class:`object`, :class:`type`, and :func:"
968+
"`super`."
977969
msgstr ""
978970

979971
#: ../../howto/descriptor.rst:812
@@ -986,8 +978,8 @@ msgstr ""
986978

987979
#: ../../howto/descriptor.rst:816
988980
msgid ""
989-
"Classes inherit this machinery from :class:`object`, :class:`type`, "
990-
"or :func:`super`."
981+
"Classes inherit this machinery from :class:`object`, :class:`type`, or :func:"
982+
"`super`."
991983
msgstr ""
992984

993985
#: ../../howto/descriptor.rst:819
@@ -1046,8 +1038,8 @@ msgstr "ORM 範例"
10461038
#: ../../howto/descriptor.rst:853
10471039
msgid ""
10481040
"The following code is a simplified skeleton showing how data descriptors "
1049-
"could be used to implement an `object relational mapping <https://"
1050-
"en.wikipedia.org/wiki/Object%E2%80%93relational_mapping>`_."
1041+
"could be used to implement an `object relational mapping <https://en."
1042+
"wikipedia.org/wiki/Object%E2%80%93relational_mapping>`_."
10511043
msgstr ""
10521044

10531045
#: ../../howto/descriptor.rst:857
@@ -1091,9 +1083,9 @@ msgstr ""
10911083

10921084
#: ../../howto/descriptor.rst:876
10931085
msgid ""
1094-
"We can use the :class:`!Field` class to define `models <https://"
1095-
"en.wikipedia.org/wiki/Database_model>`_ that describe the schema for each "
1096-
"table in a database:"
1086+
"We can use the :class:`!Field` class to define `models <https://en.wikipedia."
1087+
"org/wiki/Database_model>`_ that describe the schema for each table in a "
1088+
"database:"
10971089
msgstr ""
10981090

10991091
#: ../../howto/descriptor.rst:880
@@ -1350,10 +1342,10 @@ msgstr ""
13501342

13511343
#: ../../howto/descriptor.rst:1189
13521344
msgid ""
1353-
"To support automatic creation of methods, functions include "
1354-
"the :meth:`~object.__get__` method for binding methods during attribute "
1355-
"access. This means that functions are non-data descriptors that return "
1356-
"bound methods during dotted lookup from an instance. Here's how it works:"
1345+
"To support automatic creation of methods, functions include the :meth:"
1346+
"`~object.__get__` method for binding methods during attribute access. This "
1347+
"means that functions are non-data descriptors that return bound methods "
1348+
"during dotted lookup from an instance. Here's how it works:"
13571349
msgstr ""
13581350

13591351
#: ../../howto/descriptor.rst:1194
@@ -1405,9 +1397,8 @@ msgstr ""
14051397

14061398
#: ../../howto/descriptor.rst:1233
14071399
msgid ""
1408-
"Accessing the function through the class dictionary does not "
1409-
"invoke :meth:`~object.__get__`. Instead, it just returns the underlying "
1410-
"function object::"
1400+
"Accessing the function through the class dictionary does not invoke :meth:"
1401+
"`~object.__get__`. Instead, it just returns the underlying function object::"
14111402
msgstr ""
14121403

14131404
#: ../../howto/descriptor.rst:1236
@@ -1544,10 +1535,10 @@ msgstr ""
15441535
#: ../../howto/descriptor.rst:1293
15451536
msgid ""
15461537
"Static methods return the underlying function without changes. Calling "
1547-
"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into "
1548-
"``object.__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, "
1549-
"\"f\")``. As a result, the function becomes identically accessible from "
1550-
"either an object or a class."
1538+
"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into ``object."
1539+
"__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, \"f\")``. As a "
1540+
"result, the function becomes identically accessible from either an object or "
1541+
"a class."
15511542
msgstr ""
15521543

15531544
#: ../../howto/descriptor.rst:1299
@@ -1600,8 +1591,8 @@ msgstr ""
16001591

16011592
#: ../../howto/descriptor.rst:1328
16021593
msgid ""
1603-
"Using the non-data descriptor protocol, a pure Python version "
1604-
"of :func:`staticmethod` would look like this:"
1594+
"Using the non-data descriptor protocol, a pure Python version of :func:"
1595+
"`staticmethod` would look like this:"
16051596
msgstr ""
16061597

16071598
#: ../../howto/descriptor.rst:1331
@@ -1626,9 +1617,9 @@ msgstr ""
16261617
msgid ""
16271618
"The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute "
16281619
"that refers to the underlying function. Also it carries forward the "
1629-
"attributes necessary to make the wrapper look like the wrapped "
1630-
"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, "
1631-
"and :attr:`~function.__annotations__`."
1620+
"attributes necessary to make the wrapper look like the wrapped function: :"
1621+
"attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function."
1622+
"__doc__`, and :attr:`~function.__annotations__`."
16321623
msgstr ""
16331624

16341625
#: ../../howto/descriptor.rst:1417
@@ -1707,8 +1698,8 @@ msgstr ""
17071698

17081699
#: ../../howto/descriptor.rst:1464
17091700
msgid ""
1710-
"Using the non-data descriptor protocol, a pure Python version "
1711-
"of :func:`classmethod` would look like this:"
1701+
"Using the non-data descriptor protocol, a pure Python version of :func:"
1702+
"`classmethod` would look like this:"
17121703
msgstr ""
17131704

17141705
#: ../../howto/descriptor.rst:1467
@@ -1733,9 +1724,9 @@ msgid ""
17331724
"The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a "
17341725
"``__wrapped__`` attribute that refers to the underlying function. Also it "
17351726
"carries forward the attributes necessary to make the wrapper look like the "
1736-
"wrapped "
1737-
"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, "
1738-
"and :attr:`~function.__annotations__`."
1727+
"wrapped function: :attr:`~function.__name__`, :attr:`~function."
1728+
"__qualname__`, :attr:`~function.__doc__`, and :attr:`~function."
1729+
"__annotations__`."
17391730
msgstr ""
17401731

17411732
#: ../../howto/descriptor.rst:1538

0 commit comments

Comments
 (0)