Commit Graph

247 Commits

Author SHA1 Message Date
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
Fred Drake 85d835f0ab set_error(): Handle construction of pyexpat.error exceptions. They
now carry a 'code' attribute that gives the Expat error
              number.

Added support for additional handlers for Expat 1.95.*, including
XmlDeclHandler, EntityDeclHandler, ElementDeclHandler, and
AttlistDeclHandler.  Associated constants are in the 'model'
sub-object.

Added two new attributes to the parser object: ordered_attributes and
specified_attributes.  These are used to control how attributes are
reported and which attributes are reported.
2001-02-08 15:39:08 +00:00
Martin v. Löwis 76192ee4f5 Support older PYTHON_API_VERSIONs for backwards compatibility. 2001-02-06 09:34:40 +00:00
Jeremy Hylton 78dc825a41 Fix arguments for PyFrame_New(). The previous checkin used the wrong
arguments, which were based on an interim development API.
2001-01-25 21:48:14 +00:00
Jeremy Hylton 903f654ac9 PEP 227 implementation
Track changes to PyFrame_New() and PyFuntion_New().
2001-01-25 20:07:56 +00:00
Martin v. Löwis 3af7cc034c Fix off-by-one error in array size. 2001-01-22 08:19:10 +00:00
Tim Peters e815786858 Fixed teensy memory leak, but doesn't help test_sax on Windows. 2001-01-22 03:20:55 +00:00
Martin v. Löwis 6512dbd5be Fix typo: MICRO instead of MINOR. 2001-01-21 10:22:12 +00:00
Martin v. Löwis 0078f6cc80 Merge with 1.25 of PyXML:
Participate in garbage collection if available.
Potentially decref handlers in clear_handlers.
Partially reindent.
Put synthetic frame object on the stack to support better error output.
Expose Python codecs to pyexpat.
Add new Expat 1.2 handlers and API.
Fix memory leak: release self->handlers.
Do not expect PyModule_AddObject and PyModule_AddStringConstant in 2.0b1.
Raise exception in ParseFile.
2001-01-21 10:18:10 +00:00
Fred Drake 2d4ac208b5 Mark the "encoding" parameter to ExternalEntityParserCreate() as optional
in the docstring.
2001-01-03 15:36:25 +00:00
Fred Drake 738293d663 When using the latest & greatest version of Expat (currently in the Expat
CVS repository), provide the library version information.
2000-12-21 17:25:07 +00:00
Fred Drake e8f3ad560f Add returns_unicode to the __members__ list.
Fix a small style consistency nit.
2000-12-16 01:48:29 +00:00
Fred Drake 4ba298c325 ParserCreate(): Added test that the namespace_separator value, if given,
has the required length.

initpyexpat():  Provide the type object for the ParserCreate() return
                value as XMLParserType.
2000-10-29 04:57:53 +00:00
Fred Drake a77254a724 PyModule_AddStringConstant(): Make this static since it isn't used
elsewhere in 1.5.2.
2000-09-29 19:23:29 +00:00
Martin v. Löwis c0718eba21 Remove unused VERSION #define.
Add PyModule_AddStringConstant and PyModule_AddObject if version <2.0,
to allow to share this file with PyXML.
2000-09-29 19:05:48 +00:00
Tim Peters 51dc968b0b Repaired damaged string. 2000-09-24 22:12:45 +00:00
Fred Drake 28adf52b06 xmlparse_ExternalEntityParserCreate(): Add required cast to return to
avoid compiler warnings.
2000-09-24 22:07:59 +00:00
Lars Gustäbel 4a30a07186 Added ExternalEntityParserCreate method (patch 101635). 2000-09-24 20:50:52 +00:00
Fred Drake 93adb6918c Change the name of the exception from "pyexpat.error" to
"xml.parsers.expat.error", so it will reflect the public name of the
exception rather than the internal name.

