CustomObject *self;
self = (CustomObject *) type->tp_alloc(type, 0);
if (self != NULL) {
- self->first = PyUnicode_FromString("");
+ self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (self->first == NULL) {
Py_DECREF(self);
return NULL;
}
- self->last = PyUnicode_FromString("");
+ self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (self->last == NULL) {
Py_DECREF(self);
return NULL;
CustomObject *self;
self = (CustomObject *) type->tp_alloc(type, 0);
if (self != NULL) {
- self->first = PyUnicode_FromString("");
+ self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (self->first == NULL) {
Py_DECREF(self);
return NULL;
}
- self->last = PyUnicode_FromString("");
+ self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (self->last == NULL) {
Py_DECREF(self);
return NULL;
CustomObject *self;
self = (CustomObject *) type->tp_alloc(type, 0);
if (self != NULL) {
- self->first = PyUnicode_FromString("");
+ self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (self->first == NULL) {
Py_DECREF(self);
return NULL;
}
- self->last = PyUnicode_FromString("");
+ self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (self->last == NULL) {
Py_DECREF(self);
return NULL;
wchar_t *dest;
if (slicelen <= 0)
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (step == 1) {
return PyUnicode_FromWideChar(ptr + start,
slicelen);
wchar_t *dest;
if (len <= 0)
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (step == 1) {
return PyUnicode_FromWideChar(ptr + start,
len);
static PyObject *
delta_repr(PyDateTime_Delta *self)
{
- PyObject *args = PyUnicode_FromString("");
+ PyObject *args = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (args == NULL) {
return NULL;
PyObject* joiner;
PyObject* result;
- joiner = PyUnicode_FromStringAndSize("", 0);
+ joiner = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (!joiner)
return NULL;
result = PyUnicode_Join(joiner, list);
PyObject* text = element_get_text((ElementObject*)item);
if (text == Py_None) {
Py_DECREF(item);
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
Py_XINCREF(text);
Py_DECREF(item);
return PyUnicode_FromString("...");
}
- arglist = PyUnicode_FromString("");
+ arglist = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (arglist == NULL)
goto done;
/* Pack positional arguments */
/* In case of overseek, return the empty string */
if (self->pos >= self->string_size)
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
start = self->buf + self->pos;
if (limit < 0 || limit > self->string_size - self->pos)
get_timezones_offset_zero(PyObject *self, PyObject *args)
{
PyObject *offset = PyDelta_FromDSU(0, 0, 0);
- PyObject *name = PyUnicode_FromString("");
+ PyObject *name = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (offset == NULL || name == NULL) {
Py_XDECREF(offset);
Py_XDECREF(name);
if (datalen == 0) {
ERROR_DECREF(errorcb);
- return make_tuple(PyUnicode_New(0, 0), 0);
+ return make_tuple(Py_GetConstant(Py_CONSTANT_EMPTY_STR), 0);
}
_PyUnicodeWriter_Init(&buf.writer);
Py_ssize_t rsize;
if (sizehint == 0)
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
_PyUnicodeWriter_Init(&buf.writer);
buf.excobj = NULL;
return PyErr_SetFromWindowsErr(0);
if (size == 0)
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
/* MSDN says ERROR_MORE_DATA may occur because DNS allows longer
names */
if (UCD_Check(self)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0)
- return PyUnicode_FromString(""); /* unassigned */
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR); /* unassigned */
}
if (code < 0 || code >= 0x110000)
/* If no format_spec is provided, use an empty string */
if (format_spec == NULL) {
- empty = PyUnicode_New(0, 0);
+ empty = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
format_spec = empty;
}
{
switch (PyTuple_GET_SIZE(self->args)) {
case 0:
- return PyUnicode_FromString("");
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
case 1:
return PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
default:
if (exc->object == NULL) {
/* Not properly initialized. */
- return PyUnicode_FromString("");
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
/* Get reason and encoding as strings, which they might not be if
if (exc->object == NULL) {
/* Not properly initialized. */
- return PyUnicode_FromString("");
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
/* Get reason and encoding as strings, which they might not be if
if (exc->object == NULL) {
/* Not properly initialized. */
- return PyUnicode_FromString("");
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
/* Get reason as a string, which it might not be if it's been
SubString_new_object_or_empty(SubString *str)
{
if (str->str == NULL) {
- return PyUnicode_New(0, 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
return SubString_new_object(str);
}
format_spec->start,
format_spec->end);
else
- format_spec_object = PyUnicode_New(0, 0);
+ format_spec_object = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (format_spec_object == NULL)
goto done;
assert(p->tok->fp_interactive);
// We can reach this point if the tokenizer buffers for interactive source have not been
// initialized because we failed to decode the original source with the given locale.
- return PyUnicode_FromStringAndSize("", 0);
+ return Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
Py_ssize_t relative_lineno = p->starting_lineno ? lineno - p->starting_lineno + 1 : lineno;
error_line = get_error_line_from_tokenizer_buffers(p, lineno);
}
else {
- error_line = PyUnicode_FromStringAndSize("", 0);
+ error_line = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
if (!error_line) {
goto error;
}
PyObject *str = NULL;
if (token.start == NULL || token.end == NULL) {
- str = PyUnicode_FromString("");
+ str = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
else {
str = PyUnicode_FromStringAndSize(token.start, token.end - token.start);
PyObject* line = NULL;
int line_changed = 1;
if (it->tok->tok_extra_tokens && is_trailing_token) {
- line = PyUnicode_FromString("");
+ line = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
} else {
Py_ssize_t size = it->tok->inp - line_start;
if (size >= 1 && it->tok->implicit_newline) {
else if (type == NL) {
if (it->tok->implicit_newline) {
Py_DECREF(str);
- str = PyUnicode_FromString("");
+ str = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
}
}
else {
/* This will not fail. */
- kwonly_sig = PyUnicode_FromString("");
+ kwonly_sig = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
assert(kwonly_sig != NULL);
}
_PyErr_Format(tstate, PyExc_TypeError,
wrong_exception_type(exc);
return NULL;
}
- return Py_BuildValue("(Nn)", PyUnicode_New(0, 0), end);
+ return Py_BuildValue("(Nn)", Py_GetConstant(Py_CONSTANT_EMPTY_STR), end);
}
break;
case LT_NO_LOCALE:
locale_info->decimal_point = PyUnicode_FromOrdinal('.');
- locale_info->thousands_sep = PyUnicode_New(0, 0);
+ locale_info->thousands_sep = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
if (!locale_info->decimal_point || !locale_info->thousands_sep)
return -1;
locale_info->grouping = no_grouping;
v = PyUnicode_DecodeUTF8(buffer, n, "surrogatepass");
}
else {
- v = PyUnicode_New(0, 0);
+ v = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
}
if (v == NULL)
break;
static void dump_symtable(PySTEntryObject* ste)
{
- PyObject *empty = PyUnicode_FromString("");
+ PyObject *empty = Py_GetConstant(Py_CONSTANT_EMPTY_STR);
assert(empty != NULL);
_dump_symtable(ste, empty);
Py_DECREF(empty);