Skip to content

Commit 570bbb1

Browse files
Sync with CPython 3.12 (python#951)
Co-authored-by: Matt Wang <[email protected]>
1 parent d30872c commit 570bbb1

File tree

334 files changed

+88677
-4351
lines changed

Some content is hidden

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

334 files changed

+88677
-4351
lines changed

.scripts/poetry.lock

+146-146
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

c-api/arg.po

+37-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.12\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2024-07-20 00:03+0000\n"
10+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
1111
"PO-Revision-Date: 2022-10-16 03:21+0800\n"
1212
"Last-Translator: Adrian Liaw <[email protected]>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -612,6 +612,10 @@ msgid ""
612612
"*converter* function in turn is called as follows::"
613613
msgstr ""
614614

615+
#: ../../c-api/arg.rst:316
616+
msgid "status = converter(object, address);"
617+
msgstr "status = converter(object, address);"
618+
615619
#: ../../c-api/arg.rst:318
616620
msgid ""
617621
"where *object* is the Python object to be converted and *address* is the :c:"
@@ -828,12 +832,44 @@ msgid ""
828832
"the :mod:`!_weakref` helper module for weak references::"
829833
msgstr ""
830834

835+
#: ../../c-api/arg.rst:477
836+
msgid ""
837+
"static PyObject *\n"
838+
"weakref_ref(PyObject *self, PyObject *args)\n"
839+
"{\n"
840+
" PyObject *object;\n"
841+
" PyObject *callback = NULL;\n"
842+
" PyObject *result = NULL;\n"
843+
"\n"
844+
" if (PyArg_UnpackTuple(args, \"ref\", 1, 2, &object, &callback)) {\n"
845+
" result = PyWeakref_NewRef(object, callback);\n"
846+
" }\n"
847+
" return result;\n"
848+
"}"
849+
msgstr ""
850+
"static PyObject *\n"
851+
"weakref_ref(PyObject *self, PyObject *args)\n"
852+
"{\n"
853+
" PyObject *object;\n"
854+
" PyObject *callback = NULL;\n"
855+
" PyObject *result = NULL;\n"
856+
"\n"
857+
" if (PyArg_UnpackTuple(args, \"ref\", 1, 2, &object, &callback)) {\n"
858+
" result = PyWeakref_NewRef(object, callback);\n"
859+
" }\n"
860+
" return result;\n"
861+
"}"
862+
831863
#: ../../c-api/arg.rst:490
832864
msgid ""
833865
"The call to :c:func:`PyArg_UnpackTuple` in this example is entirely "
834866
"equivalent to this call to :c:func:`PyArg_ParseTuple`::"
835867
msgstr ""
836868

869+
#: ../../c-api/arg.rst:493
870+
msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)"
871+
msgstr "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)"
872+
837873
#: ../../c-api/arg.rst:498
838874
msgid "Building values"
839875
msgstr ""

c-api/buffer.po

+69-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.12\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2024-05-28 00:03+0000\n"
10+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
1111
"PO-Revision-Date: 2018-05-23 14:30+0000\n"
1212
"Last-Translator: Adrian Liaw <[email protected]>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -303,7 +303,7 @@ msgstr ""
303303

304304
#: ../../c-api/buffer.rst:218
305305
msgid "Constants:"
306-
msgstr ""
306+
msgstr "常數:"
307307

308308
#: ../../c-api/buffer.rst:222
309309
msgid ""
@@ -533,13 +533,52 @@ msgid ""
533533
"dimensional array as follows:"
534534
msgstr ""
535535

536+
#: ../../c-api/buffer.rst:368
537+
msgid ""
538+
"ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * "
539+
"strides[n-1];\n"
540+
"item = *((typeof(item) *)ptr);"
541+
msgstr ""
542+
"ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * "
543+
"strides[n-1];\n"
544+
"item = *((typeof(item) *)ptr);"
545+
536546
#: ../../c-api/buffer.rst:374
537547
msgid ""
538548
"As noted above, :c:member:`~Py_buffer.buf` can point to any location within "
539549
"the actual memory block. An exporter can check the validity of a buffer with "
540550
"this function:"
541551
msgstr ""
542552