Also change some of the initialization to use the new PyModule_Add*()
convenience functions.
2000-09-23 04:55:48 +00:00
Fred Drake 676940b497 When PyInt_FromLong() returns NULL, you do not need to check
PyErr_Occurred().  Removed the extra test and setting of a
bogus exception.
2000-09-22 15:21:31 +00:00
Tim Peters 954eef7e51 Fix for SF bug 115051: Dodgy use of PyTuple_SET_ITEM in pyexpat.c 2000-09-22 06:01:11 +00:00
Fred Drake 0f6dcb3f9e Remove debugging print. ;( 2000-09-22 04:49:50 +00:00
Fred Drake ca1f426080 Remove memory leaks of strings/Unicode objects passed into the character
data and default handlers -- a new reference was being passed to
Py_BuildValue() for the "O" format character; using "N" plugs the leak.

Fixed two other (minor) leaks that occurred on various error conditions.

Removed uses of the UNLESS macro, which makes code hard to read, and is
Evil.
2000-09-21 20:10:23 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Tim Peters 6d7c442e03 Try to supply a prototype for the module init function but avoid
Windows "inconsistent linkage" warnings at the same time.  I agree
with Mark Hammond that the whole DL_IMPORT/DL_EXPORT macro system
needs an overhaul; this is just an expedient hack until then.
2000-08-26 07:38:06 +00:00
Fred Drake 6f9876212d initpyexpat(): Code cleanup; makes it more robust and reduces warnings.
Added prototype to remove yet another warning.

Make a number of the handlers and helpers "static" since they are not
used in other C source files.  This also reduces the number of warnings.

Make a lot of the code "more Python".  (Need to get the style guide done!)
2000-08-25 18:03:30 +00:00
Fred Drake 9ed49e979f Fix the evil booboos. ;( Causes discussed with Jeremy offline. 2000-08-24 22:27:02 +00:00
Fred Drake c23b5239ae Remove the Py_FatalError() from initpyexpat(); the Guido has decreed
that this is not appropriate.

Made somewhat more robust in the face of reload() (exception is not
rebuilt, etc.).

Made the exception a class exception.
2000-08-24 21:57:43 +00:00
Thomas Wouters 3531730a68 Mark Favas's fix for typos in docstrings. 2000-07-22 16:34:15 +00:00
Fred Drake 0582df98d3 Convert coding style to be internally consistent and similar to the
rest of the Python C code: space between "if", "for" and "(", no space
between "(", ")" and function call parameters, etc.
2000-07-12 04:49:00 +00:00
Andrew M. Kuchling c72c3bed77 Fix bugs in readinst():
* There was no error reported if the .read() method returns a non-string
* If read() returned too much data, the buffer would be overflowed causing a
  core dump
* Used strncpy, not memcpy, which seems incorrect if there are embedded \0s.
* The args and bytes objects were leaked
2000-07-12 01:27:18 +00:00
Andrew M. Kuchling a4e75d74f8 Patch #100854 from jhylton: eliminate compiler warnings in pyexpat:
The first two warnings seem harmless enough,
	but the last one looks like a potential bug: an
	uninitialized int is returned on error. (I also
	ended up reformatting some of the code,
	because it was hard to read.)
2000-07-12 00:53:41 +00:00
Fred Drake 7bd9f41c65 pyexpat.errors is a *strange* module!
It gets initialized when pyexpat is imported, and is only accessible as an
attribute of pyexpat; it cannot be imported itself.  This allows it to at
least be importable after pyexpat itself has been imported by adding it
to sys.modules, so it is not quite as strange.

This arrangement needs to be better thought out.
2000-07-04 23:51:31 +00:00
Andrew M. Kuchling 637f6642f2 Fixes for compilation problems on Tru64 reported by Mark Favas 2000-07-04 14:53:43 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Andrew M. Kuchling beba056cd7 Added support for passing Unicode strings to Expat handlers by default.
This version still includes #ifdef hackery to compile with 1.5.2.
2000-06-27 00:33:30 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Guido van Rossum 5db862dd0c Skip Montanaro: add string precisions to calls to PyErr_Format
to prevent possible buffer overruns.
2000-04-10 12:46:51 +00:00
Guido van Rossum 5961f5a06d Make it compile on Windows. 2000-03-31 16:18:11 +00:00
Andrew M. Kuchling b7f105371f Added Python interface to Expat XML parser.
The Setup.in entry is sort of a lie; it links with -lexpat, but
    Expat's Makefile doesn't actually build a libexpat.a.  I'll send
    Expat's author a patch to do that; if he doesn't accept it, this
    rule will have to list Expat's object files (ick!), or have a
    comment explaining how to build a .a file.
2000-03-31 15:43:31 +00:00