]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95065: Argument Clinic: Pretty-print long C strings in generated code (#107712)
authorErlend E. Aasland <erlend@python.org>
Mon, 7 Aug 2023 14:33:52 +0000 (16:33 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Aug 2023 14:33:52 +0000 (14:33 +0000)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/clinic.test.c
Tools/clinic/clinic.py

index 321ac69273189fcbda67bd5d21cac9f56f744c56..c5c37b7e9e2168bb30aa61f44172f2f5a8fbf08b 100644 (file)
@@ -5521,17 +5521,31 @@ test_deprecate_positional_pos1_len1_optional(PyObject *module, PyObject *const *
     PyObject *b = Py_None;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'b' in the clinic input of 'test_deprecate_positional_pos1_len1_optional' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'b' in the clinic input of" \
+            " 'test_deprecate_positional_pos1_len1_optional' to be " \
+            "keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'b' in the clinic input of 'test_deprecate_positional_pos1_len1_optional' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'b' in the clinic input of" \
+            " 'test_deprecate_positional_pos1_len1_optional' to be " \
+            "keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'b' in the clinic input of 'test_deprecate_positional_pos1_len1_optional' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'b' in the clinic input of" \
+            " 'test_deprecate_positional_pos1_len1_optional' to be " \
+            "keyword-only."
     #  endif
     #endif
     if (nargs == 2) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing 2 positional arguments to test_deprecate_positional_pos1_len1_optional() is deprecated. Parameter 'b' will become a keyword-only parameter in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing 2 positional arguments to "
+                "test_deprecate_positional_pos1_len1_optional() is deprecated. "
+                "Parameter 'b' will become a keyword-only parameter in Python "
+                "3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
@@ -5553,7 +5567,7 @@ exit:
 static PyObject *
 test_deprecate_positional_pos1_len1_optional_impl(PyObject *module,
                                                   PyObject *a, PyObject *b)
-/*[clinic end generated code: output=20bdea6a2960ddf3 input=89099f3dacd757da]*/
+/*[clinic end generated code: output=09a6edec1ddcd469 input=89099f3dacd757da]*/
 
 
 /*[clinic input]
@@ -5609,17 +5623,27 @@ test_deprecate_positional_pos1_len1(PyObject *module, PyObject *const *args, Py_
     PyObject *b;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'b' in the clinic input of 'test_deprecate_positional_pos1_len1' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'b' in the clinic input of" \
+            " 'test_deprecate_positional_pos1_len1' to be keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'b' in the clinic input of 'test_deprecate_positional_pos1_len1' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'b' in the clinic input of" \
+            " 'test_deprecate_positional_pos1_len1' to be keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'b' in the clinic input of 'test_deprecate_positional_pos1_len1' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'b' in the clinic input of" \
+            " 'test_deprecate_positional_pos1_len1' to be keyword-only."
     #  endif
     #endif
     if (nargs == 2) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing 2 positional arguments to test_deprecate_positional_pos1_len1() is deprecated. Parameter 'b' will become a keyword-only parameter in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing 2 positional arguments to "
+                "test_deprecate_positional_pos1_len1() is deprecated. Parameter "
+                "'b' will become a keyword-only parameter in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
@@ -5637,7 +5661,7 @@ exit:
 static PyObject *
 test_deprecate_positional_pos1_len1_impl(PyObject *module, PyObject *a,
                                          PyObject *b)
-/*[clinic end generated code: output=22c70f8b36085758 input=1702bbab1e9b3b99]*/
+/*[clinic end generated code: output=52a2618293df747d input=1702bbab1e9b3b99]*/
 
 
 /*[clinic input]
@@ -5699,17 +5723,31 @@ test_deprecate_positional_pos1_len2_with_kwd(PyObject *module, PyObject *const *
     PyObject *d;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'b' and 'c' in the clinic input of 'test_deprecate_positional_pos1_len2_with_kwd' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'b' and 'c' in the clinic " \
+            "input of 'test_deprecate_positional_pos1_len2_with_kwd' to be " \
+            "keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'b' and 'c' in the clinic input of 'test_deprecate_positional_pos1_len2_with_kwd' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'b' and 'c' in the clinic " \
+            "input of 'test_deprecate_positional_pos1_len2_with_kwd' to be " \
+            "keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'b' and 'c' in the clinic input of 'test_deprecate_positional_pos1_len2_with_kwd' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'b' and 'c' in the clinic " \
+            "input of 'test_deprecate_positional_pos1_len2_with_kwd' to be " \
+            "keyword-only."
     #  endif
     #endif
     if (nargs > 1 && nargs <= 3) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing more than 1 positional argument to test_deprecate_positional_pos1_len2_with_kwd() is deprecated. Parameters 'b' and 'c' will become keyword-only parameters in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing more than 1 positional argument to "
+                "test_deprecate_positional_pos1_len2_with_kwd() is deprecated. "
+                "Parameters 'b' and 'c' will become keyword-only parameters in "
+                "Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 1, argsbuf);
@@ -5730,7 +5768,7 @@ static PyObject *
 test_deprecate_positional_pos1_len2_with_kwd_impl(PyObject *module,
                                                   PyObject *a, PyObject *b,
                                                   PyObject *c, PyObject *d)
-/*[clinic end generated code: output=79c5f04220a1f3aa input=28cdb885f6c34eab]*/
+/*[clinic end generated code: output=550aabea548589b4 input=28cdb885f6c34eab]*/
 
 
 /*[clinic input]
@@ -5783,17 +5821,27 @@ test_deprecate_positional_pos0_len1(PyObject *module, PyObject *const *args, Py_
     PyObject *a;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'a' in the clinic input of 'test_deprecate_positional_pos0_len1' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'a' in the clinic input of" \
+            " 'test_deprecate_positional_pos0_len1' to be keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'a' in the clinic input of 'test_deprecate_positional_pos0_len1' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'a' in the clinic input of" \
+            " 'test_deprecate_positional_pos0_len1' to be keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'a' in the clinic input of 'test_deprecate_positional_pos0_len1' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'a' in the clinic input of" \
+            " 'test_deprecate_positional_pos0_len1' to be keyword-only."
     #  endif
     #endif
     if (nargs == 1) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing positional arguments to test_deprecate_positional_pos0_len1() is deprecated. Parameter 'a' will become a keyword-only parameter in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing positional arguments to "
+                "test_deprecate_positional_pos0_len1() is deprecated. Parameter "
+                "'a' will become a keyword-only parameter in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
@@ -5809,7 +5857,7 @@ exit:
 
 static PyObject *
 test_deprecate_positional_pos0_len1_impl(PyObject *module, PyObject *a)
-/*[clinic end generated code: output=1b7f23b9ffca431b input=678206db25c0652c]*/
+/*[clinic end generated code: output=66c63ec8d6903bde input=678206db25c0652c]*/
 
 
 /*[clinic input]
@@ -5865,17 +5913,30 @@ test_deprecate_positional_pos0_len2(PyObject *module, PyObject *const *args, Py_
     PyObject *b;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'a' and 'b' in the clinic input of 'test_deprecate_positional_pos0_len2' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'a' and 'b' in the clinic " \
+            "input of 'test_deprecate_positional_pos0_len2' to be " \
+            "keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'a' and 'b' in the clinic input of 'test_deprecate_positional_pos0_len2' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'a' and 'b' in the clinic " \
+            "input of 'test_deprecate_positional_pos0_len2' to be " \
+            "keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'a' and 'b' in the clinic input of 'test_deprecate_positional_pos0_len2' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'a' and 'b' in the clinic " \
+            "input of 'test_deprecate_positional_pos0_len2' to be " \
+            "keyword-only."
     #  endif
     #endif
     if (nargs > 0 && nargs <= 2) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing positional arguments to test_deprecate_positional_pos0_len2() is deprecated. Parameters 'a' and 'b' will become keyword-only parameters in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing positional arguments to "
+                "test_deprecate_positional_pos0_len2() is deprecated. Parameters "
+                "'a' and 'b' will become keyword-only parameters in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
@@ -5893,7 +5954,7 @@ exit:
 static PyObject *
 test_deprecate_positional_pos0_len2_impl(PyObject *module, PyObject *a,
                                          PyObject *b)
-/*[clinic end generated code: output=31b494f2dcc016af input=fae0d0b1d480c939]*/
+/*[clinic end generated code: output=6b6df40aaf751b2e input=fae0d0b1d480c939]*/
 
 
 /*[clinic input]
@@ -5958,17 +6019,34 @@ test_deprecate_positional_pos0_len3_with_kwdonly(PyObject *module, PyObject *con
     PyObject *e;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'a', 'b' and 'c' in the clinic input of 'test_deprecate_positional_pos0_len3_with_kwdonly' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'a', 'b' and 'c' in the " \
+            "clinic input of " \
+            "'test_deprecate_positional_pos0_len3_with_kwdonly' to be " \
+            "keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'a', 'b' and 'c' in the clinic input of 'test_deprecate_positional_pos0_len3_with_kwdonly' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'a', 'b' and 'c' in the " \
+            "clinic input of " \
+            "'test_deprecate_positional_pos0_len3_with_kwdonly' to be " \
+            "keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'a', 'b' and 'c' in the clinic input of 'test_deprecate_positional_pos0_len3_with_kwdonly' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'a', 'b' and 'c' in the " \
+            "clinic input of " \
+            "'test_deprecate_positional_pos0_len3_with_kwdonly' to be " \
+            "keyword-only."
     #  endif
     #endif
     if (nargs > 0 && nargs <= 3) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing positional arguments to test_deprecate_positional_pos0_len3_with_kwdonly() is deprecated. Parameters 'a', 'b' and 'c' will become keyword-only parameters in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing positional arguments to "
+                "test_deprecate_positional_pos0_len3_with_kwdonly() is "
+                "deprecated. Parameters 'a', 'b' and 'c' will become keyword-only"
+                " parameters in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 1, argsbuf);
@@ -5991,7 +6069,7 @@ test_deprecate_positional_pos0_len3_with_kwdonly_impl(PyObject *module,
                                                       PyObject *b,
                                                       PyObject *c,
                                                       PyObject *e)
-/*[clinic end generated code: output=96978e786acfbc7b input=1b0121770c0c52e0]*/
+/*[clinic end generated code: output=5c936993846d01a3 input=1b0121770c0c52e0]*/
 
 
 /*[clinic input]
@@ -6049,17 +6127,27 @@ test_deprecate_positional_pos2_len1(PyObject *module, PyObject *const *args, Py_
     PyObject *c;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'c' in the clinic input of 'test_deprecate_positional_pos2_len1' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'c' in the clinic input of" \
+            " 'test_deprecate_positional_pos2_len1' to be keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'c' in the clinic input of 'test_deprecate_positional_pos2_len1' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'c' in the clinic input of" \
+            " 'test_deprecate_positional_pos2_len1' to be keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'c' in the clinic input of 'test_deprecate_positional_pos2_len1' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'c' in the clinic input of" \
+            " 'test_deprecate_positional_pos2_len1' to be keyword-only."
     #  endif
     #endif
     if (nargs == 3) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing 3 positional arguments to test_deprecate_positional_pos2_len1() is deprecated. Parameter 'c' will become a keyword-only parameter in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing 3 positional arguments to "
+                "test_deprecate_positional_pos2_len1() is deprecated. Parameter "
+                "'c' will become a keyword-only parameter in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
@@ -6078,7 +6166,7 @@ exit:
 static PyObject *
 test_deprecate_positional_pos2_len1_impl(PyObject *module, PyObject *a,
                                          PyObject *b, PyObject *c)
-/*[clinic end generated code: output=ceadd05f11f7f491 input=e1d129689e69ec7c]*/
+/*[clinic end generated code: output=2641e037296e3b61 input=e1d129689e69ec7c]*/
 
 
 /*[clinic input]
@@ -6139,17 +6227,30 @@ test_deprecate_positional_pos2_len2(PyObject *module, PyObject *const *args, Py_
     PyObject *d;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic input of 'test_deprecate_positional_pos2_len2' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic " \
+            "input of 'test_deprecate_positional_pos2_len2' to be " \
+            "keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic input of 'test_deprecate_positional_pos2_len2' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic " \
+            "input of 'test_deprecate_positional_pos2_len2' to be " \
+            "keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic input of 'test_deprecate_positional_pos2_len2' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic " \
+            "input of 'test_deprecate_positional_pos2_len2' to be " \
+            "keyword-only."
     #  endif
     #endif
     if (nargs > 2 && nargs <= 4) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing more than 2 positional arguments to test_deprecate_positional_pos2_len2() is deprecated. Parameters 'c' and 'd' will become keyword-only parameters in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing more than 2 positional arguments to "
+                "test_deprecate_positional_pos2_len2() is deprecated. Parameters "
+                "'c' and 'd' will become keyword-only parameters in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 4, 0, argsbuf);
@@ -6170,7 +6271,7 @@ static PyObject *
 test_deprecate_positional_pos2_len2_impl(PyObject *module, PyObject *a,
                                          PyObject *b, PyObject *c,
                                          PyObject *d)
-/*[clinic end generated code: output=5693682e3fa1188b input=0d53533463a12792]*/
+/*[clinic end generated code: output=4a9068ef8fee61f6 input=0d53533463a12792]*/
 
 
 /*[clinic input]
@@ -6238,17 +6339,31 @@ test_deprecate_positional_pos2_len3_with_kwdonly(PyObject *module, PyObject *con
     PyObject *e;
 
     #if PY_VERSION_HEX >= 0x030e00C0
-    #  error "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic input of 'test_deprecate_positional_pos2_len3_with_kwdonly' to be keyword-only."
+    #  error \
+            "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic " \
+            "input of 'test_deprecate_positional_pos2_len3_with_kwdonly' to " \
+            "be keyword-only."
     #elif PY_VERSION_HEX >= 0x030e00A0
     #  ifdef _MSC_VER
-    #    pragma message ("In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic input of 'test_deprecate_positional_pos2_len3_with_kwdonly' to be keyword-only.")
+    #    pragma message ( \
+            "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic " \
+            "input of 'test_deprecate_positional_pos2_len3_with_kwdonly' to " \
+            "be keyword-only.")
     #  else
-    #    warning "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic input of 'test_deprecate_positional_pos2_len3_with_kwdonly' to be keyword-only."
+    #    warning \
+            "In clinic.test.c, update parameter(s) 'c' and 'd' in the clinic " \
+            "input of 'test_deprecate_positional_pos2_len3_with_kwdonly' to " \
+            "be keyword-only."
     #  endif
     #endif
     if (nargs > 2 && nargs <= 4) {
-        if (PyErr_WarnEx(PyExc_DeprecationWarning, "Passing more than 2 positional arguments to test_deprecate_positional_pos2_len3_with_kwdonly() is deprecated. Parameters 'c' and 'd' will become keyword-only parameters in Python 3.14.", 1)) {
-            goto exit;
+        if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                "Passing more than 2 positional arguments to "
+                "test_deprecate_positional_pos2_len3_with_kwdonly() is "
+                "deprecated. Parameters 'c' and 'd' will become keyword-only "
+                "parameters in Python 3.14.", 1))
+        {
+                goto exit;
         }
     }
     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 4, 1, argsbuf);
@@ -6273,4 +6388,4 @@ test_deprecate_positional_pos2_len3_with_kwdonly_impl(PyObject *module,
                                                       PyObject *c,
                                                       PyObject *d,
                                                       PyObject *e)
-/*[clinic end generated code: output=00d436de747a00f3 input=154fd450448d8935]*/
+/*[clinic end generated code: output=1154c2e3e798948c input=154fd450448d8935]*/
index 2bed98c23674e0695ff850c0f595713c1f9bedb3..3a8431cb67efeaaca9eceb85029f9c94685bdee6 100755 (executable)
@@ -221,6 +221,20 @@ def c_repr(s: str) -> str:
     return '"' + s + '"'
 
 
+def wrapped_c_string_literal(
+        text: str,
+        *,
+        width: int = 72,
+        suffix: str = '',
+        initial_indent: int = 0,
+        subsequent_indent: int = 4
+) -> str:
+    wrapped = textwrap.wrap(text, width=width, replace_whitespace=False,
+                            drop_whitespace=False, break_on_hyphens=False)
+    separator = '"' + suffix + '\n' + subsequent_indent * ' ' + '"'
+    return initial_indent * ' ' + '"' + separator.join(wrapped) + '"'
+
+
 is_legal_c_identifier = re.compile('^[A-Za-z_][A-Za-z0-9_]*$').match
 
 def is_legal_py_identifier(s: str) -> bool:
@@ -837,17 +851,22 @@ class CLanguage(Language):
     """)
     DEPRECATED_POSITIONAL_PROTOTYPE: Final[str] = r"""
         #if PY_VERSION_HEX >= 0x{major:02x}{minor:02x}00C0
-        #  error "{cpp_message}"
+        #  error \
+                {cpp_message}
         #elif PY_VERSION_HEX >= 0x{major:02x}{minor:02x}00A0
         #  ifdef _MSC_VER
-        #    pragma message ("{cpp_message}")
+        #    pragma message ( \
+                {cpp_message})
         #  else
-        #    warning "{cpp_message}"
+        #    warning \
+                {cpp_message}
         #  endif
         #endif
         if ({condition}) {{{{
-            if (PyErr_WarnEx(PyExc_DeprecationWarning, "{depr_message}", 1)) {{{{
-                goto exit;
+            if (PyErr_WarnEx(PyExc_DeprecationWarning,
+                    {depr_message}, 1))
+            {{{{
+                    goto exit;
             }}}}
         }}}}
     """
@@ -899,6 +918,7 @@ class CLanguage(Language):
             f"In {source}, update parameter(s) {pstr} in the clinic "
             f"input of {func.full_name!r} to be keyword-only."
         )
+
         # Format the deprecation message.
         if first_pos == 0:
             preamble = "Passing positional arguments to "
@@ -926,8 +946,11 @@ class CLanguage(Language):
             condition=condition,
             major=major,
             minor=minor,
-            cpp_message=cpp_message,
-            depr_message=depr_message,
+            cpp_message=wrapped_c_string_literal(cpp_message, suffix=" \\",
+                                                 width=64,
+                                                 subsequent_indent=16),
+            depr_message=wrapped_c_string_literal(depr_message, width=64,
+                                                  subsequent_indent=20),
         )
         return normalize_snippet(code, indent=4)