553+
#: ../../c-api/buffer.rst:378
554+
msgid ""
555+
"def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n"
556+
" \"\"\"Verify that the parameters represent a valid array within\n"
557+
" the bounds of the allocated memory:\n"
558+
" char *mem: start of the physical memory block\n"
559+
" memlen: length of the physical memory block\n"
560+
" offset: (char *)buf - mem\n"
561+
" \"\"\"\n"
562+
" if offset % itemsize:\n"
563+
" return False\n"
564+
" if offset < 0 or offset+itemsize > memlen:\n"
565+
" return False\n"
566+
" if any(v % itemsize for v in strides):\n"
567+
" return False\n"
568+
"\n"
569+
" if ndim <= 0:\n"
570+
" return ndim == 0 and not shape and not strides\n"
571+
" if 0 in shape:\n"
572+
" return True\n"
573+
"\n"
574+
" imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n"
575+
" if strides[j] <= 0)\n"
576+
" imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n"
577+
" if strides[j] > 0)\n"
578+
"\n"
579+
" return 0 <= offset+imin and offset+imax+itemsize <= memlen"
580+
msgstr ""
581+
543582
#: ../../c-api/buffer.rst:408
544583
msgid "PIL-style: shape, strides and suboffsets"
545584
msgstr ""
@@ -562,6 +601,34 @@ msgid ""
562601
"strides and suboffsets::"
563602
msgstr ""
564603

604+
#: ../../c-api/buffer.rst:423
605+
msgid ""
606+
"void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n"
607+
" Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n"
608+
" char *pointer = (char*)buf;\n"
609+
" int i;\n"
610+
" for (i = 0; i < ndim; i++) {\n"
611+
" pointer += strides[i] * indices[i];\n"
612+
" if (suboffsets[i] >=0 ) {\n"
613+
" pointer = *((char**)pointer) + suboffsets[i];\n"
614+
" }\n"
615+
" }\n"
616+
" return (void*)pointer;\n"
617+
"}"
618+
msgstr ""
619+
"void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n"
620+
" Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n"
621+
" char *pointer = (char*)buf;\n"
622+
" int i;\n"
623+
" for (i = 0; i < ndim; i++) {\n"
624+
" pointer += strides[i] * indices[i];\n"
625+
" if (suboffsets[i] >=0 ) {\n"
626+
" pointer = *((char**)pointer) + suboffsets[i];\n"
627+
" }\n"
628+
" }\n"
629+
" return (void*)pointer;\n"
630+
"}"
631+
565632
#: ../../c-api/buffer.rst:438
566633
msgid "Buffer-related functions"
567634
msgstr ""

c-api/call.po

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Python 3.12\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2024-04-18 00:04+0000\n"
11+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
1212
"PO-Revision-Date: 2022-10-16 03:20+0800\n"
1313
"Last-Translator: Matt Wang <[email protected]>\n"
1414
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -41,6 +41,12 @@ msgstr ""
4141
"設定 :c:member:`~PyTypeObject.tp_call` 的類別之實例都是可呼叫的。該擴充槽 "
4242
"(slot) 的簽章為: ::"
4343

44+
#: ../../c-api/call.rst:17
45+
msgid ""
46+
"PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs);"
47+
msgstr ""
48+
"PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs);"
49+
4450
#: ../../c-api/call.rst:19
4551
msgid ""
4652
"A call is made using a tuple for the positional arguments and a dict for the "
@@ -273,6 +279,10 @@ msgid ""
273279
"Currently equivalent to::"
274280
msgstr "給定一個 vectorcall *nargsf* 引數,回傳引數的實際數量。目前等同於: ::"
275281

282+
#: ../../c-api/call.rst:153
283+
msgid "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)"
284+
msgstr "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)"
285+
276286
#: ../../c-api/call.rst:155
277287
msgid ""
278288
"However, the function ``PyVectorcall_NARGS`` should be used to allow for "

