Is it possible to raise an exception in the initmodule function of a C extension?
Alex
cut_me_out at hotmail.com
Tue Aug 22 16:48:10 EDT 2000
Hi. I have some code like this at the bottom of my extension module:
/**********************************************************************/
void initpattern_array() {
(void)Py_InitModule("pattern_array", Pattern_arrayMethods);
import_array();
/* Assign memory in which to list patterns now, so that it doesn't
have to be done over and over again, later. */
patterns_list = (pattern_array_pattern_score *)calloc(
MAX_PATTERNS_LIST_SIZE,
sizeof(pattern_array_pattern_score));
assert(patterns_list); /* failure means memory overflow. */
sorted_patterns_list = (pattern_array_pattern_score **)calloc(
MAX_PATTERNS_LIST_SIZE,
sizeof(
pattern_array_pattern_score *));
assert(sorted_patterns_list); /* failure means memory overflow. */
}
/**********************************************************************/
Is there some way to turn the asserts into python exceptions? It
doesn't really matter in this case because the assertions are never
going to fail (haha); I'm just a little curious.
TIA.
Alex.
--
I'm not an outlier; I just haven't found my distribution yet.
--- Ronan Conroy
More information about the Python-list
mailing list