Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
zope-container
Commits
54a07ac6
Commit
54a07ac6
authored
Feb 15, 2013
by
Albertas Agejevas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make _zope_container_contained.c compile under Py3.
parent
6d2ccdf4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
+27
-17
src/zope/container/_zope_container_contained.c
src/zope/container/_zope_container_contained.c
+27
-17
No files found.
src/zope/container/_zope_container_contained.c
View file @
54a07ac6
...
...
@@ -74,6 +74,12 @@ typedef struct {
/* Incude the proxy C source */
#include "_zope_proxy_proxy.c"
#ifdef PY3K
#define MAKE_PYSTRING(s) PyUnicode_FromString(s)
#else
#define MAKE_PYSTRING(s) PyString_FromString(s)
#endif
#define SPECIAL(NAME) ( \
*(NAME) == '_' && \
(((NAME)[1] == 'p' && (NAME)[2] == '_') \
...
...
@@ -100,7 +106,7 @@ CP_getattro(PyObject *self, PyObject *name)
{
char
*
cname
;
cname
=
PyString_AsString
(
name
);
cname
=
MAKE_STRING
(
name
);
if
(
cname
==
NULL
)
return
NULL
;
...
...
@@ -117,7 +123,7 @@ CP_setattro(PyObject *self, PyObject *name, PyObject *v)
{
char
*
cname
;
cname
=
PyString_AsString
(
name
);
cname
=
MAKE_STRING
(
name
);
if
(
cname
==
NULL
)
return
-
1
;
...
...
@@ -172,7 +178,7 @@ CP_reduce(ProxyObject *self)
if
(
!
PER_USE
(
self
))
return
NULL
;
result
=
Py_BuildValue
(
"O(O)(OO)"
,
self
->
ob_type
,
Py_TYPE
(
self
)
,
self
->
proxy_object
,
self
->
__parent__
?
self
->
__parent__
:
Py_None
,
self
->
__name__
?
self
->
__name__
:
Py_None
...
...
@@ -287,37 +293,39 @@ CP_dealloc(ProxyObject *self)
cPersistenceCAPI
->
pertype
->
tp_dealloc
((
PyObject
*
)
self
);
}
#ifndef PyMODINIT_FUNC
/* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
PyMODINIT_FUNC
init_zope_container_contained
(
void
)
MOD_INIT
(
_zope_container_contained
)
{
PyObject
*
m
;
str_p_deactivate
=
PyString_FromString
(
"_p_deactivate"
);
str_p_deactivate
=
MAKE_PYSTRING
(
"_p_deactivate"
);
if
(
str_p_deactivate
==
NULL
)
return
;
return
MOD_ERROR_VAL
;
/* Try to fake out compiler nag function */
if
(
0
)
init_zope_proxy_proxy
();
m
=
Py_InitModule3
(
"_zope_container_contained"
,
module_functions
,
module___doc__
);
MOD_DEF
(
m
,
"_zope_container_contained"
,
module___doc__
,
module_functions
);
if
(
m
==
NULL
)
return
;
return
MOD_ERROR_VAL
;
if
(
empty_tuple
==
NULL
)
empty_tuple
=
PyTuple_New
(
0
);
/* Initialize the PyPersist_C_API and the type objects. */
cPersistenceCAPI
=
PyCObject_Import
(
"persistent.cPersistence"
,
"CAPI"
);
#ifdef PY3K
cPersistenceCAPI
=
(
cPersistenceCAPIstruct
*
)
PyCapsule_Import
(
"persistent.cPersistence.CAPI"
,
0
);
#else
cPersistenceCAPI
=
(
cPersistenceCAPIstruct
*
)
PyCObject_Import
(
"persistent.cPersistence"
,
"CAPI"
);
#endif
if
(
cPersistenceCAPI
==
NULL
)
return
;
return
MOD_ERROR_VAL
;
ProxyType
.
tp_name
=
"zope.container.contained.ContainedProxyBase"
;
P
roxyType
.
ob_type
=
&
PyType_Type
;
P
y_TYPE
(
&
ProxyType
)
=
&
PyType_Type
;
ProxyType
.
tp_base
=
cPersistenceCAPI
->
pertype
;
ProxyType
.
tp_getattro
=
CP_getattro
;
ProxyType
.
tp_setattro
=
CP_setattro
;
...
...
@@ -329,8 +337,10 @@ init_zope_container_contained(void)
ProxyType
.
tp_weaklistoffset
=
offsetof
(
ProxyObject
,
po_weaklist
);
if
(
PyType_Ready
(
&
ProxyType
)
<
0
)
return
;
return
MOD_ERROR_VAL
;
Py_INCREF
(
&
ProxyType
);
PyModule_AddObject
(
m
,
"ContainedProxyBase"
,
(
PyObject
*
)
&
ProxyType
);
return
MOD_SUCCESS_VAL
(
m
);
}
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