Commit a771457a authored by Boxiang Sun's avatar Boxiang Sun

add two attribute to str cls that let test_string could pass

parent c79439cf
......@@ -23,6 +23,22 @@ PyObject * _do_string_format(PyObject *self, PyObject *args, PyObject *kwargs) {
return do_string_format(self, args, kwargs);
}
void _string_init() {
if (PyType_Ready(&PyFieldNameIter_Type) < 0)
Py_FatalError("Can't initialize field name iterator type");
if (PyType_Ready(&PyFormatterIter_Type) < 0)
Py_FatalError("Can't initialize formatter iter type");
}
PyObject * _formatter_parser(STRINGLIB_OBJECT *self) {
return formatter_parser(self);
}
PyObject * _formatter_field_name_split(STRINGLIB_OBJECT *self) {
return formatter_field_name_split(self);
}
PyObject *
string_count(PyStringObject *self,
PyObject *sub_obj, PyObject* obj_start, PyObject** args)
......
......@@ -45,6 +45,8 @@ extern "C" PyObject* string_rfind(PyStringObject* self, PyObject* args) noexcept
extern "C" PyObject* string_replace(PyStringObject* self, PyObject* args) noexcept;
extern "C" PyObject* string_splitlines(PyStringObject* self, PyObject* args) noexcept;
extern "C" PyObject* string__format__(PyObject* self, PyObject* args) noexcept;
extern "C" PyObject* _formatter_parser(PyStringObject* self) noexcept;
extern "C" PyObject* _formatter_field_name_split(PyStringObject* self) noexcept;
// from cpython's stringobject.c:
#define LEFTSTRIP 0
......@@ -2784,6 +2786,8 @@ static PyMethodDef string_methods[] = {
{ "splitlines", (PyCFunction)string_splitlines, METH_VARARGS, NULL },
{ "zfill", (PyCFunction)string_zfill, METH_VARARGS, NULL },
{ "__format__", (PyCFunction)string__format__, METH_VARARGS, NULL },
{ "_formatter_parser", (PyCFunction)_formatter_parser, METH_NOARGS, NULL },
{ "_formatter_field_name_split", (PyCFunction)_formatter_field_name_split, METH_NOARGS, NULL },
};
void setupStr() {
......
......@@ -77,6 +77,7 @@ extern "C" void initzlib();
extern "C" void init_codecs();
extern "C" void init_socket();
extern "C" void _PyUnicode_Init();
extern "C" void _string_init();
extern "C" void initunicodedata();
extern "C" void init_weakref();
extern "C" void initcStringIO();
......@@ -3936,6 +3937,7 @@ void setupRuntime() {
setupClassobj();
setupSuper();
_PyUnicode_Init();
_string_init();
setupDescr();
setupTraceback();
setupCode();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment