diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2025-04-30 11:46:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-30 11:46:41 +0200 |
commit | 60202609a2c2d0971aadfa4729ba30b50e89c6ea (patch) | |
tree | d821f3f8f277de56e5d8da457d492f1288cb2bb9 /Objects/unicodeobject.c | |
parent | 5ea9010e8910cb97555c3aef4ed95cca93a74aab (diff) | |
download | cpython-60202609a2c2d0971aadfa4729ba30b50e89c6ea.tar.gz cpython-60202609a2c2d0971aadfa4729ba30b50e89c6ea.zip |
gh-132661: Implement PEP 750 (#132662)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Wingy <git@wingysam.xyz>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
Co-authored-by: Dave Peck <davepeck@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Paul Everitt <pauleveritt@me.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index b3287546dd9..462323a828e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -56,6 +56,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "pycore_pyhash.h" // _Py_HashSecret_t #include "pycore_pylifecycle.h" // _Py_SetFileSystemEncoding() #include "pycore_pystate.h" // _PyInterpreterState_GET() +#include "pycore_template.h" // _PyTemplate_Concat() #include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI #include "pycore_unicodeobject.h" // struct _Py_unicode_state @@ -11628,10 +11629,16 @@ PyUnicode_Concat(PyObject *left, PyObject *right) return NULL; if (!PyUnicode_Check(right)) { - PyErr_Format(PyExc_TypeError, - "can only concatenate str (not \"%.200s\") to str", - Py_TYPE(right)->tp_name); - return NULL; + if (_PyTemplate_CheckExact(right)) { + // str + tstring is implemented in the tstring type + return _PyTemplate_Concat(left, right); + } + else { + PyErr_Format(PyExc_TypeError, + "can only concatenate str (not \"%.200s\") to str", + Py_TYPE(right)->tp_name); + return NULL; + } } /* Shortcuts */ |