Commit Graph

3738 Commits

Author SHA1 Message Date
Tim Peters 58c82f0b56 Assorted xreadlines problems:
Wasn't built on Windows; not in config.c either.
    Module init function missing DL_EXPORT magic.
    test_xreadline output file obviously wrong (started w/ "test_xrl").
    test program very unclear about what was expected.
2001-01-09 23:26:39 +00:00
Guido van Rossum 07b78a8778 Test for xreadline. 2001-01-09 21:47:44 +00:00
Andrew M. Kuchling 705a3ada6f Check in patch #102971: if library_dirs is a string, split it using
os.pathsep
2001-01-09 03:15:47 +00:00
Andrew M. Kuchling 9d56cd100e Patch #102953: Fix bug #125452, where shlex.shlex hangs when it
encounters a string with an unmatched quote, by adding a check for
    EOF in the 'quotes' state.
2001-01-09 03:01:15 +00:00
Fred Drake e1fd5260ea GetoptError is always initialized with exactly two parameters, so simplify
the constructor.
2001-01-08 15:39:32 +00:00
Moshe Zadka b2a0a838e0 Fixed bug which caused HTTPS not to work at all with string URLs 2001-01-08 07:09:25 +00:00
Fred Drake daa823ad9a Text.__init__(): Make sure the data parameter is a string (8-bit or
Unicode); raise TypeError if not.

This closes SF bug #126866.
2001-01-08 04:04:34 +00:00
Tim Peters 3a55f950a9 18 isn't a prime (duh). 2001-01-08 01:17:26 +00:00
Tim Peters 86821b2563 MS Win32 .readline() speedup, as discussed on Python-Dev. This is a tricky
variant that never needs to "search from the right".
Also fixed unlikely memory leak in get_line, if string size overflows INTMAX.
Also new std test test_bufio to make sure .readline() works.
2001-01-07 21:19:34 +00:00
Fred Drake e3fb18c1c4 Add more regression tests, including for the import statement variations.
These will detect regression on SF bug #127271 and other import statement
bugs.
2001-01-07 06:02:19 +00:00
Marc-André Lemburg 1109db443e This patch adds a new feature to the builtin charmap codec:
the mapping dictionaries can now contain 1-n mappings, meaning
that character ordinals may be mapped to strings or Unicode object,
e.g. 0x0078 ('x') -> u"abc", causing the ordinal to be replaced by
the complete string or Unicode object instead of just one character.

Another feature introduced by the patch is that of mapping oridnals to
the emtpy string. This allows removing characters.

The patch is different from patch #103100 in that it does not cause a
performance hit for the normal use case of 1-1 mappings.

