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.
Anonymous SF bug report #128053 point out that the #ifdef for
including "tmpfile" in the posix_methods[] array is wrong -- should be
HAVE_TMPFILE, not HAVE_TMPNAM.
Tim discovered another "bug" in my get_line() code: while the comments
said that n<0 was invalid, it was in fact still called with n<0 (when
PyFile_GetLine() was called with n<0). In that case fortunately
executed the same code as for n==0.
Changed the comment to admit this fact, and changed Tim's MS speed
hack code to use 'n <= 0' as the criteria for the speed hack.
Tim Peters [Mon, 8 Jan 2001 00:53:12 +0000 (00:53 +0000)]
Fiddled ms_getline_hack after talking w/ Guido: made clearer that the
code duplication is to let us get away without a realloc whenever possible;
boosted the init buf size (the cutoff at which we *can* get away without
a realloc) from 100 to 200 so that more files can enjoy this boost; and
allowed other threads to run in all cases. The last two cost something,
but not significantly: in my fat test case, less than a 1% slowdown total.
Since my test case has a great many short lines, that's probably the worst
slowdown, too. While the logic barely changed, there were lots of edits.
This also gets rid of the reference to fp->_cnt, so the last platform
assumption being made here is that fgets doesn't overwrite bytes
capriciously (== beyond the terminating null byte it must write).
Tim Peters [Sun, 7 Jan 2001 21:19:34 +0000 (21:19 +0000)]
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.
Tim noticed that I had botched get_line_raw(). Looking again, I
realized that this behavior is already present in PyFile_GetLine(),
which is the only place that needs it. A little refactoring of that
function made get_line_raw() redundant.
Fred Drake [Sun, 7 Jan 2001 06:02:19 +0000 (06:02 +0000)]
Add more regression tests, including for the import statement variations.
These will detect regression on SF bug #127271 and other import statement
bugs.
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.
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.
Fred Drake [Fri, 5 Jan 2001 06:44:19 +0000 (06:44 +0000)]
Update explanation of the set_location() method to indicate that in
BTree databases, the key need not be in the database. Also, tell about
the exception if the key is not in the DB for other DB types.
Fred Drake [Fri, 5 Jan 2001 05:57:04 +0000 (05:57 +0000)]
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?)
Fred Drake [Fri, 5 Jan 2001 05:54:41 +0000 (05:54 +0000)]
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.
Fred Drake [Thu, 4 Jan 2001 22:33:02 +0000 (22:33 +0000)]
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().)
Fred Drake [Thu, 4 Jan 2001 15:11:48 +0000 (15:11 +0000)]
__rcmp__() description: Changed to indicate that this is no longer
supported as of Python 2.1. We still need to
have an entry for this since it is reasonable
for users to want to understand existing code.
Fred Drake [Thu, 4 Jan 2001 14:18:55 +0000 (14:18 +0000)]
Based on comments from Guido, do not describe bisect() and insert() as
being "for backward compatibility." Also revert to using bisect() in the
example, since Guido thinks that is the best recommendation for typical
usage.
Make instances a new style number type. See PEP 208 for details. Instance
types no longer get special treatment from abstract.c so more number number
methods have to be implemented.
Patch #103012: Update fpectlmodule for current glibc;
The _setfpucw() function/macro doesn't seem to exist any more;
instead there's an _FPU_SETCW macro.
Jeremy Hylton [Wed, 3 Jan 2001 23:53:31 +0000 (23:53 +0000)]
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.
Jeremy Hylton [Wed, 3 Jan 2001 23:52:36 +0000 (23:52 +0000)]
Revised implementation of CALL_FUNCTION and friends.
More revision still needed.
Much of the code that was in the mainloop was moved to a series of
helper functions. PyEval_CallObjectWithKeywords was split into two
parts. The first part now only does argument handling. The second
part is now named call_object and delegates the call to a
call_(function,method,etc.) helper.
XXX The call_XXX helper functions should be replaced with tp_call
functions for the respective types.
The CALL_FUNCTION implementation contains three kinds of optimization:
1. fast_cfunction and fast_function are called when the arguments on
the stack can be passed directly to eval_code2() without copying
them into a tuple.
2. PyCFunction objects are dispatched immediately, because they are
presumed to occur more often than anything else.
3. Bound methods are dispatched inline. The method object contains a
pointer to the function object that will be called. The function
is called from within the mainloop, which may allow optimization #1
to be used, too.
The extened call implementation -- f(*args) and f(**kw) -- are
implemented as a separate case in the mainloop. This allows the
common case of normal function calls to execute without wasting time
on checks for extended calls, although it does introduce a small
amount of code duplication.
Also, the unused final argument of eval_code2() was removed. This is
probably the last trace of the access statement :-).
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.
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.
Thomas Wouters [Sun, 31 Dec 2000 22:52:59 +0000 (22:52 +0000)]
Change documentation of 'else' clause of 'try/except' to make clear that it
doesn't get triggered by 'return', 'break' or 'continue'. If the
'try-inside-continue' patch does not get accepted before next release, the
'or continue' should be removed ;P
Tim Peters [Sat, 30 Dec 2000 22:21:22 +0000 (22:21 +0000)]
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.
Tim Peters [Fri, 29 Dec 2000 02:17:56 +0000 (02:17 +0000)]
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.
Tim Peters [Fri, 29 Dec 2000 02:06:45 +0000 (02:06 +0000)]
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.