These functions raise TypeError when expecting a string parameter and are called with a non-string parameter.
str
and types.StringType
in the Python layer.
.
PyObject *o) |
PyObject *o) |
const char *v) |
const char *v, Py_ssize_t len) |
const char *format, ...) |
Format Characters | Type | Comment |
---|---|---|
%% | n/a | The literal % character. |
%c | int | A single character, represented as an C int. |
%d | int | Exactly equivalent to printf("%d") . |
%u | unsigned int | Exactly equivalent to printf("%u") . |
%ld | long | Exactly equivalent to printf("%ld") . |
%lu | unsigned long | Exactly equivalent to printf("%lu") . |
%zd | Py_ssize_t | Exactly equivalent to printf("%zd") . |
%zu | size_t | Exactly equivalent to printf("%zu") . |
%i | int | Exactly equivalent to printf("%i") . |
%x | int | Exactly equivalent to printf("%x") . |
%s | char* | A null-terminated C character array. |
%p | void* | The hex representation of a C pointer.
Mostly equivalent to printf("%p") except that it is
guaranteed to start with the literal 0x regardless of
what the platform's printf yields. |
An unrecognized format character causes all the rest of the format string to be copied as-is to the result string, and any extra arguments discarded.
const char *format, va_list vargs) |
PyObject *string) |
PyObject *string) |
PyObject *string) |
PyString_FromStringAndSize(NULL, size)
.
It must not be deallocated. If string is a Unicode object,
this function computes the default encoding of string and
operates on that. If string is not a string object at all,
PyString_AsString() returns NULL and raises
TypeError.
PyObject *string) |
PyObject *obj, char **buffer, Py_ssize_t *length) |
The function accepts both string and Unicode objects as input. For
Unicode objects it returns the default encoded version of the
object. If length is NULL, the resulting buffer may not
contain NUL characters; if it does, the function returns -1
and a TypeError is raised.
The buffer refers to an internal string buffer of obj, not a
copy. The data must not be modified in any way, unless the string
was just created using PyString_FromStringAndSize(NULL,
size)
. It must not be deallocated. If string is a
Unicode object, this function computes the default encoding of
string and operates on that. If string is not a string
object at all, PyString_AsStringAndSize() returns
-1
and raises TypeError.
PyObject **string, PyObject *newpart) |
PyObject **string, PyObject *newpart) |
PyObject **string, Py_ssize_t newsize) |
0
is returned; the address in
*string may differ from its input value. If the
reallocation fails, the original string object at *string is
deallocated, *string is set to NULL, a memory exception is set,
and -1
is returned.
PyObject *format, PyObject *args) |
format % args
. The args
argument must be a tuple.
PyObject **string) |
const char *v) |
const char *s, Py_ssize_t size, const char *encoding, const char *errors) |
PyObject *str, const char *encoding, const char *errors) |
const char *s, Py_ssize_t size, const char *encoding, const char *errors) |
PyObject *str, const char *encoding, const char *errors) |
See About this document... for information on suggesting changes.