Written by Marc-Andre Lemburg, copyright assigned to Guido van Rossum.
2001-01-06 15:09:57 +00:00
Guido van Rossum 4795524101 Speed it up by using readlines(sizehint). It's still slower than
other ways of reading input. :-(

In the process, I added an optional bufsize argument to the input()
function and the FileInput class.
2001-01-05 14:44:39 +00:00
Fred Drake a4d18a008f Add test cases based on RFC 1808. So now we actually have a test suite
the urljoin() function, which exercises the urlparse() and urlunparse()
functions as side effects.

(Moshe, why did we have perfectly empty tests checked in for this?)
2001-01-05 05:57:04 +00:00
Fred Drake 867952f6e4 urlunparse(): Do not add a leading slash to the path if it is empty.
urljoin():  Make this conform to RFC 1808 for all examples given in that
            RFC (both "Normal" and "Abnormal"), so long as that RFC does
            not conflict the older RFC 1630, which also specified
            relative URL resolution.

This closes SF bug #110832 (Jitterbug PR#194).
2001-01-05 05:54:41 +00:00
Fred Drake 1a7aab70d1 When a PyCFunction that takes only positional parameters is called with
an empty keywords dictionary (via apply() or the extended call syntax),
the keywords dict should be ignored.  If the keywords dict is not empty,
TypeError should be raised.  (Between the restructuring of the call
machinery and this patch, an empty dict in this situation would trigger
a SystemError via PyErr_BadInternalCall().)

Added regression tests to detect errors for this.
2001-01-04 22:33:02 +00:00
Neil Schemenauer 0ee7d8233f No more RCmp. 2001-01-04 01:36:50 +00:00
Neil Schemenauer 623116a870 Sequence repeat works now for in-place multiply with an integer type
as the left operand.  I don't know if this is a feature or a bug.
2001-01-04 01:36:25 +00:00
Neil Schemenauer aa726ba991 __rcmp__ no longer gets called on instances. Remove the test for it. 2001-01-04 01:34:52 +00:00
Neil Schemenauer 38f0223c9c Numbers no longer compare smaller than all other types. Fix the only
part of the testsuite that breaks.  The old behavior may be restored.
2001-01-04 01:33:41 +00:00
Jeremy Hylton 5ab366119e Actually call the object with an __call__ method, instead of just
checking if it is callable.  This is the only place in the test suite
where an __call__ method is called.
2001-01-03 23:53:31 +00:00
Marc-André Lemburg a866df806d This patch changes the default behaviour of the builtin charmap
codec to not apply Latin-1 mappings for keys which are not found
in the mapping dictionaries, but instead treat them as undefined
mappings.

The patch was originally written by Martin v. Loewis with some
additional (cosmetic) changes and an updated test script
by Marc-Andre Lemburg.

The standard codecs were recreated from the most current files
available at the Unicode.org site using the Tools/scripts/gencodec.py
tool.

This patch closes the bugs #116285 and #119960.
2001-01-03 21:29:14 +00:00
Neil Schemenauer e7e694fd22 Use == rather than cmp(). The return value of cmp() is not well defined when
comparing different types.
2001-01-03 02:13:26 +00:00
Neil Schemenauer 38796d07a5 Use numbers that can be accurately represented on binary machines. I hope
this works on all platforms.
2001-01-03 01:52:11 +00:00
Andrew M. Kuchling 6d0cee1170 Add forgotten import 2001-01-02 20:56:42 +00:00
Guido van Rossum 352ca8cbce Duh. Instead of string.whitespace and string.digits, use isspace()
and isdigit() methods.
2001-01-02 20:36:32 +00:00
Neil Schemenauer fd288c7cd5 Add more tests for compare and coercion in preparation for the coercion
overhaul.  Closes SF patch #102878.
2001-01-02 16:30:31 +00:00
Guido van Rossum a659efe5c7 Patch by kragen@pobox.com: When tracing is turned on, lines shorter
than a pixel don't get drawn at all. If you're building long curves
made of such lines, this is a bad thing.
2001-01-01 19:11:07 +00:00
Andrew M. Kuchling ad4a558af8 Added test case for legal DOM children 2000-12-31 04:03:27 +00:00
Andrew M. Kuchling 291ed4fb3f Patch #102485 ] Check for legal children when adding children to a DOM node 2000-12-31 03:50:23 +00:00
Tim Peters 1a4d77b252 Christmas present to myself: changed regrtest in two ways:
1. When running in verbose mode, if any test happens to pass, print
   a warning that the apparent success may be bogus (stdout isn't
   compared in verbose mode).  Been fooled by that too often.
2. When a test fails because the expected stdout doesn't match the
   actual stdout, print as much of stdout as did match before the
   first failing write.  Else we get failures of the form "expected
   'a', got 'b'" and a glance at the expected output file shows
   500 instances of 'a' -- no idea where it failed, and, as in #1,
   trying to run in verbose mode instead doesn't help because
   stdout isn't compared then.
2000-12-30 22:21:22 +00:00
Tim Peters d31b6328e1 getopt used to sort the long option names, in an attempt to simplify
the logic.  That resulted in a bug.  My previous getopt checkin repaired
the bug but left the sorting.  The solution is significantly simpler if
we don't bother sorting at all, so this checkin gets rid of the sort and
the code that relied on it.
2000-12-29 02:17:56 +00:00
Tim Peters 36cdad12dd Fred, THIS NEEDS DOCS! The function docstrings tell the tale.
Christmas present to myself:  the bisect module didn't define what
happened if the new element was already in the list.  It so happens
that it inserted the new element "to the right" of all equal elements.
Since it wasn't defined, among other bad implications it was a mystery
how to use bisect to determine whether an element was already in the
list (I've seen code that *assumed* "to the right" without justification).
Added new methods bisect_left and insort_left that insert "to the left"
instead; made the old names bisect and insort aliases for the new names
bisect_right and insort_right; beefed up docstrings to explain what
these actually do; and added a std test for the bisect module.
2000-12-29 02:06:45 +00:00
Martin v. Löwis 011ea47577 Merge with 1.8 of pulldom.py:
Use types.UnicodeType if available, not type(u"").
2000-12-28 18:43:02 +00:00
Martin v. Löwis 156c337f66 Merge changes up to 1.10 from PyXML:
- implement hasAttribute and hasAttributeNS (1.7)
- Node.replaceChild():  Update the sibling nodes to point to newChild.  Set
  the .nextSibling attribute on oldChild instead of adding a .newChild
  attribute (1.9).
2000-12-28 18:40:56 +00:00
Guido van Rossum 7dd06966cb Make Traceback header conform to new traceback ("innermost last" ->
"most recent call last").
2000-12-27 19:12:58 +00:00
Tim Peters dd699b62c5 Fix for SF bug
https://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470
"getopt long option handling broken".  Tossed the excruciating logic in
long_has_args in favor of something obviously correct.
2000-12-27 08:05:05 +00:00
Tim Peters da7bf4e236 Add test case for SF bug
https://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470
2000-12-27 08:03:20 +00:00
Andrew M. Kuchling 0cc87f37b3 Make isspace(chr(32)) return true 2000-12-26 16:07:59 +00:00
Fred Drake 1e0611b208 The "context" parameter to the ExternalEntityRefParameter exposes internal
information from the Expat library that is not part of its public API.
Do not print this information as the format of the string may (and will)
change as Expat evolves.

Add additional tests to make sure the ParserCreate() function raises the
right exceptions on illegal parameters.
2000-12-23 22:12:07 +00:00
Fred Drake 9a1a7dda8f The regression test for the regex module should not trip the deprecation
warning for that module, so suppress just that one warning.
2000-12-23 22:08:27 +00:00
Andrew M. Kuchling 49d27c82e6 Remove superfluous semicolons 2000-12-23 14:20:24 +00:00
Andrew M. Kuchling 9f5eeebb26 Wrapper for _curses_panel module; currently this adds nothing extra
beyond what's in _curses_panel
2000-12-22 21:58:29 +00:00
Andrew M. Kuchling 04a45e9bb1 Patch #102492, fixing bug #116677:
give minidom.py behaviour that complies with the DOM Level 1 REC,
    which says that when a node newChild is added to the tree, "if the
    newChild is already in the tree, it is first removed."

    pulldom.py is patched to use the public minidom interface instead
    of setting .parentNode itself.  Possibly this reduces pulldom's
    efficiency; someone else will have to pronounce on that.
2000-12-20 14:47:24 +00:00
Andrew M. Kuchling c867f74a10 Change expected message for ValueError, fixing bug #126400 2000-12-20 00:55:46 +00:00
Andrew M. Kuchling 8fe2c12d49 Add forgotten initialization. Fixes bug #120994, "Traceback with
DISTUTILS_DEBUG set"
2000-12-20 00:48:12 +00:00
Guido van Rossum 7292e921fc Adding a warning about the regsub module. This also disables further
warnings in this same module, to prevent getting a warning about
importing regex (we *know* that it's obsolete :-).
2000-12-19 18:25:58 +00:00
Guido van Rossum fad81f0838 Be explicit about scheme_chars -- string.letters is locale dependent
so we can't use it.

While I'm at it, got rid of string module use.  (Found several new
hard special cases for a hypothetical conversion tool: from string
import join, find, rfind; and a local assignment "find=string.find".)
2000-12-19 16:48:13 +00:00
Guido van Rossum 70f128861f Use binary mode to open "wave" files. 2000-12-19 06:32:57 +00:00
Guido van Rossum d1db30b7b5 Improve error messages for invalid warning arguments; don't raise
exceptions but always print a warning message.
2000-12-19 03:04:50 +00:00
Guido van Rossum 5aff7752eb Make string.translate(s, table) work for Unicode s. Two things are
required to work around restrictions on the arguments of
u.translate():

1) don't pass the deletions argument if it's empty;

2) convert table to Unicode if s is Unicode.

