@@ -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 : Japanese (https://app.transifex.com/python-doc/teams/5390/ "
@@ -708,6 +708,144 @@ msgid ""
708708"return (char*)PyBytesWriter_GetData(writer) + pos;"
709709msgstr ""
710710
711+ #: ../../c-api/bytes.rst:464
712+ msgid "Example creating the string ``b'abc'``"
713+ msgstr ""
714+
715+ #: ../../c-api/bytes.rst:466
716+ msgid ""
717+ "Example creating the bytes string ``b\" abc\" ``, with a fixed size of 3 "
718+ "bytes::"
719+ msgstr ""
720+
721+ #: ../../c-api/bytes.rst:468
722+ msgid ""
723+ "PyObject* create_abc(void)\n"
724+ "{\n"
725+ " PyBytesWriter *writer = PyBytesWriter_Create(3);\n"
726+ " if (writer == NULL) {\n"
727+ " return NULL;\n"
728+ " }\n"
729+ "\n"
730+ " char *str = PyBytesWriter_GetData(writer);\n"
731+ " memcpy(str, \" abc\" , 3);\n"
732+ " return PyBytesWriter_Finish(writer);\n"
733+ "}"
734+ msgstr ""
735+
736+ #: ../../c-api/bytes.rst:480
737+ msgid "Variant using a pointer to compute the final size::"
738+ msgstr ""
739+
740+ #: ../../c-api/bytes.rst:482
741+ msgid ""
742+ "PyObject* create_abc_ptr(void)\n"
743+ "{\n"
744+ " PyBytesWriter *writer = PyBytesWriter_Create(3);\n"
745+ " if (writer == NULL) {\n"
746+ " return NULL;\n"
747+ " }\n"
748+ "\n"
749+ " char *str = PyBytesWriter_GetData(writer);\n"
750+ " memcpy(str, \" abc\" , 3);\n"
751+ " str += 1;\n"
752+ " return PyBytesWriter_FinishWithPointer(writer, str);\n"
753+ "}"
754+ msgstr ""
755+
756+ #: ../../c-api/bytes.rst:497
757+ msgid "Update ``PyBytes_FromStringAndSize()`` code"
758+ msgstr ""
759+
760+ #: ../../c-api/bytes.rst:499
761+ msgid ""
762+ "Example of code using the soft deprecated ``PyBytes_FromStringAndSize(NULL, "
763+ "size)`` API::"
764+ msgstr ""
765+
766+ #: ../../c-api/bytes.rst:502
767+ msgid ""
768+ "int copy_bytes(char *dest, const char *src, Py_ssize_t num_bytes)\n"
769+ "{\n"
770+ " ...\n"
771+ "}\n"
772+ "\n"
773+ "PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n"
774+ "{\n"
775+ " PyObject *result = PyBytes_FromStringAndSize(NULL, num_bytes);\n"
776+ " if (result == NULL) {\n"
777+ " return NULL;\n"
778+ " }\n"
779+ " if (copy_bytes(PyBytes_AS_STRING(result), start, num_bytes) < 0) {\n"
780+ " Py_CLEAR(result);\n"
781+ " }\n"
782+ " return result;\n"
783+ "}"
784+ msgstr ""
785+
786+ #: ../../c-api/bytes.rst:519 ../../c-api/bytes.rst:556
787+ msgid "It can now be updated to::"
788+ msgstr ""
789+
790+ #: ../../c-api/bytes.rst:521
791+ msgid ""
792+ "PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n"
793+ "{\n"
794+ " PyBytesWriter *writer = PyBytesWriter_Create(num_bytes);\n"
795+ " if (writer == NULL) {\n"
796+ " return NULL;\n"
797+ " }\n"
798+ " if (copy_bytes(PyBytesWriter_GetData(writer), start, num_bytes) < 0) {\n"
799+ " PyBytesWriter_Discard(writer);\n"
800+ " return NULL;\n"
801+ " }\n"
802+ " return PyBytesWriter_Finish(writer);\n"
803+ "}"
804+ msgstr ""
805+
806+ #: ../../c-api/bytes.rst:536
807+ msgid "Update ``_PyBytes_Resize()`` code"
808+ msgstr ""
809+
810+ #: ../../c-api/bytes.rst:538
811+ msgid "Example of code using the soft deprecated ``_PyBytes_Resize()`` API::"
812+ msgstr ""
813+
814+ #: ../../c-api/bytes.rst:540
815+ msgid ""
816+ "void create_string(Py_ssize_t size)\n"
817+ "{\n"
818+ " PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);\n"
819+ " if (bytes == NULL) {\n"
820+ " return NULL;\n"
821+ " }\n"
822+ " char *str = PyBytes_AS_STRING(bytes);\n"
823+ "\n"
824+ " // ... write data into str ...\n"
825+ "\n"
826+ " if (_PyBytes_Resize(&bytes, (str - PyBytes_AS_STRING(bytes)))) {\n"
827+ " return NULL;\n"
828+ " }\n"
829+ " return bytes;\n"
830+ "}"
831+ msgstr ""
832+
833+ #: ../../c-api/bytes.rst:558
834+ msgid ""
835+ "void create_string(Py_ssize_t size)\n"
836+ "{\n"
837+ " PyBytesWriter *writer = PyBytesWriter_Create(size);\n"
838+ " if (writer == NULL) {\n"
839+ " return NULL;\n"
840+ " }\n"
841+ " char *str = PyBytesWriter_GetData(writer);\n"
842+ "\n"
843+ " // ... write data into str ...\n"
844+ "\n"
845+ " return PyBytesWriter_FinishWithPointer(writer, str);\n"
846+ "}"
847+ msgstr ""
848+
711849#: ../../c-api/bytes.rst:18
712850msgid "object"
713851msgstr "object"
0 commit comments