Commit Graph

89 Commits

Author SHA1 Message Date
Martin v. Löwis 9171f02132 Synchronize with PyXML 1.79:
73: Restore support for Python 2.1.
74: Factor the previous change differently
79: Conditionalize usage of PyTuple_Pack.
2004-10-13 19:50:11 +00:00
Dave Cole 3203efb55f Patch #1014930. Expose current parse location to XMLParser. 2004-08-26 00:37:31 +00:00
Fred Drake 39689c5c6a make exception propogation more efficient; this avoids having Expat parse
the remaining data in the buffer (which it had done happily without reporting
any results)

this depends on a new feature in Expat added in 1.95.8
2004-08-13 03:12:57 +00:00
Fred Drake 283b670f6b add constants for many error values added over the past couple of
years
2004-08-04 22:28:16 +00:00
Michael W. Hudson 0bb8454ed4 Fix the reference count errors revealed by the test suite... 2004-08-03 11:31:31 +00:00
Raymond Hettinger 8ae4689657 Simplify and speedup uses of Py_BuildValue():
* Py_BuildValue("(OOO)",a,b,c)  -->  PyTuple_Pack(3,a,b,c)
* Py_BuildValue("()",a)         -->  PyTuple_New(0)
* Py_BuildValue("O", a)         -->  Py_INCREF(a)
2003-10-12 19:09:37 +00:00
Fred Drake f239c6d537 Repair mis-application of Jeremy's patch. Thanks, Neal! 2003-07-21 17:22:43 +00:00
Fred Drake 7b6caffd70 Fix memory leak reported & discussed on the Python XML-SIG mailing list.
This patch was provided by Jeremy Kloth, and corresponds to pyexpat.c
1.77 in the PyXML CVS.
2003-07-21 17:05:56 +00:00
Jeremy Hylton 9263f5797c Fix several bugs in handling of exceptions with trace function enabled.
If the callback raised an exception but did not set curexc_traceback,
the trace function was called with PyTrace_RETURN.  That is, the trace
function was called with an exception set.  The main loop detected the
exception when the trace function returned; it complained and disabled
tracing.

Fix the logic error so that PyTrace_RETURN only occurs if the callback
returned normally.

The trace function must be called for exceptions, too.  So we had
to add new functionality to call with PyTrace_EXCEPTION.  (Leads to a
rather ugly ifdef / else block that contains only a '}'.)

Reverse the logic and name of NOFIX_TRACE to FIX_TRACE.

Joint work with Fred.
2003-06-27 16:13:17 +00:00
Fred Drake 06dd8cf5e4 Fix memory leak: free memory storing the content model passed to the
ElementDeclHandler by Expat.
Fixes SF bug #676990.
2003-02-02 03:54:17 +00:00
Martin v. Löwis c847f4040d Conditionalize features not found in PyXML 1.95.2. 2003-01-21 11:09:21 +00:00
Martin v. Löwis 069dde2be3 Merge with PyXML 1.71:
60: Added support for the SkippedEntityHandler, new in Expat 1.95.4.
61: Added support for namespace prefixes, which can be enabled by setting the
    "namespace_prefixes" attribute on the parser object.
65: Disable profiling changes for Python 2.0 and 2.1.
66: Update pyexpat to export the Expat 1.95.5 XML_GetFeatureList()
    information, and tighten up a type declaration now that Expat is using
    an incomplete type rather than a void * for the XML_Parser type.
67: Clarified a comment.
    Added support for XML_UseForeignDTD(), new in Expat 1.95.5.
68: Refactor to avoid partial duplication of the code to construct an
    ExpatError instance, and actually conform to the API for the exception
    instance as well.
69: Remove some spurious trailing whitespace.
    Add a special external-entity-ref handler that gets installed once a
    handler has raised a Python exception; this can cancel actual parsing
    earlier if there's an external entity reference in the input data
    after the the Python excpetion has been raised.
