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