mirror of https://github.com/python/cpython
Issue #8914: fix various warnings from the Clang static analyzer v254.
This commit is contained in:
parent
79da6b7075
commit
b94767ff44
|
@ -26,8 +26,6 @@ PyAPI_DATA(int) Py_UnbufferedStdioFlag;
|
||||||
PYTHONPATH and PYTHONHOME from the environment */
|
PYTHONPATH and PYTHONHOME from the environment */
|
||||||
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
|
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
|
||||||
|
|
||||||
PyAPI_FUNC(void) Py_FatalError(const char *message);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,7 +70,17 @@ PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
|
||||||
PyAPI_FUNC(void) PyErr_Clear(void);
|
PyAPI_FUNC(void) PyErr_Clear(void);
|
||||||
PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
||||||
PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
||||||
PyAPI_FUNC(void) Py_FatalError(const char *message);
|
|
||||||
|
#if defined(__clang__) || \
|
||||||
|
(defined(__GNUC__) && \
|
||||||
|
((__GNUC_MAJOR__ >= 3) || \
|
||||||
|
(__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
|
||||||
|
#define _Py_NO_RETURN __attribute__((__noreturn__))
|
||||||
|
#else
|
||||||
|
#define _Py_NO_RETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
|
||||||
|
|
||||||
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
|
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
|
||||||
#define _PyErr_OCCURRED() PyErr_Occurred()
|
#define _PyErr_OCCURRED() PyErr_Occurred()
|
||||||
|
|
|
@ -52,7 +52,7 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
||||||
{
|
{
|
||||||
CFieldObject *self;
|
CFieldObject *self;
|
||||||
PyObject *proto;
|
PyObject *proto;
|
||||||
Py_ssize_t size, align, length;
|
Py_ssize_t size, align;
|
||||||
SETFUNC setfunc = NULL;
|
SETFUNC setfunc = NULL;
|
||||||
GETFUNC getfunc = NULL;
|
GETFUNC getfunc = NULL;
|
||||||
StgDictObject *dict;
|
StgDictObject *dict;
|
||||||
|
@ -106,7 +106,6 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
||||||
}
|
}
|
||||||
|
|
||||||
size = dict->size;
|
size = dict->size;
|
||||||
length = dict->length;
|
|
||||||
proto = desc;
|
proto = desc;
|
||||||
|
|
||||||
/* Field descriptors for 'c_char * n' are be scpecial cased to
|
/* Field descriptors for 'c_char * n' are be scpecial cased to
|
||||||
|
|
|
@ -1461,7 +1461,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
|
||||||
goto Done;
|
goto Done;
|
||||||
Py_DECREF(x1);
|
Py_DECREF(x1);
|
||||||
Py_DECREF(x2);
|
Py_DECREF(x2);
|
||||||
x1 = x2 = NULL;
|
/* x1 = */ x2 = NULL;
|
||||||
|
|
||||||
/* x3 has days+seconds in seconds */
|
/* x3 has days+seconds in seconds */
|
||||||
x1 = PyNumber_Multiply(x3, us_per_second); /* us */
|
x1 = PyNumber_Multiply(x3, us_per_second); /* us */
|
||||||
|
|
|
@ -938,13 +938,11 @@ static int
|
||||||
bytesiobuf_getbuffer(bytesiobuf *obj, Py_buffer *view, int flags)
|
bytesiobuf_getbuffer(bytesiobuf *obj, Py_buffer *view, int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
void *ptr;
|
|
||||||
bytesio *b = (bytesio *) obj->source;
|
bytesio *b = (bytesio *) obj->source;
|
||||||
if (view == NULL) {
|
if (view == NULL) {
|
||||||
b->exports++;
|
b->exports++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ptr = (void *) obj;
|
|
||||||
ret = PyBuffer_FillInfo(view, (PyObject*)obj, b->buf, b->string_size,
|
ret = PyBuffer_FillInfo(view, (PyObject*)obj, b->buf, b->string_size,
|
||||||
0, flags);
|
0, flags);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
|
|
|
@ -335,7 +335,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next
|
||||||
PyObject *rval = NULL;
|
PyObject *rval = NULL;
|
||||||
Py_ssize_t len = PyUnicode_GET_SIZE(pystr);
|
Py_ssize_t len = PyUnicode_GET_SIZE(pystr);
|
||||||
Py_ssize_t begin = end - 1;
|
Py_ssize_t begin = end - 1;
|
||||||
Py_ssize_t next = begin;
|
Py_ssize_t next /* = begin */;
|
||||||
const Py_UNICODE *buf = PyUnicode_AS_UNICODE(pystr);
|
const Py_UNICODE *buf = PyUnicode_AS_UNICODE(pystr);
|
||||||
PyObject *chunks = NULL;
|
PyObject *chunks = NULL;
|
||||||
PyObject *chunk = NULL;
|
PyObject *chunk = NULL;
|
||||||
|
@ -1532,13 +1532,12 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
|
||||||
goto bail;
|
goto bail;
|
||||||
Py_CLEAR(ident);
|
Py_CLEAR(ident);
|
||||||
}
|
}
|
||||||
|
/* TODO DOES NOT RUN; dead code
|
||||||
if (s->indent != Py_None) {
|
if (s->indent != Py_None) {
|
||||||
/* TODO: DOES NOT RUN */
|
|
||||||
indent_level -= 1;
|
indent_level -= 1;
|
||||||
/*
|
|
||||||
yield '\n' + (' ' * (_indent * _current_indent_level))
|
yield '\n' + (' ' * (_indent * _current_indent_level))
|
||||||
*/
|
}*/
|
||||||
}
|
|
||||||
if (PyList_Append(rval, close_dict))
|
if (PyList_Append(rval, close_dict))
|
||||||
goto bail;
|
goto bail;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1624,13 +1623,13 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
|
||||||
goto bail;
|
goto bail;
|
||||||
Py_CLEAR(ident);
|
Py_CLEAR(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: DOES NOT RUN
|
||||||
if (s->indent != Py_None) {
|
if (s->indent != Py_None) {
|
||||||
/* TODO: DOES NOT RUN */
|
|
||||||
indent_level -= 1;
|
indent_level -= 1;
|
||||||
/*
|
|
||||||
yield '\n' + (' ' * (_indent * _current_indent_level))
|
yield '\n' + (' ' * (_indent * _current_indent_level))
|
||||||
*/
|
}*/
|
||||||
}
|
|
||||||
if (PyList_Append(rval, close_array))
|
if (PyList_Append(rval, close_array))
|
||||||
goto bail;
|
goto bail;
|
||||||
Py_DECREF(s_fast);
|
Py_DECREF(s_fast);
|
||||||
|
|
|
@ -673,7 +673,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
|
||||||
{
|
{
|
||||||
PyObject* function_result = NULL;
|
PyObject* function_result = NULL;
|
||||||
PyObject** aggregate_instance;
|
PyObject** aggregate_instance;
|
||||||
PyObject* aggregate_class;
|
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
PyGILState_STATE threadstate;
|
PyGILState_STATE threadstate;
|
||||||
|
@ -681,8 +680,6 @@ void _pysqlite_final_callback(sqlite3_context* context)
|
||||||
threadstate = PyGILState_Ensure();
|
threadstate = PyGILState_Ensure();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
aggregate_class = (PyObject*)sqlite3_user_data(context);
|
|
||||||
|
|
||||||
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
||||||
if (!*aggregate_instance) {
|
if (!*aggregate_instance) {
|
||||||
/* this branch is executed if there was an exception in the aggregate's
|
/* this branch is executed if there was an exception in the aggregate's
|
||||||
|
|
|
@ -126,11 +126,9 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
|
||||||
|
|
||||||
static void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
|
static void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* Reset the statement if the user has not closed the cursor */
|
/* Reset the statement if the user has not closed the cursor */
|
||||||
if (self->statement) {
|
if (self->statement) {
|
||||||
rc = pysqlite_statement_reset(self->statement);
|
pysqlite_statement_reset(self->statement);
|
||||||
Py_DECREF(self->statement);
|
Py_DECREF(self->statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +527,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
|
||||||
|
|
||||||
if (self->statement != NULL) {
|
if (self->statement != NULL) {
|
||||||
/* There is an active statement */
|
/* There is an active statement */
|
||||||
rc = pysqlite_statement_reset(self->statement);
|
pysqlite_statement_reset(self->statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
|
operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
|
||||||
|
@ -734,7 +732,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
rc = pysqlite_statement_reset(self->statement);
|
pysqlite_statement_reset(self->statement);
|
||||||
}
|
}
|
||||||
Py_XDECREF(parameters);
|
Py_XDECREF(parameters);
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,11 +369,9 @@ void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
|
||||||
|
|
||||||
void pysqlite_statement_dealloc(pysqlite_Statement* self)
|
void pysqlite_statement_dealloc(pysqlite_Statement* self)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (self->st) {
|
if (self->st) {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
rc = sqlite3_finalize(self->st);
|
sqlite3_finalize(self->st);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,6 @@ static PyObject *PySSL_SSLdo_handshake(PySSLSocket *self)
|
||||||
|
|
||||||
/* Actually negotiate SSL connection */
|
/* Actually negotiate SSL connection */
|
||||||
/* XXX If SSL_do_handshake() returns 0, it's also a failure. */
|
/* XXX If SSL_do_handshake() returns 0, it's also a failure. */
|
||||||
sockstate = 0;
|
|
||||||
do {
|
do {
|
||||||
PySSL_BEGIN_ALLOW_THREADS
|
PySSL_BEGIN_ALLOW_THREADS
|
||||||
ret = SSL_do_handshake(self->ssl);
|
ret = SSL_do_handshake(self->ssl);
|
||||||
|
@ -1090,7 +1089,6 @@ static PyObject *PySSL_SSLwrite(PySSLSocket *self, PyObject *args)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
err = 0;
|
|
||||||
PySSL_BEGIN_ALLOW_THREADS
|
PySSL_BEGIN_ALLOW_THREADS
|
||||||
len = SSL_write(self->ssl, buf.buf, buf.len);
|
len = SSL_write(self->ssl, buf.buf, buf.len);
|
||||||
err = SSL_get_error(self->ssl, len);
|
err = SSL_get_error(self->ssl, len);
|
||||||
|
@ -1226,7 +1224,6 @@ static PyObject *PySSL_SSLread(PySSLSocket *self, PyObject *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
err = 0;
|
|
||||||
PySSL_BEGIN_ALLOW_THREADS
|
PySSL_BEGIN_ALLOW_THREADS
|
||||||
count = SSL_read(self->ssl, mem, len);
|
count = SSL_read(self->ssl, mem, len);
|
||||||
err = SSL_get_error(self->ssl, count);
|
err = SSL_get_error(self->ssl, count);
|
||||||
|
|
|
@ -53,8 +53,9 @@ acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
|
||||||
_PyTime_timeval curtime;
|
_PyTime_timeval curtime;
|
||||||
_PyTime_timeval endtime;
|
_PyTime_timeval endtime;
|
||||||
|
|
||||||
if (microseconds > 0) {
|
|
||||||
_PyTime_gettimeofday(&endtime);
|
_PyTime_gettimeofday(&endtime);
|
||||||
|
if (microseconds > 0) {
|
||||||
endtime.tv_sec += microseconds / (1000 * 1000);
|
endtime.tv_sec += microseconds / (1000 * 1000);
|
||||||
endtime.tv_usec += microseconds % (1000 * 1000);
|
endtime.tv_usec += microseconds % (1000 * 1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2005,7 +2005,7 @@ static int
|
||||||
PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
|
PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
|
||||||
PyObject *self, *func, *arg, *res;
|
PyObject *func, *arg, *res;
|
||||||
int i, rv;
|
int i, rv;
|
||||||
Tcl_Obj *obj_res;
|
Tcl_Obj *obj_res;
|
||||||
|
|
||||||
|
@ -2014,7 +2014,6 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
|
||||||
/* TBD: no error checking here since we know, via the
|
/* TBD: no error checking here since we know, via the
|
||||||
* Tkapp_CreateCommand() that the client data is a two-tuple
|
* Tkapp_CreateCommand() that the client data is a two-tuple
|
||||||
*/
|
*/
|
||||||
self = data->self;
|
|
||||||
func = data->func;
|
func = data->func;
|
||||||
|
|
||||||
/* Create argument list (argv1, ..., argvN) */
|
/* Create argument list (argv1, ..., argvN) */
|
||||||
|
|
|
@ -876,7 +876,6 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n)
|
||||||
if (Py_SIZE(self) > 0) {
|
if (Py_SIZE(self) > 0) {
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n = 0;
|
n = 0;
|
||||||
items = self->ob_item;
|
|
||||||
if ((self->ob_descr->itemsize != 0) &&
|
if ((self->ob_descr->itemsize != 0) &&
|
||||||
(Py_SIZE(self) > PY_SSIZE_T_MAX / self->ob_descr->itemsize)) {
|
(Py_SIZE(self) > PY_SSIZE_T_MAX / self->ob_descr->itemsize)) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
|
@ -513,7 +513,6 @@ audioop_findfit(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
best_result = result;
|
best_result = result;
|
||||||
best_j = 0;
|
best_j = 0;
|
||||||
j = 0;
|
|
||||||
|
|
||||||
for ( j=1; j<=len1-len2; j++) {
|
for ( j=1; j<=len1-len2; j++) {
|
||||||
aj_m1 = (double)cp1[j-1];
|
aj_m1 = (double)cp1[j-1];
|
||||||
|
@ -599,7 +598,6 @@ audioop_findmax(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
best_result = result;
|
best_result = result;
|
||||||
best_j = 0;
|
best_j = 0;
|
||||||
j = 0;
|
|
||||||
|
|
||||||
for ( j=1; j<=len1-len2; j++) {
|
for ( j=1; j<=len1-len2; j++) {
|
||||||
aj_m1 = (double)cp1[j-1];
|
aj_m1 = (double)cp1[j-1];
|
||||||
|
@ -1433,7 +1431,6 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
|
||||||
if ( state == Py_None ) {
|
if ( state == Py_None ) {
|
||||||
/* First time, it seems. Set defaults */
|
/* First time, it seems. Set defaults */
|
||||||
valpred = 0;
|
valpred = 0;
|
||||||
step = 7;
|
|
||||||
index = 0;
|
index = 0;
|
||||||
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
|
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1534,7 +1531,6 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
|
||||||
if ( state == Py_None ) {
|
if ( state == Py_None ) {
|
||||||
/* First time, it seems. Set defaults */
|
/* First time, it seems. Set defaults */
|
||||||
valpred = 0;
|
valpred = 0;
|
||||||
step = 7;
|
|
||||||
index = 0;
|
index = 0;
|
||||||
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
|
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -123,7 +123,7 @@ struct iso2022_config {
|
||||||
|
|
||||||
CODEC_INIT(iso2022)
|
CODEC_INIT(iso2022)
|
||||||
{
|
{
|
||||||
const struct iso2022_designation *desig = CONFIG_DESIGNATIONS;
|
const struct iso2022_designation *desig;
|
||||||
for (desig = CONFIG_DESIGNATIONS; desig->mark; desig++)
|
for (desig = CONFIG_DESIGNATIONS; desig->mark; desig++)
|
||||||
if (desig->initializer != NULL && desig->initializer() != 0)
|
if (desig->initializer != NULL && desig->initializer() != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -483,6 +483,7 @@ multibytecodec_encode(MultibyteCodec *codec,
|
||||||
return PyBytes_FromStringAndSize(NULL, 0);
|
return PyBytes_FromStringAndSize(NULL, 0);
|
||||||
|
|
||||||
buf.excobj = NULL;
|
buf.excobj = NULL;
|
||||||
|
buf.outobj = NULL;
|
||||||
buf.inbuf = buf.inbuf_top = *data;
|
buf.inbuf = buf.inbuf_top = *data;
|
||||||
buf.inbuf_end = buf.inbuf_top + datalen;
|
buf.inbuf_end = buf.inbuf_top + datalen;
|
||||||
|
|
||||||
|
|
|
@ -577,7 +577,6 @@ Py_Main(int argc, wchar_t **argv)
|
||||||
if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') {
|
if ((p = Py_GETENV("PYTHONEXECUTABLE")) && *p != '\0') {
|
||||||
wchar_t* buffer;
|
wchar_t* buffer;
|
||||||
size_t len = strlen(p);
|
size_t len = strlen(p);
|
||||||
size_t r;
|
|
||||||
|
|
||||||
buffer = malloc(len * sizeof(wchar_t));
|
buffer = malloc(len * sizeof(wchar_t));
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
|
@ -585,7 +584,7 @@ Py_Main(int argc, wchar_t **argv)
|
||||||
"not enough memory to copy PYTHONEXECUTABLE");
|
"not enough memory to copy PYTHONEXECUTABLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
r = mbstowcs(buffer, p, len);
|
mbstowcs(buffer, p, len);
|
||||||
Py_SetProgramName(buffer);
|
Py_SetProgramName(buffer);
|
||||||
/* buffer is now handed off - do not free */
|
/* buffer is now handed off - do not free */
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3407,7 +3407,7 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
|
||||||
goto finally;
|
goto finally;
|
||||||
af = sa->sa_family;
|
af = sa->sa_family;
|
||||||
ap = NULL;
|
ap = NULL;
|
||||||
al = 0;
|
/* al = 0; */
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
ap = (char *)&((struct sockaddr_in *)sa)->sin_addr;
|
ap = (char *)&((struct sockaddr_in *)sa)->sin_addr;
|
||||||
|
|
|
@ -2439,7 +2439,7 @@ If the argument is omitted, strip trailing ASCII whitespace.");
|
||||||
static PyObject *
|
static PyObject *
|
||||||
bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
|
bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
Py_ssize_t left, right, mysize, argsize;
|
Py_ssize_t right, mysize, argsize;
|
||||||
void *myptr, *argptr;
|
void *myptr, *argptr;
|
||||||
PyObject *arg = Py_None;
|
PyObject *arg = Py_None;
|
||||||
Py_buffer varg;
|
Py_buffer varg;
|
||||||
|
@ -2457,11 +2457,10 @@ bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
myptr = self->ob_bytes;
|
myptr = self->ob_bytes;
|
||||||
mysize = Py_SIZE(self);
|
mysize = Py_SIZE(self);
|
||||||
left = 0;
|
|
||||||
right = rstrip_helper(myptr, mysize, argptr, argsize);
|
right = rstrip_helper(myptr, mysize, argptr, argsize);
|
||||||
if (arg != Py_None)
|
if (arg != Py_None)
|
||||||
PyBuffer_Release(&varg);
|
PyBuffer_Release(&varg);
|
||||||
return PyByteArray_FromStringAndSize(self->ob_bytes + left, right - left);
|
return PyByteArray_FromStringAndSize(self->ob_bytes, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(decode_doc,
|
PyDoc_STRVAR(decode_doc,
|
||||||
|
|
|
@ -297,8 +297,8 @@ Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj)
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
if (c == '\n') break;
|
if (c == '\n') break;
|
||||||
}
|
}
|
||||||
if ( c == EOF && skipnextlf )
|
/* if ( c == EOF && skipnextlf )
|
||||||
newlinetypes |= NEWLINE_CR;
|
newlinetypes |= NEWLINE_CR; */
|
||||||
FUNLOCKFILE(stream);
|
FUNLOCKFILE(stream);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if ( skipnextlf ) {
|
if ( skipnextlf ) {
|
||||||
|
|
|
@ -197,7 +197,6 @@ PyFloat_FromString(PyObject *v)
|
||||||
Py_DECREF(s_buffer);
|
Py_DECREF(s_buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
last = s + len;
|
|
||||||
}
|
}
|
||||||
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
else if (PyObject_AsCharBuffer(v, &s, &len)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
@ -2246,7 +2245,7 @@ _PyFloat_Pack8(double x, unsigned char *p, int le)
|
||||||
|
|
||||||
/* Eighth byte */
|
/* Eighth byte */
|
||||||
*p = flo & 0xFF;
|
*p = flo & 0xFF;
|
||||||
p += incr;
|
/* p += incr; */
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1775,7 +1775,6 @@ _PyObject_DebugMallocStats(void)
|
||||||
* will be living in full pools -- would be a shame to miss them.
|
* will be living in full pools -- would be a shame to miss them.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < maxarenas; ++i) {
|
for (i = 0; i < maxarenas; ++i) {
|
||||||
uint poolsinarena;
|
|
||||||
uint j;
|
uint j;
|
||||||
uptr base = arenas[i].address;
|
uptr base = arenas[i].address;
|
||||||
|
|
||||||
|
@ -1784,7 +1783,6 @@ _PyObject_DebugMallocStats(void)
|
||||||
continue;
|
continue;
|
||||||
narenas += 1;
|
narenas += 1;
|
||||||
|
|
||||||
poolsinarena = arenas[i].ntotalpools;
|
|
||||||
numfreepools += arenas[i].nfreepools;
|
numfreepools += arenas[i].nfreepools;
|
||||||
|
|
||||||
/* round up to pool alignment */
|
/* round up to pool alignment */
|
||||||
|
|
|
@ -86,7 +86,7 @@ PyTuple_New(register Py_ssize_t size)
|
||||||
{
|
{
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
nbytes += sizeof(PyTupleObject) - sizeof(PyObject *);
|
/* nbytes += sizeof(PyTupleObject) - sizeof(PyObject *); */
|
||||||
|
|
||||||
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
||||||
if (op == NULL)
|
if (op == NULL)
|
||||||
|
|
|
@ -902,7 +902,7 @@ subtype_dealloc(PyObject *self)
|
||||||
|
|
||||||
/* Find the nearest base with a different tp_dealloc */
|
/* Find the nearest base with a different tp_dealloc */
|
||||||
base = type;
|
base = type;
|
||||||
while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
|
while ((/*basedealloc =*/ base->tp_dealloc) == subtype_dealloc) {
|
||||||
base = base->tp_base;
|
base = base->tp_base;
|
||||||
assert(base);
|
assert(base);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5418,7 +5418,6 @@ PyUnicode_BuildEncodingMap(PyObject* string)
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
key = value = NULL;
|
|
||||||
key = PyLong_FromLong(decode[i]);
|
key = PyLong_FromLong(decode[i]);
|
||||||
value = PyLong_FromLong(i);
|
value = PyLong_FromLong(i);
|
||||||
if (!key || !value)
|
if (!key || !value)
|
||||||
|
@ -6935,7 +6934,7 @@ PyObject *replace(PyUnicodeObject *self,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Py_ssize_t n, i, j, e;
|
Py_ssize_t n, i, j;
|
||||||
Py_ssize_t product, new_size, delta;
|
Py_ssize_t product, new_size, delta;
|
||||||
Py_UNICODE *p;
|
Py_UNICODE *p;
|
||||||
|
|
||||||
|
@ -6967,7 +6966,6 @@ PyObject *replace(PyUnicodeObject *self,
|
||||||
return NULL;
|
return NULL;
|
||||||
i = 0;
|
i = 0;
|
||||||
p = u->str;
|
p = u->str;
|
||||||
e = self->length - str1->length;
|
|
||||||
if (str1->length > 0) {
|
if (str1->length > 0) {
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
/* look for next match */
|
/* look for next match */
|
||||||
|
|
|
@ -168,13 +168,20 @@ weakref_repr(PyWeakReference *self)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
else if (PyUnicode_Check(nameobj))
|
else if (PyUnicode_Check(nameobj))
|
||||||
name = _PyUnicode_AsString(nameobj);
|
name = _PyUnicode_AsString(nameobj);
|
||||||
|
if (name)
|
||||||
PyOS_snprintf(buffer, sizeof(buffer),
|
PyOS_snprintf(buffer, sizeof(buffer),
|
||||||
name ? "<weakref at %p; to '%.50s' at %p (%s)>"
|
"<weakref at %p; to '%.50s' at %p (%s)>",
|
||||||
: "<weakref at %p; to '%.50s' at %p>",
|
|
||||||
self,
|
self,
|
||||||
Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
|
Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
|
||||||
PyWeakref_GET_OBJECT(self),
|
PyWeakref_GET_OBJECT(self),
|
||||||
name);
|
name);
|
||||||
|
else
|
||||||
|
PyOS_snprintf(buffer, sizeof(buffer),
|
||||||
|
"<weakref at %p; to '%.50s' at %p>",
|
||||||
|
self,
|
||||||
|
Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
|
||||||
|
PyWeakref_GET_OBJECT(self));
|
||||||
|
|
||||||
Py_XDECREF(nameobj);
|
Py_XDECREF(nameobj);
|
||||||
}
|
}
|
||||||
return PyUnicode_FromString(buffer);
|
return PyUnicode_FromString(buffer);
|
||||||
|
|
|
@ -127,7 +127,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
|
||||||
{
|
{
|
||||||
parser_state *ps;
|
parser_state *ps;
|
||||||
node *n;
|
node *n;
|
||||||
int started = 0, handling_import = 0, handling_with = 0;
|
int started = 0;
|
||||||
|
|
||||||
if ((ps = PyParser_New(g, start)) == NULL) {
|
if ((ps = PyParser_New(g, start)) == NULL) {
|
||||||
fprintf(stderr, "no mem for new parser\n");
|
fprintf(stderr, "no mem for new parser\n");
|
||||||
|
@ -154,7 +154,6 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
|
||||||
}
|
}
|
||||||
if (type == ENDMARKER && started) {
|
if (type == ENDMARKER && started) {
|
||||||
type = NEWLINE; /* Add an extra newline */
|
type = NEWLINE; /* Add an extra newline */
|
||||||
handling_with = handling_import = 0;
|
|
||||||
started = 0;
|
started = 0;
|
||||||
/* Add the right number of dedent tokens,
|
/* Add the right number of dedent tokens,
|
||||||
except if a certain flag is given --
|
except if a certain flag is given --
|
||||||
|
|
|
@ -29,6 +29,8 @@ int Py_IgnoreEnvironmentFlag;
|
||||||
/* Forward */
|
/* Forward */
|
||||||
grammar *getgrammar(char *filename);
|
grammar *getgrammar(char *filename);
|
||||||
|
|
||||||
|
void Py_Exit(int) _Py_NO_RETURN;
|
||||||
|
|
||||||
void
|
void
|
||||||
Py_Exit(int sts)
|
Py_Exit(int sts)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3231,7 +3231,6 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
|
||||||
const char *end;
|
const char *end;
|
||||||
|
|
||||||
if (encoding == NULL) {
|
if (encoding == NULL) {
|
||||||
buf = (char *)s;
|
|
||||||
u = NULL;
|
u = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* check for integer overflow */
|
/* check for integer overflow */
|
||||||
|
|
|
@ -37,7 +37,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
PyObject *func, *name, *bases, *mkw, *meta, *prep, *ns, *cell;
|
PyObject *func, *name, *bases, *mkw, *meta, *prep, *ns, *cell;
|
||||||
PyObject *cls = NULL;
|
PyObject *cls = NULL;
|
||||||
Py_ssize_t nargs, nbases;
|
Py_ssize_t nargs;
|
||||||
|
|
||||||
assert(args != NULL);
|
assert(args != NULL);
|
||||||
if (!PyTuple_Check(args)) {
|
if (!PyTuple_Check(args)) {
|
||||||
|
@ -61,7 +61,6 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
bases = PyTuple_GetSlice(args, 2, nargs);
|
bases = PyTuple_GetSlice(args, 2, nargs);
|
||||||
if (bases == NULL)
|
if (bases == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
nbases = nargs - 2;
|
|
||||||
|
|
||||||
if (kwds == NULL) {
|
if (kwds == NULL) {
|
||||||
meta = NULL;
|
meta = NULL;
|
||||||
|
@ -766,7 +765,6 @@ builtin_exec(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
PyObject *prog, *globals = Py_None, *locals = Py_None;
|
PyObject *prog, *globals = Py_None, *locals = Py_None;
|
||||||
int plain = 0;
|
|
||||||
|
|
||||||
if (!PyArg_UnpackTuple(args, "exec", 1, 3, &prog, &globals, &locals))
|
if (!PyArg_UnpackTuple(args, "exec", 1, 3, &prog, &globals, &locals))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -775,7 +773,6 @@ builtin_exec(PyObject *self, PyObject *args)
|
||||||
globals = PyEval_GetGlobals();
|
globals = PyEval_GetGlobals();
|
||||||
if (locals == Py_None) {
|
if (locals == Py_None) {
|
||||||
locals = PyEval_GetLocals();
|
locals = PyEval_GetLocals();
|
||||||
plain = 1;
|
|
||||||
}
|
}
|
||||||
if (!globals || !locals) {
|
if (!globals || !locals) {
|
||||||
PyErr_SetString(PyExc_SystemError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
|
|
|
@ -2690,7 +2690,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
||||||
Py_DECREF(*pfunc);
|
Py_DECREF(*pfunc);
|
||||||
*pfunc = self;
|
*pfunc = self;
|
||||||
na++;
|
na++;
|
||||||
n++;
|
/* n++; */
|
||||||
} else
|
} else
|
||||||
Py_INCREF(func);
|
Py_INCREF(func);
|
||||||
sp = stack_pointer;
|
sp = stack_pointer;
|
||||||
|
@ -3026,7 +3026,7 @@ fast_yield:
|
||||||
PyTrace_RETURN, retval)) {
|
PyTrace_RETURN, retval)) {
|
||||||
Py_XDECREF(retval);
|
Py_XDECREF(retval);
|
||||||
retval = NULL;
|
retval = NULL;
|
||||||
why = WHY_EXCEPTION;
|
/* why = WHY_EXCEPTION; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2055,7 +2055,7 @@ _Py_dg_strtod(const char *s00, char **se)
|
||||||
+ Exp_msk1
|
+ Exp_msk1
|
||||||
;
|
;
|
||||||
word1(&rv) = 0;
|
word1(&rv) = 0;
|
||||||
dsign = 0;
|
/* dsign = 0; */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2092,7 +2092,7 @@ _Py_dg_strtod(const char *s00, char **se)
|
||||||
goto undfl;
|
goto undfl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dsign = 1 - dsign;
|
/* dsign = 1 - dsign; */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((aadj = ratio(delta, bs)) <= 2.) {
|
if ((aadj = ratio(delta, bs)) <= 2.) {
|
||||||
|
|
|
@ -966,9 +966,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
case 'u': /* raw unicode buffer (Py_UNICODE *) */
|
case 'u': /* raw unicode buffer (Py_UNICODE *) */
|
||||||
case 'Z': /* raw unicode buffer or None */
|
case 'Z': /* raw unicode buffer or None */
|
||||||
{
|
{
|
||||||
|
Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
|
||||||
|
|
||||||
if (*format == '#') { /* any buffer-like object */
|
if (*format == '#') { /* any buffer-like object */
|
||||||
/* "s#" or "Z#" */
|
/* "s#" or "Z#" */
|
||||||
Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
|
|
||||||
FETCH_SIZE;
|
FETCH_SIZE;
|
||||||
|
|
||||||
if (c == 'Z' && arg == Py_None) {
|
if (c == 'Z' && arg == Py_None) {
|
||||||
|
@ -984,8 +985,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
format++;
|
format++;
|
||||||
} else {
|
} else {
|
||||||
/* "s" or "Z" */
|
/* "s" or "Z" */
|
||||||
Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
|
|
||||||
|
|
||||||
if (c == 'Z' && arg == Py_None)
|
if (c == 'Z' && arg == Py_None)
|
||||||
*p = NULL;
|
*p = NULL;
|
||||||
else if (PyUnicode_Check(arg)) {
|
else if (PyUnicode_Check(arg)) {
|
||||||
|
|
|
@ -954,7 +954,7 @@ format_float_short(double d, char format_code,
|
||||||
/* shouldn't get here: Gay's code should always return
|
/* shouldn't get here: Gay's code should always return
|
||||||
something starting with a digit, an 'I', or 'N' */
|
something starting with a digit, an 'I', or 'N' */
|
||||||
strncpy(p, "ERR", 3);
|
strncpy(p, "ERR", 3);
|
||||||
p += 3;
|
/* p += 3; */
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
|
@ -1176,7 +1176,6 @@ PySys_AddXOption(const wchar_t *s)
|
||||||
PyObject *opts;
|
PyObject *opts;
|
||||||
PyObject *name = NULL, *value = NULL;
|
PyObject *name = NULL, *value = NULL;
|
||||||
const wchar_t *name_end;
|
const wchar_t *name_end;
|
||||||
int r;
|
|
||||||
|
|
||||||
opts = get_xoptions();
|
opts = get_xoptions();
|
||||||
if (opts == NULL)
|
if (opts == NULL)
|
||||||
|
@ -1194,7 +1193,7 @@ PySys_AddXOption(const wchar_t *s)
|
||||||
}
|
}
|
||||||
if (name == NULL || value == NULL)
|
if (name == NULL || value == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
r = PyDict_SetItem(opts, name, value);
|
PyDict_SetItem(opts, name, value);
|
||||||
Py_DECREF(name);
|
Py_DECREF(name);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue