Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6854e803
Commit
6854e803
authored
Jun 01, 2018
by
Eric Snow
Committed by
GitHub
Jun 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33724: Use the right format code for int64_t in subinterpreters code. (gh-7330)
parent
2e01b758
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
32 deletions
+33
-32
Modules/_xxsubinterpretersmodule.c
Modules/_xxsubinterpretersmodule.c
+33
-32
No files found.
Modules/_xxsubinterpretersmodule.c
View file @
6854e803
...
...
@@ -33,35 +33,35 @@ _get_current(void)
}
static
int64_t
_coerce_id
(
PyObject
*
id
)
_coerce_id
(
PyObject
*
orig
)
{
id
=
PyNumber_Long
(
id
);
if
(
id
==
NULL
)
{
PyObject
*
pyid
=
PyNumber_Long
(
orig
);
if
(
py
id
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_TypeError
))
{
PyErr_
SetString
(
PyExc_TypeError
,
"'id' must be a non-negative int"
);
PyErr_
Format
(
PyExc_TypeError
,
"'id' must be a non-negative int, got %R"
,
orig
);
}
else
{
PyErr_
SetString
(
PyExc_ValueError
,
"'id' must be a non-negative int"
);
PyErr_
Format
(
PyExc_ValueError
,
"'id' must be a non-negative int, got %R"
,
orig
);
}
return
-
1
;
}
int64_t
cid
=
PyLong_AsLongLong
(
id
);
Py_DECREF
(
id
);
if
(
c
id
==
-
1
&&
PyErr_Occurred
()
!=
NULL
)
{
int64_t
id
=
PyLong_AsLongLong
(
py
id
);
Py_DECREF
(
py
id
);
if
(
id
==
-
1
&&
PyErr_Occurred
()
!=
NULL
)
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
{
PyErr_
SetString
(
PyExc_ValueError
,
"'id' must be a non-negative int"
);
PyErr_
Format
(
PyExc_ValueError
,
"'id' must be a non-negative int, got %R"
,
orig
);
}
return
-
1
;
}
if
(
c
id
<
0
)
{
PyErr_
SetString
(
PyExc_ValueError
,
"'id' must be a non-negative int"
);
if
(
id
<
0
)
{
PyErr_
Format
(
PyExc_ValueError
,
"'id' must be a non-negative int, got %R"
,
orig
);
return
-
1
;
}
return
c
id
;
return
id
;
}
...
...
@@ -1000,11 +1000,11 @@ _channels_lookup(_channels *channels, int64_t id, PyThread_type_lock *pmutex)
_channelref
*
ref
=
_channelref_find
(
channels
->
head
,
id
,
NULL
);
if
(
ref
==
NULL
)
{
PyErr_Format
(
ChannelNotFoundError
,
"channel %d not found"
,
id
);
PyErr_Format
(
ChannelNotFoundError
,
"channel %
ll
d not found"
,
id
);
goto
done
;
}
if
(
ref
->
chan
==
NULL
||
!
ref
->
chan
->
open
)
{
PyErr_Format
(
ChannelClosedError
,
"channel %d closed"
,
id
);
PyErr_Format
(
ChannelClosedError
,
"channel %
ll
d closed"
,
id
);
goto
done
;
}
...
...
@@ -1064,16 +1064,16 @@ _channels_close(_channels *channels, int64_t cid, _PyChannelState **pchan,
_channelref
*
ref
=
_channelref_find
(
channels
->
head
,
cid
,
NULL
);
if
(
ref
==
NULL
)
{
PyErr_Format
(
ChannelNotFoundError
,
"channel %d not found"
,
cid
);
PyErr_Format
(
ChannelNotFoundError
,
"channel %
ll
d not found"
,
cid
);
goto
done
;
}
if
(
ref
->
chan
==
NULL
)
{
PyErr_Format
(
ChannelClosedError
,
"channel %d closed"
,
cid
);
PyErr_Format
(
ChannelClosedError
,
"channel %
ll
d closed"
,
cid
);
goto
done
;
}
else
if
(
!
force
&&
end
==
CHANNEL_SEND
&&
ref
->
chan
->
closing
!=
NULL
)
{
PyErr_Format
(
ChannelClosedError
,
"channel %d closed"
,
cid
);
PyErr_Format
(
ChannelClosedError
,
"channel %
ll
d closed"
,
cid
);
goto
done
;
}
else
{
...
...
@@ -1081,7 +1081,8 @@ _channels_close(_channels *channels, int64_t cid, _PyChannelState **pchan,
if
(
end
==
CHANNEL_SEND
&&
PyErr_ExceptionMatches
(
ChannelNotEmptyError
))
{
if
(
ref
->
chan
->
closing
!=
NULL
)
{
PyErr_Format
(
ChannelClosedError
,
"channel %d closed"
,
cid
);
PyErr_Format
(
ChannelClosedError
,
"channel %lld closed"
,
cid
);
goto
done
;
}
// Mark the channel as closing and return. The channel
...
...
@@ -1143,7 +1144,7 @@ _channels_remove(_channels *channels, int64_t id, _PyChannelState **pchan)
_channelref
*
prev
=
NULL
;
_channelref
*
ref
=
_channelref_find
(
channels
->
head
,
id
,
&
prev
);
if
(
ref
==
NULL
)
{
PyErr_Format
(
ChannelNotFoundError
,
"channel %d not found"
,
id
);
PyErr_Format
(
ChannelNotFoundError
,
"channel %
ll
d not found"
,
id
);
goto
done
;
}
...
...
@@ -1163,7 +1164,7 @@ _channels_add_id_object(_channels *channels, int64_t id)
_channelref
*
ref
=
_channelref_find
(
channels
->
head
,
id
,
NULL
);
if
(
ref
==
NULL
)
{
PyErr_Format
(
ChannelNotFoundError
,
"channel %d not found"
,
id
);
PyErr_Format
(
ChannelNotFoundError
,
"channel %
ll
d not found"
,
id
);
goto
done
;
}
ref
->
objcount
+=
1
;
...
...
@@ -1327,7 +1328,7 @@ _channel_send(_channels *channels, int64_t id, PyObject *obj)
// Past this point we are responsible for releasing the mutex.
if
(
chan
->
closing
!=
NULL
)
{
PyErr_Format
(
ChannelClosedError
,
"channel %d closed"
,
id
);
PyErr_Format
(
ChannelClosedError
,
"channel %
ll
d closed"
,
id
);
PyThread_release_lock
(
mutex
);
return
-
1
;
}
...
...
@@ -1376,7 +1377,7 @@ _channel_recv(_channels *channels, int64_t id)
PyThread_release_lock
(
mutex
);
if
(
data
==
NULL
)
{
if
(
!
PyErr_Occurred
())
{
PyErr_Format
(
ChannelEmptyError
,
"channel %d is empty"
,
id
);
PyErr_Format
(
ChannelEmptyError
,
"channel %
ll
d is empty"
,
id
);
}
return
NULL
;
}
...
...
@@ -1526,13 +1527,13 @@ channelid_repr(PyObject *self)
channelid
*
cid
=
(
channelid
*
)
self
;
const
char
*
fmt
;
if
(
cid
->
end
==
CHANNEL_SEND
)
{
fmt
=
"%s(%d, send=True)"
;
fmt
=
"%s(%
ll
d, send=True)"
;
}
else
if
(
cid
->
end
==
CHANNEL_RECV
)
{
fmt
=
"%s(%d, recv=True)"
;
fmt
=
"%s(%
ll
d, recv=True)"
;
}
else
{
fmt
=
"%s(%d)"
;
fmt
=
"%s(%
ll
d)"
;
}
return
PyUnicode_FromFormat
(
fmt
,
name
,
cid
->
id
);
}
...
...
@@ -1541,7 +1542,7 @@ static PyObject *
channelid_str
(
PyObject
*
self
)
{
channelid
*
cid
=
(
channelid
*
)
self
;
return
PyUnicode_FromFormat
(
"%d"
,
cid
->
id
);
return
PyUnicode_FromFormat
(
"%
ll
d"
,
cid
->
id
);
}
PyObject
*
...
...
@@ -2046,14 +2047,14 @@ interpid_repr(PyObject *self)
PyTypeObject
*
type
=
Py_TYPE
(
self
);
const
char
*
name
=
_PyType_Name
(
type
);
interpid
*
id
=
(
interpid
*
)
self
;
return
PyUnicode_FromFormat
(
"%s(%d)"
,
name
,
id
->
id
);
return
PyUnicode_FromFormat
(
"%s(%
ll
d)"
,
name
,
id
->
id
);
}
static
PyObject
*
interpid_str
(
PyObject
*
self
)
{
interpid
*
id
=
(
interpid
*
)
self
;
return
PyUnicode_FromFormat
(
"%d"
,
id
->
id
);
return
PyUnicode_FromFormat
(
"%
ll
d"
,
id
->
id
);
}
PyObject
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment