Commit Graph

3622 Commits

Author SHA1 Message Date
Fred Drake 3277da0f33 Update the test suite to cover more ground.
This closes patch #102477.
2000-12-14 18:20:22 +00:00
Fred Drake f7cf40d331 Lots of small bug fixes and DOM API conformance improvements:
Make Node inherit from xml.dom.Node to pick up the NodeType values
defined by the W3C recommendation.

When raising AttributeError, be sure to provide the name of the attribute
that does not exist.

Node.normalize():  Make sure we do not allow an empty text node to survive
                   as the first child; update the sibling links properly.

_getElementsByTagNameNSHelper():  Make recursive calls using the right
                                  number of parameters.

Attr.__setattr__():  Be sure to update name and nodeName at the same time
                     since they are synonyms for this node type.

AttributeList:  Renamed to NamedNodeMap (AttributeList maintained as an
                alias).  Compute the length attribute dynamically to allow
                the underlying structures to mutate.

AttributeList.item():  Call .keys() on the dictionary rather than using
                       self.keys() for performance.

AttributeList.setNamedItem(), .setNamedItemNS():
        Added methods.

Text.splitText():
        Added method.

DocumentType:
        Added implementation class.

DOMImplementation:
        Added implementation class.

Document.appendChild():  Do not allow a second document element to be added.

Document.documentElement:  Find this dynamically, so that one can be
        removed and another added.

Document.unlink():  Clear the doctype attribute.

_get_StringIO():  Only use the StringIO module; cStringIO does not support
                  Unicode.
2000-12-14 18:16:11 +00:00
Fred Drake c16adce273 Adjust PullDOM to use a DOMImplementation instance to create new Document
objects; uses minidom if one is not provided to the constructor.

parse():  Pick up the default_bufsize default value dynamically so that
          the value in the module may be (meaningfully) changed at runtime.

This (partially) closes patch #102477.
2000-12-14 18:00:18 +00:00
Fred Drake ec126dab9c When raising KeyError, provide the key value that failed. 2000-12-13 20:48:29 +00:00
Moshe Zadka dd802208a7 Changing allow_reuse_address's default value, and documenting it. 2000-12-13 20:39:22 +00:00
Fred Drake a63bd1c65b Untabify! (Barry, this is gonna cost you a bottle of wine! ;) 2000-12-13 20:23:11 +00:00
Guido van Rossum ff87174db1 Get rid of string module and string exceptions. 2000-12-13 18:11:56 +00:00
Fred Drake 5d1b5eaf55 Add code to DOMException to ensure it cannot be instantiated directly,
since the API documentation will state specifically that the specializations
must be used by the DOM implementations.
2000-12-13 16:35:53 +00:00
Martin v. Löwis 64acf1db22 Add standard DOM exception hierarchy. 2000-12-13 14:21:07 +00:00
Fred Drake 8152d32375 Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.
2000-12-12 23:20:45 +00:00
Barry Warsaw c140131995 Change the file's indentation from tabs to 4 spaces per level. 2000-12-12 23:16:51 +00:00
Barry Warsaw c7ed0e3c13 Accept Finn Bock's patch #102208 to hardcode EINVAL to 22 when errno
can't be imported.  This makes StringIO.py work with Jython.

Also, get rid of the string module by converting to string methods.

Shorten some lines by using augmented assignment where appropriate.
2000-12-12 23:12:23 +00:00
Fred Drake 132dce2246 Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.
2000-12-12 23:11:42 +00:00
Jack Jansen d49056cd90 The ".pth" code knew about the layout of Python trees on unix and
windows, but not on the mac. Fixed.
2000-12-12 22:39:04 +00:00
Guido van Rossum 1072c3872d Add popitem(). 2000-12-12 22:06:00 +00:00
Guido van Rossum b822c6138e Added test for {}.popitem(). 2000-12-12 22:02:59 +00:00
Marc-André Lemburg 988ad2bdff Changed .getaliases() support to register the new aliases in the
encodings package aliases mapping dictionary rather than in the
internal cache used by the search function.

This enables aliases to take advantage of the full normalization
process applied to encoding names which was previously not available.

The patch restricts alias registration to new aliases. Existing
aliases cannot be overridden anymore.
2000-12-12 14:45:35 +00:00
Fred Drake 6bcf4c2a0b Update the docstring.
Add a Node class that defines the NodeType constants, based on discussion
in the XML-SIG.
2000-12-11 22:29:23 +00:00
Fred Drake e1578ce204 Added tests to avoid regression on bug #125375.
roundtrip():  Show the offending syntax tree when things break; this makes
              it a little easier to debug the module by adding test cases.

(Still need better tests for this module, but there's not enough time
 today.)
2000-12-11 22:12:09 +00:00
Guido van Rossum 5b7b764afb Apply rstrip() to the lines read from _dirfile in _update(), so that a
dumbdbm archive created on Windows can be read on Unix.
2000-12-11 20:33:52 +00:00
Guido van Rossum 0aee7220db Hoepeful fix for SF bug #123924: Windows - using OpenSSL, problem with
socket in httplib.py.

