8000 Wrap long lines. · python/cpython@9065001 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit 9065001

Browse files
Wrap long lines.
1 parent ba94571 commit 9065001

File tree

1 file changed

+45
-26
lines changed

1 file changed

+45
-26
lines changed

Modules/_xxsubinterpretersmodule.c

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,29 @@ _coerce_id(PyObject *id)
2222
id = PyNumber_Long(id);
2323
if (id == NULL) {
2424
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
25-
PyErr_SetString(PyExc_TypeError, "'id' must be a non-negative int");
25+
PyErr_SetString(PyExc_TypeError,
26+
"'id' must be a non-negative int");
2627
}
2728
else {
28-
PyErr_SetString(PyExc_ValueError, "'id' must be a non-negative int");
29+
PyErr_SetString(PyExc_ValueError,
30+
"'id' must be a non-negative int");
2931
}
3032
return -1;
3133
}
3234
long long cid = PyLong_AsLongLong(id);
3335
if (cid == -1 && PyErr_Occurred() != NULL) {
34-
PyErr_SetString(PyExc_ValueError, "'id' must be a non-negative int");
36+
PyErr_SetString(PyExc_ValueError,
37+
"'id' must be a non-negative int");
3538
return -1;
3639
}
3740
if (cid < 0) {
38-
PyErr_SetString(PyExc_ValueError, "'id' must be a non-negative int");
41+
PyErr_SetString(PyExc_ValueError,
42+
"'id' must be a non-negative int");
3943
return -1;
4044
}
4145
if (cid > INT64_MAX) {
42-
PyErr_SetString(PyExc_ValueError, "'id' too large (must be 64-bit int)");
46+
PyErr_SetString(PyExc_ValueError,
47+
"'id' too large (must be 64-bit int)");
4348
return -1;
4449
}
4550
return cid;
@@ -212,8 +217,8 @@ channel_exceptions_init(PyObject *ns)
212217
}
213218

214219
// An operation tried to use a channel that doesn't exist.
215-
ChannelNotFoundError = PyErr_NewException("_xxsubinterpreters.ChannelNotFoundError",
216-
ChannelError, NULL);
220+
ChannelNotFoundError = PyErr_NewException(
221+
"_xxsubinterpreters.ChannelNotFoundError", ChannelError, NULL);
217222
if (ChannelNotFoundError == NULL) {
218223
return -1;
219224
}
@@ -222,8 +227,8 @@ channel_exceptions_init(PyObject *ns)
222227
}
223228

224229
// An operation tried to use a closed channel.
225-
ChannelClosedError = PyErr_NewException("_xxsubinterpreters.ChannelClosedError",
226-
ChannelError, NULL);
230+
ChannelClosedError = PyErr_NewException(
231+
"_xxsubinterpreters.ChannelClosedError", ChannelError, NULL);
227232
if (ChannelClosedError == NULL) {
228233
return -1;
229234
}
@@ -232,8 +237,8 @@ channel_exceptions_init(PyObject *ns)
232237
}
233238

234239
// An operation tried to pop from an empty channel.
235-
ChannelEmptyError = PyErr_NewException("_xxsubinterpreters.ChannelEmptyError",
236-
ChannelError, NULL);
240+
ChannelEmptyError = PyErr_NewException(
241+
"_xxsubinterpreters.ChannelEmptyError", ChannelError, NULL);
237242
if (ChannelEmptyError == NULL) {
238243
return -1;
239244
}
@@ -333,7 +338,8 @@ _channel_new(void)
333338
chan->mutex = PyThread_allocate_lock();
334339
if (chan->mutex == NULL) {
335340
PyMem_Free(chan);
336-
PyErr_SetString(ChannelError, "can't initialize mutex for new channel");
341+
PyErr_SetString(ChannelError,
342+
"can't initialize mutex for new channel");
337343
return NULL;
338344
}
339345

@@ -352,7 +358,8 @@ _channel_new(void)
352358
}
353359