c-api/capsule.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.12\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2023-07-29 00:03+0000\n"
10+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
1111
"PO-Revision-Date: 2018-05-23 14:30+0000\n"
1212
"Last-Translator: Adrian Liaw <[email protected]>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -41,6 +41,10 @@ msgstr ""
4141
msgid "The type of a destructor callback for a capsule. Defined as::"
4242
msgstr ""
4343

44+
#: ../../c-api/capsule.rst:29
45+
msgid "typedef void (*PyCapsule_Destructor)(PyObject *);"
46+
msgstr "typedef void (*PyCapsule_Destructor)(PyObject *);"
47+
4448
#: ../../c-api/capsule.rst:31
4549
msgid ""
4650
"See :c:func:`PyCapsule_New` for the semantics of PyCapsule_Destructor "

c-api/complex.po

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.12\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2024-07-18 00:03+0000\n"
10+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
1111
"PO-Revision-Date: 2015-12-09 17:51+0000\n"
1212
"Last-Translator: Matt Wang <[email protected]>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -61,6 +61,18 @@ msgstr ""
6161
msgid "The structure is defined as::"
6262
msgstr "該結構被定義為: ::"
6363

64+
#: ../../c-api/complex.rst:35
65+
msgid ""
66+
"typedef struct {\n"
67+
" double real;\n"
68+
" double imag;\n"
69+
"} Py_complex;"
70+
msgstr ""
71+
"typedef struct {\n"
72+
" double real;\n"
73+
" double imag;\n"
74+
"} Py_complex;"
75+
6476
#: ../../c-api/complex.rst:43
6577
msgid ""
6678
"Return the sum of two complex numbers, using the C :c:type:`Py_complex` "

c-api/contextvars.po

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ msgid ""
55
msgstr ""
66
"Project-Id-Version: Python 3.12\n"
77
"Report-Msgid-Bugs-To: \n"
8-
"POT-Creation-Date: 2024-03-07 17:26+0000\n"
8+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
99
"PO-Revision-Date: 2018-07-15 18:56+0800\n"
1010
"Last-Translator: \n"
1111
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -26,6 +26,15 @@ msgid ""
2626
"`PyContext`, :c:type:`PyContextVar`, and :c:type:`PyContextToken`, e.g.::"
2727
msgstr ""
2828

29+
#: ../../c-api/contextvars.rst:20
30+
msgid ""
31+
"// in 3.7.0:\n"
32+
"PyContext *PyContext_New(void);\n"
33+
"\n"
34+
"// in 3.7.1+:\n"
35+
"PyObject *PyContext_New(void);"
36+
msgstr ""
37+
2938
#: ../../c-api/contextvars.rst:26
3039
msgid "See :issue:`34762` for more details."
3140
msgstr "更多細節請見 :issue:`34762`。"

c-api/datetime.po

+6-6
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,15 @@ msgstr "為了方便模組實作 DB API 的巨集:"
355355
#: ../../c-api/datetime.rst:320
356356
msgid ""
357357
"Create and return a new :class:`datetime.datetime` object given an argument "
358-
"tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp()`."
358+
"tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp`."
359359
msgstr ""
360-
"給定一個適合傳遞給 :meth:`datetime.datetime.fromtimestamp()` 的引數元組,建立"
361-
"並回傳一個新的 :class:`datetime.datetime` 物件。"
360+
"給定一個適合傳遞給 :meth:`datetime.datetime.fromtimestamp` 的引數元組,建立並"
361+
"回傳一個新的 :class:`datetime.datetime` 物件。"
362362

363363
#: ../../c-api/datetime.rst:326
364364
msgid ""
365365
"Create and return a new :class:`datetime.date` object given an argument "
366-
"tuple suitable for passing to :meth:`datetime.date.fromtimestamp()`."
366+
"tuple suitable for passing to :meth:`datetime.date.fromtimestamp`."
367367
msgstr ""
368-
"給定一個適合傳遞給 :meth:`datetime.date.fromtimestamp()` 的引數元組,建立並回"
369-
"傳一個新的 :class:`datetime.date` 物件。"
368+
"給定一個適合傳遞給 :meth:`datetime.date.fromtimestamp` 的引數元組,建立並回傳"
369+
"一個新的 :class:`datetime.date` 物件。"

