@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.15\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2026-10-05 21:29 +0000\n "
14+ "POT-Creation-Date : 2026-10-11 18:31 +0000\n "
1515"PO-Revision-Date : 2025-09-16 00:00+0000\n "
1616"Last-Translator : python-doc bot, 2026\n "
1717"Language-Team : Russian (https://app.transifex.com/python-doc/teams/5390/ "
@@ -538,6 +538,130 @@ msgid ""
538538"return (char*)PyBytesWriter_GetData(writer) + pos;"
539539msgstr ""
540540
541+ msgid "Example creating the string ``b'abc'``"
542+ msgstr ""
543+
544+ msgid ""
545+ "Example creating the bytes string ``b\" abc\" ``, with a fixed size of 3 "
546+ "bytes::"
547+ msgstr ""
548+
549+ msgid ""
550+ "PyObject* create_abc(void)\n"
551+ "{\n"
552+ " PyBytesWriter *writer = PyBytesWriter_Create(3);\n"
553+ " if (writer == NULL) {\n"
554+ " return NULL;\n"
555+ " }\n"
556+ "\n"
557+ " char *str = PyBytesWriter_GetData(writer);\n"
558+ " memcpy(str, \" abc\" , 3);\n"
559+ " return PyBytesWriter_Finish(writer);\n"
560+ "}"
561+ msgstr ""
562+
563+ msgid "Variant using a pointer to compute the final size::"
564+ msgstr ""
565+
566+ msgid ""
567+ "PyObject* create_abc_ptr(void)\n"
568+ "{\n"
569+ " PyBytesWriter *writer = PyBytesWriter_Create(3);\n"
570+ " if (writer == NULL) {\n"
571+ " return NULL;\n"
572+ " }\n"
573+ "\n"
574+ " char *str = PyBytesWriter_GetData(writer);\n"
575+ " memcpy(str, \" abc\" , 3);\n"
576+ " str += 1;\n"
577+ " return PyBytesWriter_FinishWithPointer(writer, str);\n"
578+ "}"
579+ msgstr ""
580+
581+ msgid "Update ``PyBytes_FromStringAndSize()`` code"
582+ msgstr ""
583+
584+ msgid ""
585+ "Example of code using the soft deprecated ``PyBytes_FromStringAndSize(NULL, "
586+ "size)`` API::"
587+ msgstr ""
588+
589+ msgid ""
590+ "int copy_bytes(char *dest, const char *src, Py_ssize_t num_bytes)\n"
591+ "{\n"
592+ " ...\n"
593+ "}\n"
594+ "\n"
595+ "PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n"
596+ "{\n"
597+ " PyObject *result = PyBytes_FromStringAndSize(NULL, num_bytes);\n"
598+ " if (result == NULL) {\n"
599+ " return NULL;\n"
600+ " }\n"
601+ " if (copy_bytes(PyBytes_AS_STRING(result), start, num_bytes) < 0) {\n"
602+ " Py_CLEAR(result);\n"
603+ " }\n"
604+ " return result;\n"
605+ "}"
606+ msgstr ""
607+
608+ msgid "It can now be updated to::"
609+ msgstr ""
610+
611+ msgid ""
612+ "PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n"
613+ "{\n"
614+ " PyBytesWriter *writer = PyBytesWriter_Create(num_bytes);\n"
615+ " if (writer == NULL) {\n"
616+ " return NULL;\n"
617+ " }\n"
618+ " if (copy_bytes(PyBytesWriter_GetData(writer), start, num_bytes) < 0) {\n"
619+ " PyBytesWriter_Discard(writer);\n"
620+ " return NULL;\n"
621+ " }\n"
622+ " return PyBytesWriter_Finish(writer);\n"
623+ "}"
624+ msgstr ""
625+
626+ msgid "Update ``_PyBytes_Resize()`` code"
627+ msgstr ""
628+
629+ msgid "Example of code using the soft deprecated ``_PyBytes_Resize()`` API::"
630+ msgstr ""
631+
632+ msgid ""
633+ "void create_string(Py_ssize_t size)\n"
634+ "{\n"
635+ " PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);\n"
636+ " if (bytes == NULL) {\n"
637+ " return NULL;\n"
638+ " }\n"
639+ " char *str = PyBytes_AS_STRING(bytes);\n"
640+ "\n"
641+ " // ... write data into str ...\n"
642+ "\n"
643+ " if (_PyBytes_Resize(&bytes, (str - PyBytes_AS_STRING(bytes)))) {\n"
644+ " return NULL;\n"
645+ " }\n"
646+ " return bytes;\n"
647+ "}"
648+ msgstr ""
649+
650+ msgid ""
651+ "void create_string(Py_ssize_t size)\n"
652+ "{\n"
653+ " PyBytesWriter *writer = PyBytesWriter_Create(size);\n"
654+ " if (writer == NULL) {\n"
655+ " return NULL;\n"
656+ " }\n"
657+ " char *str = PyBytesWriter_GetData(writer);\n"
658+ "\n"
659+ " // ... write data into str ...\n"
660+ "\n"
661+ " return PyBytesWriter_FinishWithPointer(writer, str);\n"
662+ "}"
663+ msgstr ""
664+
541665msgid "object"
542666msgstr ""
543667
0 commit comments