This fixes SF bug #124060.
2000-12-19 02:39:08 +00:00
Guido van Rossum 8b26454273 Test more split argument combinations:
1) multi-char separator
2) multi-char separator that only occurs at last position
3) all of the above with mixed Unicode and 8-bit-string arguments
2000-12-19 02:22:31 +00:00
Guido van Rossum 8b74b15b92 Test some Unicode pickling endcases. 2000-12-19 02:01:12 +00:00
Guido van Rossum a31b4ef7c5 Minimal fix for the complaints about pickling Unicode objects. (SF
bugs #126161 and 123634).

The solution doesn't use the unicode-escape encoding; that has other
problems (it seems not 100% reversible).  Rather, it transforms the
input Unicode object slightly before encoding it using
raw-unicode-escape, so that the decoding will reconstruct the original
string: backslash and newline characters are translated into their
\uXXXX counterparts.

This is backwards incompatible for strings containing backslashes, but
for some of those strings, the pickling was already broken.
2000-12-19 01:29:00 +00:00
Neil Schemenauer 99664e455b gdbm.open() no longer accepts garbage in the flags string. Fix the tests. 2000-12-18 17:28:05 +00:00
Fred Drake 95b4ec5fbe Do not assume that types.UnicodeType exists; we might be running in an old
version of Python.  ;-(
2000-12-16 01:45:11 +00:00
Fred Drake 1402ab2cb9 Use the string module instead of string methods; this should still work
with Python 1.5.2 for now.
2000-12-16 01:43:40 +00:00
Fred Drake f16527c863 Typo caught by /F -- thanks! 2000-12-15 23:56:43 +00:00
Guido van Rossum 2a862c614d Python part of the warnings subsystem. 2000-12-15 21:59:53 +00:00
Fred Drake 1703cf662c Before calling traceback.print_exc(), call sys.stdout.flush(). This makes
it much easier to see where things went wrong.
2000-12-15 21:31:59 +00:00
Fred Drake 279aa6cabc DOMException.__init__(): Remember to pass self to Exception.__init__(). 2000-12-15 21:07:59 +00:00
Guido van Rossum 5080b33046 Comment out a debugging print statement that triggered a complaint in
c.l.py.
2000-12-15 20:08:39 +00:00
Guido van Rossum e6e03eafed Get rid of string functions. 2000-12-15 15:49:08 +00:00
Guido van Rossum c80f182dc4 Get rid of string functions. References to string.whitespace,
string.digits are left.
2000-12-15 15:37:48 +00:00
Guido van Rossum 34735a6682 Get rid of string functions.
There should really be a little tool to help with this -- it's rather
tedious and there are lots of special cases!
2000-12-15 15:09:42 +00:00
Guido van Rossum b2493f855a Get rid of string functions, except maketrans() (which is *not*
obsolete!).

Fix a bug in ftpwrapper.retrfile() where somehow ftplib.error_perm was
assumed to be a string.  (The fix applies str().)

Also break some long lines and change the output from test() slightly.
2000-12-15 15:01:37 +00:00
Andrew M. Kuchling 4d192b37ec Add test case for error message raised by bad % format character
(Oh, look, it adds another little utility function for testing)
2000-12-15 13:09:06 +00:00
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