c-api/dict.po

+62-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgid ""
99
msgstr ""
1010
"Project-Id-Version: Python 3.12\n"
1111
"Report-Msgid-Bugs-To: \n"
12-
"POT-Creation-Date: 2023-09-03 00:03+0000\n"
12+
"POT-Creation-Date: 2024-09-01 22:24+0800\n"
1313
"PO-Revision-Date: 2017-09-22 18:26+0000\n"
1414
"Last-Translator: Liang-Bo Wang <[email protected]>\n"
1515
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -200,13 +200,62 @@ msgstr ""
200200
msgid "For example::"
201201
msgstr "舉例來說: ::"
202202

203+
#: ../../c-api/dict.rst:181
204+
msgid ""
205+
"PyObject *key, *value;\n"
206+
"Py_ssize_t pos = 0;\n"
207+
"\n"
208+
"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n"
209+
" /* do something interesting with the values... */\n"
210+
" ...\n"
211+
"}"
212+
msgstr ""
213+
203214
#: ../../c-api/dict.rst:189
204215
msgid ""
205216
"The dictionary *p* should not be mutated during iteration. It is safe to "
206217
"modify the values of the keys as you iterate over the dictionary, but only "
207218
"so long as the set of keys does not change. For example::"
208219
msgstr ""
209220

221+
#: ../../c-api/dict.rst:193
222+
msgid ""
223+
"PyObject *key, *value;\n"
224+
"Py_ssize_t pos = 0;\n"
225+
"\n"
226+
"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n"
227+
" long i = PyLong_AsLong(value);\n"
228+
" if (i == -1 && PyErr_Occurred()) {\n"
229+
" return -1;\n"
230+
" }\n"
231+
" PyObject *o = PyLong_FromLong(i + 1);\n"
232+
" if (o == NULL)\n"
233+
" return -1;\n"
234+
" if (PyDict_SetItem(self->dict, key, o) < 0) {\n"
235+
" Py_DECREF(o);\n"
236+
" return -1;\n"
237+
" }\n"
238+
" Py_DECREF(o);\n"
239+
"}"
240+
msgstr ""
241+
"PyObject *key, *value;\n"
242+
"Py_ssize_t pos = 0;\n"
243+
"\n"
244+
"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n"
245+
" long i = PyLong_AsLong(value);\n"
246+
" if (i == -1 && PyErr_Occurred()) {\n"
247+
" return -1;\n"
248+
" }\n"
249+
" PyObject *o = PyLong_FromLong(i + 1);\n"
250+
" if (o == NULL)\n"
251+
" return -1;\n"
252+
" if (PyDict_SetItem(self->dict, key, o) < 0) {\n"
253+
" Py_DECREF(o);\n"
254+
" return -1;\n"
255+
" }\n"
256+
" Py_DECREF(o);\n"
257+
"}"
258+
210259
#: ../../c-api/dict.rst:214
211260
msgid ""
212261
"Iterate over mapping object *b* adding key-value pairs to dictionary *a*. "
@@ -235,6 +284,18 @@ msgid ""
235284
"if an exception was raised. Equivalent Python (except for the return value)::"
236285
msgstr ""
237286

287+
#: ../../c-api/dict.rst:240
288+
msgid ""
289+
"def PyDict_MergeFromSeq2(a, seq2, override):\n"
290+
" for key, value in seq2:\n"
291+
" if override or key not in a:\n"
292+
" a[key] = value"
293+
msgstr ""
294+
"def PyDict_MergeFromSeq2(a, seq2, override):\n"
295+
" for key, value in seq2:\n"
296+
" if override or key not in a:\n"
297+
" a[key] = value"
298+
238299
#: ../../c-api/dict.rst:247
239300
msgid ""
240301
"Register *callback* as a dictionary watcher. Return a non-negative integer "

0 commit comments

Comments
 (0)