Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
edecf75b
Commit
edecf75b
authored
Sep 17, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python binding checks ctx argument type
parent
8cdf7532
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
pyzmq.cpp
bindings/python/pyzmq.cpp
+12
-10
No files found.
bindings/python/pyzmq.cpp
View file @
edecf75b
...
...
@@ -30,6 +30,8 @@
#pragma warning (disable:4996)
#endif
extern
PyTypeObject
context_type
;
struct
context_t
{
PyObject_HEAD
...
...
@@ -55,14 +57,14 @@ int context_init (context_t *self, PyObject *args, PyObject *kwdict)
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdict
,
"ii"
,
(
char
**
)
kwlist
,
&
app_threads
,
&
io_threads
))
{
PyErr_SetString
(
PyExc_SystemError
,
"invalid arguments"
);
return
-
1
;
// ?
return
-
1
;
}
assert
(
!
self
->
handle
);
self
->
handle
=
zmq_init
(
app_threads
,
io_threads
);
if
(
!
self
->
handle
)
{
PyErr_SetString
(
PyExc_SystemError
,
strerror
(
errno
));
return
-
1
;
// ?
return
-
1
;
}
return
0
;
...
...
@@ -79,6 +81,8 @@ void context_dealloc (context_t *self)
self
->
ob_type
->
tp_free
((
PyObject
*
)
self
);
}
extern
PyTypeObject
socket_type
;
struct
socket_t
{
PyObject_HEAD
...
...
@@ -100,18 +104,17 @@ int socket_init (socket_t *self, PyObject *args, PyObject *kwdict)
context_t
*
context
;
int
socket_type
;
static
const
char
*
kwlist
[]
=
{
"context"
,
"type"
,
NULL
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdict
,
"Oi"
,
(
char
**
)
kwlist
,
&
context
,
&
socket_type
))
{
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdict
,
"O
!
i"
,
(
char
**
)
kwlist
,
&
context
_type
,
&
context
,
&
socket_type
))
{
PyErr_SetString
(
PyExc_SystemError
,
"invalid arguments"
);
return
NULL
;
return
-
1
;
}
// TODO: Check whether 'context' is really a libpyzmq.Context object.
assert
(
!
self
->
handle
);
self
->
handle
=
zmq_socket
(
context
->
handle
,
socket_type
);
if
(
!
self
->
handle
)
{
PyErr_SetString
(
PyExc_SystemError
,
strerror
(
errno
));
return
-
1
;
// ?
return
-
1
;
}
return
0
;
...
...
@@ -157,7 +160,6 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict)
case
ZMQ_IDENTITY
:
case
ZMQ_SUBSCRIBE
:
case
ZMQ_UNSUBSCRIBE
:
rc
=
zmq_setsockopt
(
self
->
handle
,
option
,
PyString_AsString
(
optval
),
PyString_Size
(
optval
));
break
;
...
...
@@ -309,7 +311,7 @@ static PyMethodDef context_methods [] =
}
};
static
PyTypeObject
context_type
=
PyTypeObject
context_type
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
...
...
@@ -395,7 +397,7 @@ static PyMethodDef socket_methods [] =
}
};
static
PyTypeObject
socket_type
=
PyTypeObject
socket_type
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
...
...
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