From 03adaee6d254e53c2151ccfda9720adf3287549c Mon Sep 17 00:00:00 2001 From: Wei-Ming Yang Date: Sun, 18 Oct 2015 18:41:09 +0800 Subject: [PATCH] Implement `str::endswith()` --- src/str.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/str.cpp b/src/str.cpp index 0bc225aa..5122f7f5 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -162,6 +162,22 @@ bool str_base::endswith(object_cref suffix) const return result; } +bool str_base::endswith(object_cref suffix, object_cref start) const +{ + bool result = _BOOST_PYTHON_ASLONG(this->attr("endswith")(suffix,start).ptr()); + if (PyErr_Occurred()) + throw_error_already_set(); + return result; +} + +bool str_base::endswith(object_cref suffix, object_cref start, object_cref end) const +{ + bool result = _BOOST_PYTHON_ASLONG(this->attr("endswith")(suffix,start,end).ptr()); + if (PyErr_Occurred()) + throw_error_already_set(); + return result; +} + BOOST_PYTHON_DEFINE_STR_METHOD(expandtabs, 0) BOOST_PYTHON_DEFINE_STR_METHOD(expandtabs, 1)