Barry Warsaw [Tue, 19 Jun 2001 19:07:46 +0000 (19:07 +0000)]
Better support for RFC 1521 quoted-printable specification, along with
addition of interface for consistency with base64 module. Namely,
encodestring(), decodestring(): New functions which accept a string
object and return a string object. They just wrap the string in
StringIOs and pass them to the encode() and decode() methods
respectively. encodestring() accepts a default argument of quotetabs,
defaulting to zero, which is passed on straight through to encode().
encode(): Fix the bug where an extra newline would always be added to
the output, which prevented an idempotent roundtrip through
encode->decode. Now, if the source string doesn't end in a newline,
then the result string won't end in a newline.
Also, extend the quotetabs argument semantics to include quoting
embedded strings, which is also optional according to the RFC.
test() -> main()
"from quopri import *" also imports encodestring() and decodestring().
Neil Schemenauer [Tue, 19 Jun 2001 15:44:15 +0000 (15:44 +0000)]
Added a MACHDEP_OBJS to the python link. Use this on MacOSX to include
Mac/macglue.c into the core interpreter. This file contains the glue code that
allows extension modules for Mac toolboxes to live in different shared libraries
but still communicate with each other. The glue code is controlled by the
USE_MAC_TOOLBOX_GLUE define. [checked in for Jack]
Jack Jansen [Tue, 19 Jun 2001 15:00:23 +0000 (15:00 +0000)]
Added a MACHDEP_OBJS to the python link. Use this on MacOSX to include
Mac/macglue.c into the core interpreter. This file contains the glue code that
allows extension modules for Mac toolboxes to live in different shared libraries
but still communicate with each other. The glue code is controlled by the
USE_MAC_TOOLBOX_GLUE define.
Tim Peters [Tue, 19 Jun 2001 00:28:47 +0000 (00:28 +0000)]
Taught IDLE's autoident parser that "yield" is a keyword that begins a
stmt. Along w/ the preceding change to keyword.py, making all this work
w/ a future-stmt just looks harder and harder.
Tim Peters [Mon, 18 Jun 2001 22:27:39 +0000 (22:27 +0000)]
Added "i" and "l" to the list of std-mode struct codes that don't range-
check correctly on pack(). While these were checking OK on my 32-bit box,
Mark Favas reported failures on a 64-bit box (alas, easy to believe).
Tim Peters [Mon, 18 Jun 2001 19:21:11 +0000 (19:21 +0000)]
SF bug 434186: 0x80000000/2 != 0x80000000>>1
i_divmod: New and simpler algorithm. Old one returned gibberish on most
boxes when the numerator was -sys.maxint-1. Oddly enough, it worked in the
release (not debug) build on Windows, because the compiler optimized away
some tricky sign manipulations that were incorrect in this case.
Makes you wonder <wink> ...
Bugfix candidate.
Tim Peters [Sun, 17 Jun 2001 21:57:17 +0000 (21:57 +0000)]
Clarification in the fp appendix suggested on c.l.py by Michael Chermside.
Also replaced a *star* style emphasis in the Representation Error section
with an \emph{} thingie.
Martin v. Löwis [Sun, 17 Jun 2001 07:05:43 +0000 (07:05 +0000)]
Synchronize with 1.13 of PyXML:
Allow application to set a new content handler and lex_prop handler during
parsing. Closes bug #433761.
Small hack to make expat be ignored in Jython.
Fred Drake [Sat, 16 Jun 2001 21:02:31 +0000 (21:02 +0000)]
Instead of initializing & interning the strings passed to the profile
and trace functions lazily, which incurs extra argument pushing and checks
in the C overhead for profiling/tracing, create the strings semi-lazily
when the Python code first registers a profile or trace function. This
simplifies the trampoline into the profile/trace functions.
Tim Peters [Sat, 16 Jun 2001 05:11:17 +0000 (05:11 +0000)]
SF bug 433228: repr(list) woes when len(list) big.
Gave Python linear-time repr() implementations for dicts, lists, strings.
This means, e.g., that repr(range(50000)) is no longer 50x slower than
pprint.pprint() in 2.2 <wink>.
I don't consider this a bugfix candidate, as it's a performance boost.
Added _PyString_Join() to the internal string API. If we want that in the
public API, fine, but then it requires runtime error checks instead of
asserts.
Tim Peters [Sat, 16 Jun 2001 00:09:28 +0000 (00:09 +0000)]
SF bug 433228: repr(list) woes when len(list) big
call_object: If the object isn't callable, display its type in the error
msg rather than its repr.
Bugfix candidate.
Thomas Wouters [Fri, 15 Jun 2001 12:05:44 +0000 (12:05 +0000)]
Forward-port revision 2.24.2.4 from the release21-maint branch:
Protect several more uses of constants with #ifdefs; these are necessary on
(at least) SCO OpenServer 5. Fixes a non-SF-submitted bugreport by Michael
Kent.
Tim Peters [Thu, 14 Jun 2001 04:56:19 +0000 (04:56 +0000)]
PyLong_From{Unsigned,}Long: count the # of digits first, so no more space
is allocated than needed (used to allocate 80 bytes of digit space no
matter how small the long input). This also runs faster, at least on 32-
bit boxes.
Tim Peters [Thu, 14 Jun 2001 00:55:41 +0000 (00:55 +0000)]
Add tests of PyLong_{As,From}{Unsigned,}Long. These are very much like
the new PyLong_{As,From}{Unsigned,}LongLong tests, so the bulk of the
code is in the new #include file testcapi_long.h, which generates
different code depending on how macros are set. This sucks, but I couldn't
think of anything that sucked less.
UNIX headache? If we still maintain dependencies by hand, someone who
knows what they're doing should teach whatever needs it that
_testcapimodule.c includes testcapi_long.h.
Tim Peters [Wed, 13 Jun 2001 22:45:27 +0000 (22:45 +0000)]
Generalize the new qQ std-mode tests to all int codes (bBhHiIlLqQ).
Unfortunately, the std-mode bBhHIL codes don't do any range-checking; if
and when some of those get fixed, remove their letters from the
IntTester.BUGGY_RANGE_CHECK string. In the meantime, a msg saying that
range-tests are getting skipped is printed to stdout whenever one is
skipped.
Tim Peters [Wed, 13 Jun 2001 21:09:15 +0000 (21:09 +0000)]
_PyLong_FromByteArray: changed decl of "carry" to match "thisbyte". No
semantic change, but a bit clearer and may help a really stupid compiler
avoid pointless runtime length conversions.
Tim Peters [Wed, 13 Jun 2001 00:35:57 +0000 (00:35 +0000)]
longobject.c:
Replaced PyLong_{As,From}{Unsigned,}LongLong guts with calls
to _PyLong_{As,From}ByteArray.
_testcapimodule.c:
Added strong tests of PyLong_{As,From}{Unsigned,}LongLong.
Fixes SF bug #432552 PyLong_AsLongLong() problems.
Possible bugfix candidate, but the fix relies on code added to longobject
to support the new q/Q structmodule format codes.
Tim Peters [Tue, 12 Jun 2001 20:10:01 +0000 (20:10 +0000)]
The merest start of a test for the PyLong_{As,From}{Unsigned,}LongLong()
functions. I intend to replace their guts with calls to the new
_PyLong_{As,From}ByteArray() functions, but AFAICT there's no tests for
them at all now; I also suspect PyLong_AsLongLong() isn't catching all
overflow cases, but without a std test to demonstrate that why should you
believe me <wink>.
Fred Drake [Tue, 12 Jun 2001 13:31:37 +0000 (13:31 +0000)]
Make the option processing more robust.
Add a -F option similar to "cvs commit -F <file>".
Add a -t option to allow specifying the prefix to the directory into which
the docs should be unpacked (useful when I start trying out new styles for
the presentation).
Fred Drake [Tue, 12 Jun 2001 03:31:56 +0000 (03:31 +0000)]
Fixed reference to table notes for {}.keys() and {}.items() -- these
references did not get updated when the notes were renumbered in a
previous update.
Tim Peters [Tue, 12 Jun 2001 01:22:22 +0000 (01:22 +0000)]
Added q/Q standard (x-platform 8-byte ints) mode in struct module.
This completes the q/Q project.
longobject.c _PyLong_AsByteArray: The original code had a gross bug:
the most-significant Python digit doesn't necessarily have SHIFT
significant bits, and you really need to count how many copies of the sign
bit it has else spurious overflow errors result.
test_struct.py: This now does exhaustive std q/Q testing at, and on both
sides of, all relevant power-of-2 boundaries, both positive and negative.
Tim Peters [Mon, 11 Jun 2001 21:23:58 +0000 (21:23 +0000)]
Two new private longobject API functions,
_PyLong_FromByteArray
_PyLong_AsByteArray
Untested and probably buggy -- they compile OK, but nothing calls them
yet. Will soon be called by the struct module, to implement x-platform
'q' and 'Q'.
If other people have uses for them, we could move them into the public API.
See longobject.h for usage details.
Fred Drake [Mon, 11 Jun 2001 15:21:48 +0000 (15:21 +0000)]
Fixed parameter order for os.popen2(), os.popen3(), and os.popen(4). Added
a reference to these functions and popen() from the "Process Management"
section.
Tim Peters [Sun, 10 Jun 2001 23:40:19 +0000 (23:40 +0000)]
Initial support for 'q' and 'Q' struct format codes: for now, only in
native mode, and only when config #defines HAVE_LONG_LONG. Standard mode
will eventually treat them as 8-byte ints across all platforms, but that
likely requires a new set of routines in longobject.c first (while
sizeof(long) >= 4 is guaranteed by C, there's nothing in C we can rely
on x-platform to hold 8 bytes of int, so we'll have to roll our own;
I'm thinking of a simple pair of conversion functions, Python long
to/from sized vector of unsigned bytes; that may be useful for GMP
conversions too; std q/Q would call them with size fixed at 8).
test_struct.py: In addition to adding some native-mode 'q' and 'Q' tests,
got rid of unused code, and repaired a non-portable assumption about
native sizeof(short) (it isn't 2 on some Cray boxes).
libstruct.tex: In addition to adding a bit of 'q'/'Q' docs (more needed
later), removed an erroneous footnote about 'I' behavior.
Tim Peters [Sun, 10 Jun 2001 18:58:26 +0000 (18:58 +0000)]
SF bug 431772: traceback.print_exc() causes traceback
Patch from Michael Hundson.
format_exception_only() blew up when trying to report a SyntaxError
from a string input (line is None in this case, but it assumed a string).
Bugfix candidate.
Tim Peters [Sat, 9 Jun 2001 09:26:21 +0000 (09:26 +0000)]
SF bug 430991: wrong co_lnotab
Armin Rigo pointed out that the way the line-# table got built didn't work
for lines generating more than 255 bytes of bytecode. Fixed as he
suggested, plus corresponding changes to pyassem.py, plus added some
long overdue docs about this subtle table to compile.c.
Bugfix candidate (line numbers may be off in tracebacks under -O).
Martin v. Löwis [Sat, 9 Jun 2001 07:34:05 +0000 (07:34 +0000)]
Patch #424475: Speed-up tp_compare usage, by special-casing the common
case of objects with equal types which support tp_compare. Give
type objects a tp_compare function.
Also add c<0 tests before a few PyErr_Occurred tests.
Fred Drake [Fri, 8 Jun 2001 16:24:58 +0000 (16:24 +0000)]
Text from Tim & Guido discussing floating point arithmetic and what users
need to understand about the binary & decimal fp, so that representation
weirdness is documented somewhere. This makes it easier to repond to "bug"
reports caused by user confusion & ignorance of the issues.
Fred Drake [Fri, 8 Jun 2001 05:04:19 +0000 (05:04 +0000)]
In the section on extending the profiler, add some additional discussion
about setting up the dispatch table, and update the OldProfile and
HotProfile classes to the current implementations, showing the adjusted
construction for the dispatch table.
Fred Drake [Fri, 8 Jun 2001 04:33:09 +0000 (04:33 +0000)]
call_trace(): Add an additional parameter -- pointer to a PyObject*
that should be used to cache an interned version of the event
string passed to the profile/trace function. call_trace() will
create interned strings and cache them in using the storage
specified by this additional parameter, avoiding a lot of string
object creation at runtime when using the profiling or tracing
functions.
All call sites are modified to pass the additional parameter, and four
static PyObject* variables are allocated to cache the interned string
objects.
Fred Drake [Fri, 8 Jun 2001 04:25:24 +0000 (04:25 +0000)]
Performance improvements to the profiler:
Ensure that all the default timers are called as functions, not an
expensive method wrapper around a variety of different functions.
Agressively avoid dictionary lookups.
Modify the dispatch scheme (Profile.trace_dispatch_*(), where * is not
'call', 'exception' or 'return') so that the callables dispatched to
are simple functions and not bound methods -- this reduces the number
of layers of Python call machinery that gets touched.
Remove a couple of duplicate imports from the "if __name__ == ..."
section.
Acknowledge the existence of the 'platform' file, generated by the
Makefile and used by the setup.py script. Ignore it in .cvsignore;
remove it in "make clobber".