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