The bug reports that on Windows, you must pass sock._sock to the
socket.ssl() call.  But on Unix, you must pass sock itself.  (sock is
a wrapper on Windows but not on Unix; the ssl() call wants the real
socket object, not the wrapper.)

So we see if sock has an _sock attribute and if so, extract it.

Unfortunately, the submitter of the bug didn't confirm that this patch
works, so I'll just have to believe it (can't test it myself since I
don't have OpenSSL on Windows set up, and that's a nontrivial thing I
believe).
2000-12-11 20:32:20 +00:00
Fred Drake 7c1e5adf27 Make ConfigParser.Error inherit from Exception. 2000-12-11 18:13:19 +00:00
Andrew M. Kuchling c6c2838403 (Patch #102698) Fix for a bug reported by Wade Leftwich:
StreamReader ignores the 'errors' parameter passed to its constructor
2000-12-10 15:12:14 +00:00
Barry Warsaw 23f26ce813 Fix `credits' to credit the Jython developers when running under that
interpreter.  Update and reword the credits for CPython.  Closes SF
patch #102665.
2000-12-06 22:20:07 +00:00
Sjoerd Mullender f7e84e12b3 Two changes:
- Use new Error class (subclass of RuntimeError so is backward
  compatible) which is raised when RuntimeError used to be raised.
- Report original attribute name in error messages instead of name
  mangled with namespace URL.
2000-12-06 10:37:57 +00:00
Fred Drake 3d5f7e83c7 Add test cases for ConfigParser.remove_option() behavior. This includes
coverage to ensure bug #124324 does not re-surface.
2000-12-04 16:30:40 +00:00
Fred Drake ff4a23bbcb remove_option(): Use the right variable name for the option name!
This closes bug #124324.
2000-12-04 16:29:13 +00:00
Moshe Zadka afb17fc7b2 Call of _cmp had wrong number of paramereters.
Fixed definition of _cmp.
2000-12-03 20:48:07 +00:00
Martin v. Löwis 1d99433a58 Convert Unicode strings to byte strings before passing them into specific
protocols. Closes bug #119822.
2000-12-03 18:30:10 +00:00
Moshe Zadka 5725d1eb03 Backing out my changes.
Improved version coming soon to a Source Forge near you!
2000-11-30 19:30:21 +00:00
Moshe Zadka 1a62750eda Added .first{item,value,key}() to dictionaries.
Complete with docos and tests.
OKed by Guido.
2000-11-30 12:31:03 +00:00
Tim Peters a3a3a030af Fox for SF bug #123859: %[duxXo] long formats inconsistent. 2000-11-30 05:22:44 +00:00
Guido van Rossum 15ffc71c0f Slight improvement to Unicode test suite, inspired by patch #102563:
also test join method of 8-bit strings.

Also changed the test() function to (1) compare the types of the
expected and actual result, and (2) in verbose mode, print the repr()
of the output.
2000-11-29 12:13:59 +00:00
Guido van Rossum f8baad0f17 Patch by Finn Bock to support PyStringMap in Jython. 2000-11-27 21:53:14 +00:00
Fred Drake b7f0cef54d Update test output. 2000-11-21 22:03:09 +00:00
Fred Drake a1bde802f1 testInsertBefore(): Rewritten to actually test insertBefore() somewhat.
testAAA(),
testAAB():  Added checks that the results are right.

testTooManyDocumentElements():  Added code to actually test this.

testCloneElementDeep()
testCloneElementShallow():  Filled these in with test code.

_testCloneElementCopiesAttributes(),
_setupCloneElement():  Helper functions used with the other
        testCloneElement*() functions.

testCloneElementShallowCopiesAttributes():  No longer a separate test;
        _setupCloneElement() uses _testCloneElementCopiesAttributes() to
        test that this is always done.

testNormalize():  Added to check Node.normalize().
2000-11-21 22:02:43 +00:00
Fred Drake 4ccf4a1e8a Reduce the visibility of imported modules for cleaner "from ... import *"
behavior.

Added support for the Attr.ownerElement attribute.

Everywhere:  Define constant object attributes in the classes rather than
on the instances during object construction.  This reduces the amount of
work needed for object construction and destruction; these need to be
lightweight operations on a DOM.

Node._get_firstChild(),
Node._get_lastChild():  Return None if there are no children (required for
        compliance with DOM level 1).

Node.insertBefore():  If refChild is None, append the new node instead of
        failing (required for compliance).  Also, update the sibling
        relationships.  Return the inserted node (required for compliance).

Node.appendChild():  Update the parent of the appended node.

Node.replaceChild():  Actually replace the old child!  Update the parent
        and sibling relationships of both the old and new children.  Return
        the replaced child (required for compliance).

Node.normalize():  Implemented the normalize() method.  Required for
        compliance, but missing from the release.  Useful for joining
        adjacent Text nodes into a single node for easier processing.

Node.cloneNode():  Actually make this work.  Don't let the new node share
        the instance __dict__ with the original.  Do proper recursion if
        doing a "deep" clone.  Move the attribute cloning out of the base
        class, since only Element is supposed to have attributes.

Node.unlink():  Simplify handling of child nodes for efficiency, and
        remove the attribute handling since only Element nodes support
        attributes.

Attr.cloneNode():  Extend this to clear the ownerElement attribute in
        the clone.

AttributeList.items(),
AttributeList.itemsNS():  Slight performance improvement (avoid lambda).

Element.cloneNode():  Extend Node.cloneNode() with support for the
        attributes.  Clone the Attr objects after creating the underlying
        clone.

Element.unlink():  Clean out the attributes here instead of in the base
        class, since this is the only class that will have them.

Element.toxml():  Adjust to create only one AttributeList instance; minor
        efficiency improvement.

_nssplit():  No need to re-import string.

Document.__init__():  No longer needed once constant attributes are
        initialized in the class itself.

Document.createElementNS(),
Document.createAttributeNS():  Use the defined constructors rather than
        directly access the classes.

_get_StringIO():  New function.  Create an output StringIO using the most
        efficient available flavor.

parse(),
parseString():  Import pulldom here instead of in the public namespace of
        the module.
2000-11-21 22:02:22 +00:00
Tim Peters cc78e47bcd Verify that str(a) and repr(a) don't blow up (part of SF patch 102068). 2000-11-14 21:36:07 +00:00
Guido van Rossum 2595a837b5 Typo for Mac code, fixing SF bug 12195. 2000-11-13 20:30:57 +00:00
Guido van Rossum 56baca328f Removing DOS 8x3 support 2000-11-13 17:11:45 +00:00
Greg Ward f6fc875831 Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
use it to generate a dialog for users to specify the command-line (because
providing a command-line with MacPython is so awkward).
2000-11-11 02:47:11 +00:00
Guido van Rossum a66eed62fd Implement the suggestion of bug_id=122070: surround tell() call with
try/except.
2000-11-09 18:05:24 +00:00
Barry Warsaw 17bfef5860 SMTP.connect(): If the socket.connect() raises a socket.error, be sure
to call self.close() to reclaim some file descriptors, the reraise the
exception.  Closes SF patch #102185 and SF bug #119833.
2000-11-08 22:19:47 +00:00
Fred Drake b046b76322 Added test cases to detect regression on SourceForge bug #121965. 2000-11-08 19:51:25 +00:00
Barry Warsaw 7fed217515 This fixes several bug reports concering memory bloating during large
file uploads.

In response to SF bugs 110674 and 119806, and discussions on
python-dev, we are removing the self.lines attribute from the
FieldStorage class.  Specifically touched where methods __init__(),
read_lines_to_eof(), and skip_lines().

No one can remember why self.lines was added.  Technically, it's part
of the public interface for the class, but it was never documented.
It's possible clever or nosy code will break because of this, but it
was decided to remove it and see who complains.

This resolution also closes the second half of the cgi.py entry in PEP
42.  The first half of that PEP concerns specifically binary file
uploads, where there may be no end-of-line marker for a very long
time.  This patch does not address that issue.
2000-11-06 18:46:09 +00:00
Jeremy Hylton 4ebf3be407 a few small optimizations that seem to give a 5-10% speedup; the
further optimization of com_node makes the most difference.
2000-11-06 16:03:52 +00:00
Jeremy Hylton eefaeb78b3 move pruneNext method to correct object (doh!) 2000-11-06 03:47:39 +00:00
Jeremy Hylton 314e3fb215 Change the graph structure to contain the code generator object for
embedded code objects (e.g. functions) rather than the generated code
object.  This change means that the compiler generates code for
everything at the end, rather then generating code for each function
as it finds it.  Implementation note: _convert_LOAD_CONST in
pyassem.py must be change to call getCode().

Other changes follow.  Several changes creates extra edges between
basic blocks to reflect control flow for loops and exceptions.  These
missing edges had gone unnoticed because they do not affect the
current compilation process.

pyassem.py:
    Add _enable_debug() and _disable_debug() methods that print
    instructions and blocks to stdout as they are generated.

    Add edges between blocks for instructions like SETUP_LOOP,
    FOR_LOOP, etc.

    Add pruneNext to get rid of bogus edges remaining after
    unconditional transfer ops (e.g. JUMP_FORWARD)

    Change repr of Block to omit block length.

pycodegen.py:
    Make sure a new block is started after FOR_LOOP, etc.

    Change assert implementation to use RAISE_VARARGS 1 when there is
    no user-specified failure output.

misc.py:
    Implement __contains__ and copy for Set.
2000-11-06 03:43:11 +00:00
Jeremy Hylton a59ac0a7df If a function contains a doc string, remove the doc string node from
the function's body.

If assert is used without an error message, make the AST node None
rather than Name('None').
2000-11-06 03:33:52 +00:00
Fredrik Lundh fad27aee11 Added 38,642 missing characters to the Unicode database (first-last
ranges) -- but thanks to the 2.0 compression scheme, this doesn't add
a single byte to the resulting binaries (!)

Closes bug #117524
2000-11-03 20:24:15 +00:00