from sre_constants import *
+assert _sre.MAGIC == MAGIC, "SRE module mismatch"
+
MAXCODE = 65535
def _compile(code, pattern, flags):
# See the sre.py file for information on usage and redistribution.
#
+# update when constants are added or removed
+
+MAGIC = 20010115
+
+# max code word in this release
+
MAXREPEAT = 65535
+# SRE standard exception (access as sre.error)
# should this really be here?
class error(Exception):
""")
+ f.write("#define SRE_MAGIC %d\n" % MAGIC)
+
dump(f, OPCODES, "SRE_OP")
dump(f, ATCODES, "SRE")
dump(f, CHCODES, "SRE")
#endif
init_sre(void)
{
+ PyObject* m;
+ PyObject* d;
+
/* Patch object types */
Pattern_Type.ob_type = Match_Type.ob_type =
Scanner_Type.ob_type = &PyType_Type;
- Py_InitModule("_" MODULE, _functions);
+ m = Py_InitModule("_" MODULE, _functions);
+ d = PyModule_GetDict(m);
+
+ PyDict_SetItemString(
+ d, "MAGIC", (PyObject*) PyInt_FromLong(SRE_MAGIC)
+ );
}
#endif /* !defined(SRE_RECURSIVE) */
* See the _sre.c file for information on usage and redistribution.
*/
+#define SRE_MAGIC 20010115
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
#define SRE_OP_ANY 2