354360
static _channelend *
355-
_channel_add_end(_PyChannelState *chan, _channelend *prev, int64_t interp, int send)
361+
_channel_add_end(_PyChannelState *chan, _channelend *prev, int64_t interp,
362+
int send)
356363
{
357364
_channelend *end = _channelend_new(interp);
358365
if (end == NULL) {
@@ -388,7 +395,8 @@ _channel_associate_end(_PyChannelState *chan, int64_t interp, int send)
388395
}
389396

390397
_channelend *prev;
391-
_channelend *end = _channelend_find(send ? chan->send : chan->recv, interp, &prev);
398+
_channelend *end = _channelend_find(send ? chan->send : chan->recv,
399+
interp, &prev);
392400
if (end != NULL) {
393401
if (!end->open) {
394402
PyErr_SetString(ChannelClosedError, "channel already closed");
@@ -494,7 +502,8 @@ _channel_close_all(_PyChannelState *chan)
494502
}
495503

496504
static int
497-
_channel_add(_PyChannelState *chan, int64_t interp, _PyCrossInterpreterData *data)
505+
_channel_add(_PyChannelState *chan, int64_t interp,
506+
_PyCrossInterpreterData *data)
498507
{
499508
int res = -1;
500509

@@ -632,7 +641,8 @@ _channels_init(_channels *channels)
632641
channels->mutex = PyThread_allocate_lock();
633642
if (channels->mutex == NULL) {
634643
PyMem_Free(channels);
635-
PyErr_SetString(ChannelError, "can't initialize mutex for channel management");
644+
PyErr_SetString(ChannelError,
645+
"can't initialize mutex for channel management");
636646
return -1;
637647
}
638648
}
@@ -752,7 +762,8 @@ _channels_close(_channels *channels, int64_t cid, _PyChannelState **pchan)
752762
}
753763

754764
static void
755-
_channels_remove_ref(_channels *channels, _channelref *ref, _channelref *prev, _PyChannelState **pchan)
765+
_channels_remove_ref(_channels *channels, _channelref *ref, _channelref *prev,
766+
_PyChannelState **pchan)
756767
{
757768
if (ref == channels->head) {
758769
channels->head = ref->next;
@@ -906,7 +917,7 @@ _channel_send(_channels *channels, int64_t id, PyObject *obj)
906917
// Past this point we are responsible for releasing the mutex.
907918

908919
// Convert the object to cross-interpreter data.
909-
_PyCrossInterpreterData *data = PyMem_Malloc(sizeof(_PyCrossInterpreterData));
920+
_PyCrossInterpreterData *data = PyMem_NEW(_PyCrossInterpreterData, 1);
910921
if (data == NULL) {
911922
PyThread_release_lock(mutex);
912923
return -1;
@@ -1005,7 +1016,8 @@ typedef struct channelid {
10051016
} channelid;
10061017

10071018
static channelid *
1008-
newchannelid(PyTypeObject *cls, int64_t cid, int end, _channels *channels, int force)
1019+
newchannelid(PyTypeObject *cls, int64_t cid, int end, _channels *channels,
1020+
int force)
10091021
{
10101022
channelid *self = PyObject_New(channelid, cls);
10111023
if (self == NULL) {
@@ -1038,7 +1050,8 @@ channelid_new(PyTypeObject *cls, PyObject *args, PyObject *kwds)
10381050
int send = -1;
10391051
int recv = -1;
10401052
int force = 0;
1041-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|$ppp:ChannelID.__init__", kwlist,
1053+
if (!PyArg_ParseTupleAndKeywords(args, kwds,
1054+
"O|$ppp:ChannelID.__init__", kwlist,
10421055
&id, &send, &recv, &force))
10431056
return NULL;
10441057

@@ -1056,7 +1069,8 @@ channelid_new(PyTypeObject *cls, PyObject *args, PyObject *kwds)
10561069

10571070
// Handle "send" and "recv".
10581071
if (send == 0 && recv == 0) {
1059-
PyErr_SetString(PyExc_ValueError, "'send' and 'recv' cannot both be False");
1072+
PyErr_SetString(PyExc_ValueError,
1073+
"'send' and 'recv' cannot both be False");
10601074
return NULL;
10611075
}
10621076
int end = 0;
@@ -1205,7 +1219,8 @@ static PyObject *
12051219
_channelid_from_xid(_PyCrossInterpreterData *data)
12061220
{
12071221
struct _channelid_xid *xid = (struct _channelid_xid *)data->data;
1208-
return (PyObject *)newchannelid(&ChannelIDtype, xid->id, xid->end, _global_channels(), 0);
1222+
return (PyObject *)newchannelid(&ChannelIDtype, xid->id, xid->end,
1223+
_global_channels(), 0);
12091224
}
12101225

12111226
static int
@@ -1231,7 +1246,8 @@ channelid_end(PyObject *self, void *end)
12311246
int force = 1;
12321247
channelid *cid = (channelid *)self;
12331248
if (end != NULL) {
1234-
return (PyObject *)newchannelid(Py_TYPE(self), cid->id, *(int *)end, cid->channels, force);
1249+
return (PyObject *)newchannelid(Py_TYPE(self), cid->id, *(int *)end,
1250+
cid->channels, force);
12351251
}
12361252

12371253
if (cid->end == CHANNEL_SEND) {
@@ -1736,7 +1752,8 @@ channel_create(PyObject *self)
17361752
if (cid < 0) {
17371753
return NULL;
17381754
}
1739-
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, cid, 0, &_globals.channels, 0);
1755+
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, cid, 0,
1756+
&_globals.channels, 0);
17401757
if (id == NULL) {
17411758
if (_channel_destroy(&_globals.channels, cid) != 0) {
17421759
// XXX issue a warning?
@@ -1793,7 +1810,8 @@ channel_list_all(PyObject *self)
17931810
return NULL;
17941811
}
17951812
for (int64_t i=0; i < count; cids++, i++) {
1796-
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, *cids, 0, &_globals.channels, 0);
1813+
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, *cids, 0,
1814+
&_globals.channels, 0);
17971815
if (id == NULL) {
17981816
Py_DECREF(ids);
17991817
ids = NULL;
@@ -1886,7 +1904,8 @@ channel_drop_interpreter(PyObject *self, PyObject *args, PyObject *kwds)
18861904
PyObject *id;
18871905
int send = -1;
18881906
int recv = -1;
1889-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|$pp:channel_drop_interpreter", kwlist,
1907+
if (!PyArg_ParseTupleAndKeywords(args, kwds,
1908+
"O|$pp:channel_drop_interpreter", kwlist,
18901909
&id, &send, &recv))
18911910
return NULL;
18921911

0 commit comments

Comments
 (0)
0