-
Notifications
You must be signed in to change notification settings - Fork 3
Track for new and join on both str and unicode #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1646,6 +1646,15 @@ string_join(PyStringObject *self, PyObject *orig) | |
| * original sequence can be iterated over | ||
| * again, so we must pass seq here. | ||
| */ | ||
| if (!PyString_Check(item) && !item->ob_bstate == NULL) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I now realise is we probably need a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Today I started to add Py_GetBState, I broke other tests that I am still fixing. |
||
| if (PyErr_WarnPy3k("Concatenation only works for bytes to bytes in 3.x: convert the string to bytes.", 1) < 0) { | ||
| return NULL; | ||
| } | ||
| } | ||
|
|
||
| if (!PyString_Check(orig) && item->ob_bstate == NULL) { | ||
| item->ob_bstate = BSTATE_BYTE; | ||
| } | ||
| PyObject *result; | ||
| result = PyUnicode_Join((PyObject *)self, seq); | ||
| Py_DECREF(seq); | ||
|
|
@@ -1700,6 +1709,7 @@ _PyString_Join(PyObject *sep, PyObject *x) | |
| { | ||
| assert(sep != NULL && PyString_Check(sep)); | ||
| assert(x != NULL); | ||
|
|
||
| return string_join((PyStringObject *)sep, x); | ||
| } | ||
|
|
||
|
|
@@ -3719,16 +3729,20 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); | |
| static PyObject * | ||
| string_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | ||
| { | ||
|
|
||
| PyObject *x = NULL; | ||
| static char *kwlist[] = {"object", 0}; | ||
| PyStringObject *tmp = NULL; | ||
|
|
||
| if (type != &PyString_Type) | ||
| return str_subtype_new(type, args, kwds); | ||
| if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:str", kwlist, &x)) | ||
| return NULL; | ||
| if (x == NULL) | ||
| return PyString_FromString(""); | ||
| return PyObject_Str(x); | ||
| tmp = PyObject_Str(x); | ||
| tmp->ob_bstate = BSTATE_BYTE; | ||
| return tmp; | ||
| } | ||
|
|
||
| static PyObject * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to put this only in strings/bytes, rather than in every object? Or is that not possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some methods use the abstract object type see: #39 , so it is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what it means to ask for the bstate of something that isn't a string. Maybe I'm missing something!