70: Untabify APPEND.
71: Backport PyMODINIT_FUNC for 2.2 and earlier.
2003-01-21 10:58:18 +00:00
Neal Norwitz fa56e2dc40 SF # 669553, fix memory (ref) leaks
Will backport.
2003-01-19 15:40:09 +00:00
Michael W. Hudson 019a78e76d Assorted patches from Armin Rigo:
[ 617309 ] getframe hook (Psyco #1)
[ 617311 ] Tiny profiling info (Psyco #2)
[ 617312 ] debugger-controlled jumps (Psyco #3)

These are forward ports from 2.2.2.
2002-11-08 12:53:11 +00:00
Fred Drake 117ac85c4e Be more careful with the type of the xmlhandlersetter; it takes an
XML_Parser, which happens to be a pointer type, not an XML_Parser*.
This generated warnings when compiled with Expat 1.95.5, which no
longer defines XML_Parser to be void*.
2002-09-24 16:24:54 +00:00
Fred Drake f57b22a716 Minor change for symmetry with PyXML: PyDoc_STR should not include
the "safety" parentheses since some older compilers refuse to compile
the module then, claiming that static initializers are non-constant.

This doesn't actually make any difference for Python, since these
definitions are not used when compiling with a version of Python that
already defines the PyDoc_* macros.
2002-09-02 15:54:06 +00:00
Guido van Rossum 84b2bed435 Squash a few calls to the hideously expensive PyObject_CallObject(o,a)
-- replace then with slightly faster PyObject_Call(o,a,NULL).  (The
difference is that the latter requires a to be a tuple; the former
allows other values and wraps them in a tuple if necessary; it
involves two more levels of C function calls to accomplish all that.)
2002-08-16 17:01:09 +00:00
Martin v. Löwis 7d6e19d70c Add trace_frame. Fixes #534864. Backported to 2.2. 2002-08-04 08:24:49 +00:00
Fred Drake 814f9fe806 Return NULL instead of 0 from function with a pointer return value. 2002-07-19 22:03:03 +00:00
Mark Hammond 8235ea1c3a Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT. 2002-07-19 06:55:41 +00:00
Tim Peters 0c32279626 Removed more stray instances of statichere, but left _sre.c alone. 2002-07-17 16:49:03 +00:00
Jeremy Hylton 938ace69a0 staticforward bites the dust.
The staticforward define was needed to support certain broken C
compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the
static keyword when it was used with a forward declaration of a static
initialized structure.  Standard C allows the forward declaration with
static, and we've decided to stop catering to broken C compilers.  (In
fact, we expect that the compilers are all fixed eight years later.)

I'm leaving staticforward and statichere defined in object.h as
static.  This is only for backwards compatibility with C extensions
that might still use it.

XXX I haven't updated the documentation.
2002-07-17 16:30:39 +00:00
Fred Drake b28467b713 Do not depend on pymemcompat.h (was only used for PyXML); Martin likes
it all inline.
2002-07-02 15:44:36 +00:00
Fred Drake 7c75bf2090 Bring this back into sync with PyXML revision 1.58. 2002-07-01 14:02:31 +00:00
Martin v. Löwis b4fcf4d102 Define PyDoc_STRVAR if it is not available (PyXML 1.54).
Remove support for Python 1.5 (PyXML 1.55).
2002-06-30 06:40:55 +00:00
Martin v. Löwis 6b2cf0e5ea Undo usage of PyOS_snprintf (rev. 1.51 of PyXML). 2002-06-30 06:03:35 +00:00
Fred Drake 2a3d7db93e Added character data buffering to pyexpat parser objects.
Setting the buffer_text attribute to true causes the parser to collect
character data, waiting as long as possible to report it to the Python
callback.  This can save an enormous number of callbacks from C to
Python, which can be a substantial performance improvement.

buffer_text defaults to false.
2002-06-28 22:56:48 +00:00
Fred Drake 71b63ff342 pyexpat code cleanup and minor refactorings:
The handlers array on each parser now has the invariant that None will
never be set as a handler; it will always be NULL or a Python-level
value passed in for the specific handler.

have_handler():  Return true if there is a Python handler for a
    particular event.

get_handler_name():  Return a string object giving the name of a
    particular handler.  This caches the string object so it doesn't
    need to be created more than once.

get_parse_result():  Helper to allow the Parse() and ParseFile()
    methods to share the same logic for determining the return value
    or exception state.

PyUnknownEncodingHandler(), PyModule_AddIntConstant():
    Made these helpers static.  (The later is only defined for older
    versions of Python.)

pyxml_UpdatePairedHandlers(), pyxml_SetStartElementHandler(),
pyxml_SetEndElementHandler(), pyxml_SetStartNamespaceDeclHandler(),
pyxml_SetEndNamespaceDeclHandler(), pyxml_SetStartCdataSection(),
pyxml_SetEndCdataSection(), pyxml_SetStartDoctypeDeclHandler(),
pyxml_SetEndDoctypeDeclHandler():
    Removed.  These are no longer needed with Expat 1.95.x.

handler_info:
    Use the setter functions provided by Expat 1.95.x instead of the
    pyxml_Set*Handler() functions which have been removed.

Minor code formatting changes for consistency.
Trailing whitespace removed.
2002-06-28 22:29:01 +00:00
Fred Drake b91a36b230 Integrate the changes from PyXML's version of pyexpat.c revisions
1.47, 1.48, 1.49 (name interning support).
2002-06-27 19:40:48 +00:00
Martin v. Löwis 14f8b4cfcb Patch #568124: Add doc string macros. 2002-06-13 20:33:02 +00:00
Neal Norwitz 3afb2d2bba Remove compiler warnings on Solaris 8.
Can go into 2.2.x, but not necessary.
2002-03-20 21:32:07 +00:00
Martin v. Löwis cf453fe2a8 Use included Expat library. Drop support for older expat versions. 2002-02-11 23:27:45 +00:00
Guido van Rossum 146483964e Patch supplied by Burton Radons for his own SF bug #487390: Modifying
type.__module__ behavior.

This adds the module name and a dot in front of the type name in every
type object initializer, except for built-in types (and those that
already had this).  Note that it touches lots of Mac modules -- I have
no way to test these but the changes look right.  Apologies if they're
not.  This also touches the weakref docs, which contains a sample type
object initializer.  It also touches the mmap test output, because the
mmap type's repr is included in that output.  It touches object.h to
put the correct description in a comment.
2001-12-08 18:02:58 +00:00
Tim Peters 885d457709 sprintf -> PyOS_snprintf in some "obviously safe" cases.
Also changed <>-style #includes to ""-style in some places where the
former didn't make sense.
2001-11-28 20:27:42 +00:00
Fred Drake 8188e792d9 assert.h was not always included by Python.h; make sure we import it for
older versions.  (Thanks to Martijn Faassen.)
2001-11-18 02:36:07 +00:00
Martin v. Löwis 42ba08fab0 Patch #473265: UpdatePairedHandlers nonsensical. 2001-11-10 13:59:16 +00:00
Martin v. Löwis 1d7c55faee Merge 1.42 from PyXML: Flag errors resulting from argument conversion problems.
Fixes problem with not detecting UTF-8 errors.
2001-11-10 13:57:55 +00:00
Martin v. Löwis 5b68ce3122 Change clear_handlers argument to indicate whether this is an initialization.
Do not set the Expat handlers if it is. Fixes PyXML bug #473195.
2001-10-21 08:53:52 +00:00
Martin v. Löwis 894258cebe Reactivate participation of expat parsers in GC. Fixes bug #462710. 2001-09-23 10:20:10 +00:00
Martin v. Löwis 7090ed16d7 Include ctype.h after Python.h. 2001-09-19 10:37:50 +00:00
Martin v. Löwis c57428d3a0 Patch to bug #461753: Allow None in ExternalEntityParserCreate. 2001-09-19 09:55:09 +00:00
Martin v. Löwis 339d0f720e Patch #445762: Support --disable-unicode
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
2001-08-17 18:39:25 +00:00
Tim Peters 9544fc5027 Squash compiler wng about mixing signed and unsigned in comparison. 2001-07-28 09:36:36 +00:00
Fred Drake cde79131ea ParserCreate(): Allow an empty string for the namespace_separator argument;
while not generally a good idea, this is used by RDF users, and works
    to implement RDF-style namespace+localname concatenation as defined
    in the RDF specifications.  (This also corrects a backwards-compatibility
    bug.)

Be more conservative while clearing out handlers; set the slot in the
self->handlers array to NULL before DECREFing the callback.

Still more adjustments to make the code style internally consistent.
2001-04-25 16:01:30 +00:00
Fred Drake 4113b137cd get_version_string(): New function -- returns a Python string object that
gives the CVS revision of this file even if it does not include the
    extra RCS "$Revision: " cruft.

initpyexpat():  Use get_version_string() instead of hard-coding magic
    indexes into the RCS string (which may be affected by export options).
2001-03-24 19:58:26 +00:00
Jeremy Hylton 30c9f3991c Variety of small INC/DECREF patches that fix reported memory leaks
with free variables.  Thanks to Martin v. Loewis for finding two of
the problems.  This fixes SF buf 405583.

There is also a C API change: PyFrame_New() is reverting to its
pre-2.1 signature.  The change introduced by nested scopes was a
mistake.  XXX Is this okay between beta releases?

cell_clear(), the GC helper, must decref its reference to break
cycles.

frame_dealloc() must dealloc all cell vars and free vars in addition
to locals.

eval_code2() setup code must INCREF cells it copies out of the
closure.

The STORE_DEREF opcode implementation must DECREF the object it passes
to PyCell_Set().
2001-03-13 01:58:22 +00:00
Fred Drake bb66a200be Wrap some long lines, use only C89 /* */ comments, and add spaces around
some operators (style guide conformance).
2001-03-01 20:48:17 +00:00
Tim Peters 63cb99e4f0 Bug #132816: Compiler warning in PYEXPAT.C for extra ';'
Removed trailing ";" in instances of "};" closing code blocks.
2001-02-17 18:12:50 +00:00
Fred Drake 6bfa31c5a0 Remove the old version of my_StartElementHandler(). This was conditionally
compiled only for some versions of Expat, but was no longer needed as the
new implementation works for all versions.  Keeping it created multiple
definitions for Expat 1.2, which caused compilation to fail.
2001-02-16 20:46:26 +00:00
Fred Drake bd6101c3dc xmlparseobject: Remove the unused conv_attrs field, added an
in_callback field that's set to true whenever a callback into an
    event handler is true.  Needed for:

set_error():  Add line number of offset information to the exception
    as attributes, so users don't need to parse the text of the
    message.

set_error_attr():  New helper function for set_error().

xmlparse_GetInputContext():  New function of the parser object;
    returns the document source for an event during a callback, None
    at all other times.

xmlparse_SetParamEntityParsing():  Make the signature consistent with
    the other parser methods (use xmlparseobject* for self instead of
    PyObject*).

initpyexpat():  Don't lose the reference to the exception class!

call_with_frame(),
getcode():  Re-indent to be consistent with the rest of the file.
2001-02-14 18:29:45 +00:00