Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
fdf6f3c4
Commit
fdf6f3c4
authored
Dec 15, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in method attribute handling.
Added support for sniffing out __module__ for classes.
parent
2acdfa26
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
16 deletions
+110
-16
lib/Components/ExtensionClass/ExtensionClass.c
lib/Components/ExtensionClass/ExtensionClass.c
+55
-8
lib/Components/ExtensionClass/src/ExtensionClass.c
lib/Components/ExtensionClass/src/ExtensionClass.c
+55
-8
No files found.
lib/Components/ExtensionClass/ExtensionClass.c
View file @
fdf6f3c4
/*
/*
$Id: ExtensionClass.c,v 1.
19 1997/12/15 15:18:36
jim Exp $
$Id: ExtensionClass.c,v 1.
20 1997/12/15 19:54:00
jim Exp $
Extension Class
Extension Class
...
@@ -65,7 +65,7 @@ static char ExtensionClass_module_documentation[] =
...
@@ -65,7 +65,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,
\n
"
" - They provide access to unbound methods,
\n
"
" - They can be called to create instances.
\n
"
" - They can be called to create instances.
\n
"
"
\n
"
"
\n
"
"$Id: ExtensionClass.c,v 1.
19 1997/12/15 15:18:36
jim Exp $
\n
"
"$Id: ExtensionClass.c,v 1.
20 1997/12/15 19:54:00
jim Exp $
\n
"
;
;
#include <stdio.h>
#include <stdio.h>
...
@@ -113,7 +113,8 @@ static PyObject *py__add__, *py__sub__, *py__mul__, *py__div__,
...
@@ -113,7 +113,8 @@ static PyObject *py__add__, *py__sub__, *py__mul__, *py__div__,
*
py__getattr__
,
*
py__setattr__
,
*
py__delattr__
,
*
py__getattr__
,
*
py__setattr__
,
*
py__delattr__
,
*
py__del__
,
*
py__repr__
,
*
py__str__
,
*
py__class__
,
*
py__name__
,
*
py__del__
,
*
py__repr__
,
*
py__str__
,
*
py__class__
,
*
py__name__
,
*
py__hash__
,
*
py__cmp__
,
*
py__var_size__
,
*
py__init__
,
*
py__getinitargs__
,
*
py__hash__
,
*
py__cmp__
,
*
py__var_size__
,
*
py__init__
,
*
py__getinitargs__
,
*
py__getstate__
,
*
py__setstate__
,
*
py__dict__
,
*
pyclass_
;
*
py__getstate__
,
*
py__setstate__
,
*
py__dict__
,
*
pyclass_
,
*
py__module__
;
static
PyObject
*
concat_fmt
=
0
;
static
PyObject
*
concat_fmt
=
0
;
static
PyObject
*
subclass_watcher
=
0
;
/* Object that subclass events */
static
PyObject
*
subclass_watcher
=
0
;
/* Object that subclass events */
...
@@ -172,6 +173,7 @@ init_py_names()
...
@@ -172,6 +173,7 @@ init_py_names()
INIT_PY_NAME
(
__setstate__
);
INIT_PY_NAME
(
__setstate__
);
INIT_PY_NAME
(
__dict__
);
INIT_PY_NAME
(
__dict__
);
INIT_PY_NAME
(
class_
);
INIT_PY_NAME
(
class_
);
INIT_PY_NAME
(
__module__
);
#undef INIT_PY_NAME
#undef INIT_PY_NAME
}
}
...
@@ -793,13 +795,27 @@ PMethod_getattro(PMethod *self, PyObject *oname)
...
@@ -793,13 +795,27 @@ PMethod_getattro(PMethod *self, PyObject *oname)
UNLESS
(
name
=
PyString_AsString
(
oname
))
return
NULL
;
UNLESS
(
name
=
PyString_AsString
(
oname
))
return
NULL
;
if
(
name
[
0
]
!=
'_'
&&
name
[
0
]
&&
name
[
1
]
!=
'_'
&&
if
(
name
[
0
]
==
'_'
&&
name
[
1
]
==
'_'
)
PyEval_GetRestricted
())
{
if
(
strcmp
(
name
+
2
,
"name__"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__name__"
);
if
(
strcmp
(
name
+
2
,
"doc__"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__doc__"
);
}
else
if
(
PyEval_GetRestricted
())
{
{
PyErr_SetString
(
PyExc_RuntimeError
,
PyErr_SetString
(
PyExc_RuntimeError
,
"function attributes not accessible in restricted mode"
);
"function attributes not accessible in restricted mode"
);
return
NULL
;
return
NULL
;
}
}
else
if
(
name
[
0
]
==
'f'
&&
name
[
1
]
==
'u'
&&
name
[
2
]
==
'n'
&&
name
[
3
]
==
'c'
&&
name
[
4
]
==
'_'
)
{
if
(
strcmp
(
name
+
5
,
"name"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__name__"
);
if
(
strcmp
(
name
+
5
,
"doc"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__doc__"
);
}
if
(
*
name
++==
'i'
&&
*
name
++==
'm'
&&
*
name
++==
'_'
)
if
(
*
name
++==
'i'
&&
*
name
++==
'm'
&&
*
name
++==
'_'
)
{
{
...
@@ -3120,6 +3136,20 @@ subclass__init__(PyExtensionClass *self, PyObject *args)
...
@@ -3120,6 +3136,20 @@ subclass__init__(PyExtensionClass *self, PyObject *args)
subclass_set
(
str
,
str
);
subclass_set
(
str
,
str
);
self
->
tp_doc
=
0
;
self
->
tp_doc
=
0
;
/* Implement __module__=__name__ */
if
(
PyDict_GetItem
(
methods
,
py__module__
)
==
NULL
)
{
PyObject
*
globals
=
PyEval_GetGlobals
();
if
(
globals
!=
NULL
)
{
PyObject
*
modname
=
PyDict_GetItem
(
globals
,
py__name__
);
if
(
modname
!=
NULL
)
{
if
(
PyDict_SetItem
(
methods
,
py__module__
,
modname
)
<
0
)
return
NULL
;
}
}
}
/* Check for and use __class_init__ */
/* Check for and use __class_init__ */
if
((
class_init
=
PyObject_GetAttrString
(
AsPyObject
(
self
),
"__class_init__"
)))
if
((
class_init
=
PyObject_GetAttrString
(
AsPyObject
(
self
),
"__class_init__"
)))
{
{
...
@@ -3197,6 +3227,19 @@ static int
...
@@ -3197,6 +3227,19 @@ static int
export_type
(
PyObject
*
dict
,
char
*
name
,
PyExtensionClass
*
typ
)
export_type
(
PyObject
*
dict
,
char
*
name
,
PyExtensionClass
*
typ
)
{
{
initializeBaseExtensionClass
(
typ
);
initializeBaseExtensionClass
(
typ
);
if
(
PyErr_Occurred
())
return
-
1
;
if
(
PyDict_GetItem
(
typ
->
class_dictionary
,
py__module__
)
==
NULL
)
{
PyObject
*
modname
=
PyDict_GetItem
(
dict
,
py__name__
);
if
(
modname
!=
NULL
)
{
if
(
PyDict_SetItem
(
typ
->
class_dictionary
,
py__module__
,
modname
)
<
0
)
return
NULL
;
}
}
PyErr_Clear
();
return
PyMapping_SetItemString
(
dict
,
name
,(
PyObject
*
)
typ
);
return
PyMapping_SetItemString
(
dict
,
name
,(
PyObject
*
)
typ
);
}
}
...
@@ -3216,7 +3259,7 @@ void
...
@@ -3216,7 +3259,7 @@ void
initExtensionClass
()
initExtensionClass
()
{
{
PyObject
*
m
,
*
d
;
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.
19
$"
;
char
*
rev
=
"$Revision: 1.
20
$"
;
PURE_MIXIN_CLASS
(
Base
,
"Minimalbase class for Extension Classes"
,
NULL
);
PURE_MIXIN_CLASS
(
Base
,
"Minimalbase class for Extension Classes"
,
NULL
);
PMethodType
.
ob_type
=&
PyType_Type
;
PMethodType
.
ob_type
=&
PyType_Type
;
...
@@ -3257,6 +3300,10 @@ initExtensionClass()
...
@@ -3257,6 +3300,10 @@ initExtensionClass()
/****************************************************************************
/****************************************************************************
$Log: ExtensionClass.c,v $
$Log: ExtensionClass.c,v $
Revision 1.20 1997/12/15 19:54:00 jim
Fixed bug in method attribute handling.
Added support for sniffing out __module__ for classes.
Revision 1.19 1997/12/15 15:18:36 jim
Revision 1.19 1997/12/15 15:18:36 jim
Changed so that __basicnew__ is always available and calls regular
Changed so that __basicnew__ is always available and calls regular
constructor when EXTENSIONCLASS_BASICNEW_FLAG is not set.
constructor when EXTENSIONCLASS_BASICNEW_FLAG is not set.
...
...
lib/Components/ExtensionClass/src/ExtensionClass.c
View file @
fdf6f3c4
/*
/*
$Id: ExtensionClass.c,v 1.
19 1997/12/15 15:18:36
jim Exp $
$Id: ExtensionClass.c,v 1.
20 1997/12/15 19:54:00
jim Exp $
Extension Class
Extension Class
...
@@ -65,7 +65,7 @@ static char ExtensionClass_module_documentation[] =
...
@@ -65,7 +65,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,
\n
"
" - They provide access to unbound methods,
\n
"
" - They can be called to create instances.
\n
"
" - They can be called to create instances.
\n
"
"
\n
"
"
\n
"
"$Id: ExtensionClass.c,v 1.
19 1997/12/15 15:18:36
jim Exp $
\n
"
"$Id: ExtensionClass.c,v 1.
20 1997/12/15 19:54:00
jim Exp $
\n
"
;
;
#include <stdio.h>
#include <stdio.h>
...
@@ -113,7 +113,8 @@ static PyObject *py__add__, *py__sub__, *py__mul__, *py__div__,
...
@@ -113,7 +113,8 @@ static PyObject *py__add__, *py__sub__, *py__mul__, *py__div__,
*
py__getattr__
,
*
py__setattr__
,
*
py__delattr__
,
*
py__getattr__
,
*
py__setattr__
,
*
py__delattr__
,
*
py__del__
,
*
py__repr__
,
*
py__str__
,
*
py__class__
,
*
py__name__
,
*
py__del__
,
*
py__repr__
,
*
py__str__
,
*
py__class__
,
*
py__name__
,
*
py__hash__
,
*
py__cmp__
,
*
py__var_size__
,
*
py__init__
,
*
py__getinitargs__
,
*
py__hash__
,
*
py__cmp__
,
*
py__var_size__
,
*
py__init__
,
*
py__getinitargs__
,
*
py__getstate__
,
*
py__setstate__
,
*
py__dict__
,
*
pyclass_
;
*
py__getstate__
,
*
py__setstate__
,
*
py__dict__
,
*
pyclass_
,
*
py__module__
;
static
PyObject
*
concat_fmt
=
0
;
static
PyObject
*
concat_fmt
=
0
;
static
PyObject
*
subclass_watcher
=
0
;
/* Object that subclass events */
static
PyObject
*
subclass_watcher
=
0
;
/* Object that subclass events */
...
@@ -172,6 +173,7 @@ init_py_names()
...
@@ -172,6 +173,7 @@ init_py_names()
INIT_PY_NAME
(
__setstate__
);
INIT_PY_NAME
(
__setstate__
);
INIT_PY_NAME
(
__dict__
);
INIT_PY_NAME
(
__dict__
);
INIT_PY_NAME
(
class_
);
INIT_PY_NAME
(
class_
);
INIT_PY_NAME
(
__module__
);
#undef INIT_PY_NAME
#undef INIT_PY_NAME
}
}
...
@@ -793,13 +795,27 @@ PMethod_getattro(PMethod *self, PyObject *oname)
...
@@ -793,13 +795,27 @@ PMethod_getattro(PMethod *self, PyObject *oname)
UNLESS
(
name
=
PyString_AsString
(
oname
))
return
NULL
;
UNLESS
(
name
=
PyString_AsString
(
oname
))
return
NULL
;
if
(
name
[
0
]
!=
'_'
&&
name
[
0
]
&&
name
[
1
]
!=
'_'
&&
if
(
name
[
0
]
==
'_'
&&
name
[
1
]
==
'_'
)
PyEval_GetRestricted
())
{
if
(
strcmp
(
name
+
2
,
"name__"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__name__"
);
if
(
strcmp
(
name
+
2
,
"doc__"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__doc__"
);
}
else
if
(
PyEval_GetRestricted
())
{
{
PyErr_SetString
(
PyExc_RuntimeError
,
PyErr_SetString
(
PyExc_RuntimeError
,
"function attributes not accessible in restricted mode"
);
"function attributes not accessible in restricted mode"
);
return
NULL
;
return
NULL
;
}
}
else
if
(
name
[
0
]
==
'f'
&&
name
[
1
]
==
'u'
&&
name
[
2
]
==
'n'
&&
name
[
3
]
==
'c'
&&
name
[
4
]
==
'_'
)
{
if
(
strcmp
(
name
+
5
,
"name"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__name__"
);
if
(
strcmp
(
name
+
5
,
"doc"
)
==
0
)
return
PyObject_GetAttrString
(
self
->
meth
,
"__doc__"
);
}
if
(
*
name
++==
'i'
&&
*
name
++==
'm'
&&
*
name
++==
'_'
)
if
(
*
name
++==
'i'
&&
*
name
++==
'm'
&&
*
name
++==
'_'
)
{
{
...
@@ -3120,6 +3136,20 @@ subclass__init__(PyExtensionClass *self, PyObject *args)
...
@@ -3120,6 +3136,20 @@ subclass__init__(PyExtensionClass *self, PyObject *args)
subclass_set
(
str
,
str
);
subclass_set
(
str
,
str
);
self
->
tp_doc
=
0
;
self
->
tp_doc
=
0
;
/* Implement __module__=__name__ */
if
(
PyDict_GetItem
(
methods
,
py__module__
)
==
NULL
)
{
PyObject
*
globals
=
PyEval_GetGlobals
();
if
(
globals
!=
NULL
)
{
PyObject
*
modname
=
PyDict_GetItem
(
globals
,
py__name__
);
if
(
modname
!=
NULL
)
{
if
(
PyDict_SetItem
(
methods
,
py__module__
,
modname
)
<
0
)
return
NULL
;
}
}
}
/* Check for and use __class_init__ */
/* Check for and use __class_init__ */
if
((
class_init
=
PyObject_GetAttrString
(
AsPyObject
(
self
),
"__class_init__"
)))
if
((
class_init
=
PyObject_GetAttrString
(
AsPyObject
(
self
),
"__class_init__"
)))
{
{
...
@@ -3197,6 +3227,19 @@ static int
...
@@ -3197,6 +3227,19 @@ static int
export_type
(
PyObject
*
dict
,
char
*
name
,
PyExtensionClass
*
typ
)
export_type
(
PyObject
*
dict
,
char
*
name
,
PyExtensionClass
*
typ
)
{
{
initializeBaseExtensionClass
(
typ
);
initializeBaseExtensionClass
(
typ
);
if
(
PyErr_Occurred
())
return
-
1
;
if
(
PyDict_GetItem
(
typ
->
class_dictionary
,
py__module__
)
==
NULL
)
{
PyObject
*
modname
=
PyDict_GetItem
(
dict
,
py__name__
);
if
(
modname
!=
NULL
)
{
if
(
PyDict_SetItem
(
typ
->
class_dictionary
,
py__module__
,
modname
)
<
0
)
return
NULL
;
}
}
PyErr_Clear
();
return
PyMapping_SetItemString
(
dict
,
name
,(
PyObject
*
)
typ
);
return
PyMapping_SetItemString
(
dict
,
name
,(
PyObject
*
)
typ
);
}
}
...
@@ -3216,7 +3259,7 @@ void
...
@@ -3216,7 +3259,7 @@ void
initExtensionClass
()
initExtensionClass
()
{
{
PyObject
*
m
,
*
d
;
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.
19
$"
;
char
*
rev
=
"$Revision: 1.
20
$"
;
PURE_MIXIN_CLASS
(
Base
,
"Minimalbase class for Extension Classes"
,
NULL
);
PURE_MIXIN_CLASS
(
Base
,
"Minimalbase class for Extension Classes"
,
NULL
);
PMethodType
.
ob_type
=&
PyType_Type
;
PMethodType
.
ob_type
=&
PyType_Type
;
...
@@ -3257,6 +3300,10 @@ initExtensionClass()
...
@@ -3257,6 +3300,10 @@ initExtensionClass()
/****************************************************************************
/****************************************************************************
$Log: ExtensionClass.c,v $
$Log: ExtensionClass.c,v $
Revision 1.20 1997/12/15 19:54:00 jim
Fixed bug in method attribute handling.
Added support for sniffing out __module__ for classes.
Revision 1.19 1997/12/15 15:18:36 jim
Revision 1.19 1997/12/15 15:18:36 jim
Changed so that __basicnew__ is always available and calls regular
Changed so that __basicnew__ is always available and calls regular
constructor when EXTENSIONCLASS_BASICNEW_FLAG is not set.
constructor when EXTENSIONCLASS_BASICNEW_FLAG is not set.
...
...
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