Commit Graph

20336 Commits

Author SHA1 Message Date
Tim Peters b1a37c0196 Removed more comments that didn't make much sense.
Made the presence/absence of a semicolon after macros consistent.
2001-10-17 03:56:45 +00:00
Tim Peters 6605c64c83 Removed obsolete comments about confused string refcount tricks (Jeremy
removed the tricks).

Changed the ENTER/LEAVE_ZLIB macros so as not to create a new block (a
new block is neither necessary nor helpful).
2001-10-17 03:43:54 +00:00
Fred Drake 2a2d970ef9 Remove unused import; reported by Neal Norwitz. 2001-10-17 01:51:04 +00:00
Fred Drake d10ed8b179 Minor code cleanups based on comments from Neal Norwitz. 2001-10-17 01:49:50 +00:00
Guido van Rossum 89e000edb7 YAPC. 2001-10-17 00:17:52 +00:00
Jeremy Hylton ba3dd9990f Undo needless INCREF chicanery introduced by SF patch #450702.
Apparently this patch (rev 2.41) replaced all the good old "s#"
    formats in PyArg_ParseTuple() with "S".  Then it did
    PyString_FromStringAndSize() to get back the values setup by the
    "s#" format.  It also incref'd and decref'd the string obtained by
    "S" even though the argument tuple had a reference to it.

Replace PyString_AsString() calls with PyString_AS_STRING().

    A good rule of thumb -- if you never check the return value of
    PyString_AsString() to see if it's NULL, you ought to be using the
    macro <wink>.
2001-10-16 23:26:08 +00:00
Jeremy Hylton 9d620d018c Simplify and fix error handling for most cases.
Many functions used a local variable called return_error, which was
initialized to zero.  If an error occurred, it was set to true.  Most
of the code paths checked were only executed if return_error was
false.  goto is clearer.

The code also seemed to be written under the curious assumption that
calling Py_DECREF() on a local variable would assign the variable to
NULL.  As a result, more of the error-exit code paths returned an
object that had a reference count of zero instead of just returning
NULL.  Fixed the code to explicitly assign NULL after the DECREF.

A bit more reformatting, but not much.

XXX Need a much better test suite for zlib, since it the current tests
don't exercise any of this broken code.
2001-10-16 23:02:32 +00:00
Tim Peters 61acf067ac SF bug [#471111] inspect.getframeinfo() needs docs.
TeX-ified its docstring.
2001-10-16 23:01:06 +00:00
Jeremy Hylton 4990000077 More reformatting. 2001-10-16 21:59:35 +00:00
Jeremy Hylton 0965e084cd Add zlib_error() helper.
It sets a ZlibError exception, using the msg from the z_stream pointer
if one is available.
2001-10-16 21:56:09 +00:00
Guido van Rossum 2c40adb1e4 Fix a bug in the previous checkin. The wrong bootstrap function was
passed to _beginthread().
2001-10-16 21:50:04 +00:00
Guido van Rossum 9074ef6081 Add fix for getattr(obj, name, default). Rearrange a few things. 2001-10-16 21:34:49 +00:00
Guido van Rossum d892357bf7 SF patch #471852 (anonymous) notes that getattr(obj, name, default)
masks any exception, not just AttributeError.  Fix this.
2001-10-16 21:31:32 +00:00
Jeremy Hylton 9bc9d66eb1 Remove many calls to set MemoryError exceptions.
When PyString_FromStringAndSize() and _PyString_Resize() fail, they
set an exception.  There's no need to set a new exception.
2001-10-16 21:23:58 +00:00
Jeremy Hylton 9714f99d60 Reformat!
Consistently indent 4 spaces.
Use whitespace around operators.
Put braces in the right places.
2001-10-16 21:19:45 +00:00
Guido van Rossum 3c28863e08 Partial patch from SF #452266, by Jason Petrone.
This changes Pythread_start_thread() to return the thread ID, or -1
for an error.  (It's technically an incompatible API change, but I
doubt anyone calls it.)
2001-10-16 21:13:49 +00:00
Jeremy Hylton 6f543b606d Add note about new zlib feature. 2001-10-16 20:42:52 +00:00
Jeremy Hylton 511e2cacc4 [ #403753 ] zlib decompress; uncontrollable memory usage
Mostly by Toby Dickenson and Titus Brown.

Add an optional argument to a decompression object's decompress()
method.  The argument specifies the maximum length of the return
value.  If the uncompressed data exceeds this length, the excess data
is stored as the unconsumed_tail attribute.  (Not to be confused with
unused_data, which is a separate issue.)

Difference from SF patch: Default value for unconsumed_tail is ""
rather than None.  It's simpler if the attribute is always a string.
2001-10-16 20:39:49 +00:00
Guido van Rossum 7a59445e37 Document required return values -1, 0, 1 for tp_compare handler, as
suggested in SF patch #424475.  Also document exception return.
2001-10-16 20:32:05 +00:00
Tim Peters c993315b18 SF bug [#468061] __str__ ignored in str subclass.
object.c, PyObject_Str:  Don't try to optimize anything except exact
string objects here; in particular, let str subclasses go thru tp_str,
same as non-str objects.  This allows overrides of tp_str to take
effect.

stringobject.c:
+ string_print (str's tp_print):  If the argument isn't an exact string
  object, get one from PyObject_Str.

+ string_str (str's tp_str):  Make a genuine-string copy of the object if
  it's of a proper str subclass type.  str() applied to a str subclass
  that doesn't override __str__ ends up here.

test_descr.py:  New str_of_str_subclass() test.
2001-10-16 20:18:24 +00:00
Guido van Rossum dfefc06fe0 Add Shane. 2001-10-16 20:13:53 +00:00
Guido van Rossum ae9e7960d3 SF patch #471839: Bug when extensions import extensions (Shane Hathaway)
When an extension imports another extension in its
    initXXX() function, the variable _Py_PackageContext is
    prematurely reset to NULL. If the outer extension then
    calls Py_InitModule(), the extension is installed in
    sys.modules without its package name. The
    manifestation of this bug is a "SystemError:
    _PyImport_FixupExtension: module <package>.<extension>
    not loaded".

    To fix this, importdl.c just needs to retain the old
    value of _Py_PackageContext and restore it after the
    initXXX() method is called. The attached patch does this.

    This patch applies to Python 2.1.1 and the current CVS.
2001-10-16 20:07:34 +00:00
Guido van Rossum b6aca6afe2 Fix SF bug #459767: ftplib fails with files > 2GB
size(), parse150(): try int() first, catch OverflowError, fall back to
long().
2001-10-16 19:45:52 +00:00
Fred Drake 5bf1ecd503 Update the description of PyTrace_EXCEPT. 2001-10-16 19:23:55 +00:00
Fred Drake ab9b238ced Fix a few usage and style-guide conformance issues. 2001-10-16 19:22:51 +00:00
Jeremy Hylton 3eb46f3a5d Must terminate the Pickler_members[] and Pickler_getsets with NULL. 2001-10-16 17:10:49 +00:00
Guido van Rossum b85a8b7bc7 Refactored the update_slot() code a bit to be hopefully slightly more
efficient:

- recurse down subclasses only once rather than for each affected
  slot;

- short-circuit recursing down subclasses when a subclass has its own
  definition of the name that caused the update_slot() calls in the
  first place;

- inline collect_ptrs().
2001-10-16 17:00:48 +00:00
Jeremy Hylton 26633f4c00 Put descr name in "bad memberdescr type" error message. 2001-10-16 16:51:56 +00:00
Fred Drake 64d7863797 Added information about setprofile() and settrace() hooks being thread-
specific, and updated some of the comments about the profile hook.
This closes SF bug #471725.
2001-10-16 14:54:22 +00:00
Fred Drake a815916472 Fix thinko in a comment about seeking with a file object.
Reported by Francesco Trentini.
2001-10-16 03:25:00 +00:00
Guido van Rossum 3eea25c3fa Reword the text on the demise of __dynamic__ somewhat, correcting a
typo.
2001-10-16 00:46:57 +00:00
Tim Peters a7e1f43bd9 Remove obsolete __dynamic__ distinction. 2001-10-15 22:59:59 +00:00
Tim Peters 6006629c3c Remove obsolete __dynamic__ distinction. 2001-10-15 22:53:29 +00:00
Tim Peters 1ce150c675 Remove obsolete __static__/__dynamic__ distinction. 2001-10-15 22:49:27 +00:00
Fred Drake 47cada7ab8 pstats-compatible analysis module.
hotshot.stats.load(logfilename) returns a pstats.Stats instance, which is
about as compatible as it gets.
2001-10-15 22:18:53 +00:00
Fred Drake e7d8a78b8e runcall(): Expose the return value of the profiled function; this allows
changing an application to collect profile data on one part of the
    app while still making use of the profiled component, without relying
    on side effects.
2001-10-15 22:14:29 +00:00
Fred Drake 30d1c75d15 Removed useless code to count the number of calls into the profiler.
Added support for saving the names of the functions observed into the
profile log.
Added support for using the profiler to measure coverage without collecting
timing information (which is the slow part).  Coverage logs can also be
substantially smaller than profiling logs where per-line information is
being collected.
Updated comments on the log format; corrected record type values in some
of the record descriptions.
2001-10-15 22:11:02 +00:00
Fred Drake d5d5a04040 Avoid deep recursion when reading the header of the log file.
Add support for extracting function names from the log file, keeping the
extract-names-from-sources support as a fallback.
2001-10-15 22:05:32 +00:00
Guido van Rossum 687ae00460 Get rid of __defined__ and tp_defined -- there's no need to
distinguish __dict__ and __defined__ any more.  In the C structure,
tp_cache takes its place -- but this hasn't been implemented yet.
2001-10-15 22:03:32 +00:00
Jeremy Hylton 6642653875 Covert pickle tests to use unittest.
Extend tests to cover a few more cases.  For cPickle, test several of
the undocumented features.
2001-10-15 21:38:56 +00:00
Jeremy Hylton 499ab6a653 Better fix for core dumps on recursive objects in fast mode.
Raise ValueError when an object contains an arbitrarily nested
reference to itself.  (The previous fix just produced invalid
pickles.)

Solution is very much like Py_ReprEnter() and Py_ReprLeave():
fast_save_enter() and fast_save_leave() that tracks the fast_container
limit and keeps a fast_memo of objects currently being pickled.

The cost of the solution is moderately expensive for deeply nested
structures, but it still seems to be faster than normal pickling,
based on tests with deeply nested lists.

Once FAST_LIMIT is exceeded, the new code is about twice as slow as
fast-mode code that doesn't check for recursion.  It's still twice as
fast as the normal pickling code.  In the absence of deeply nested
structures, I couldn't measure a difference.
2001-10-15 21:37:58 +00:00
Jeremy Hylton abe2c62bdb Use cStringIO when available.
Remove test code.  It's available in Lib/test/picklertester.py.
2001-10-15 21:29:28 +00:00
Guido van Rossum 2ef1b8fd97 Remove a couple of tp_xxx fields that you are not expected to
initialize (or use or even know about :-).
2001-10-15 21:24:12 +00:00
Guido van Rossum 17209fcf1f Fix a bunch of warnings reported by Skip.
To whoever who changed a bunch of (PyCFunction) casts to
(PyNoArgsFunction) in PyMethodDef initializers: don't do that.  The
cast is to shut the compiler up.  The compiler wants the function
pointer initializer to be a PyCFunction.
2001-10-15 21:12:54 +00:00
Guido van Rossum 2f3ca6eeb6 Completely get rid of __dynamic__ and the corresponding
Py_TPFLAGS_DYNAMICTYPE bit.  There is no longer a performance benefit,
and I don't really see the use case any more.
2001-10-15 21:05:10 +00:00
Skip Montanaro f118cb1d6f make getarray static - it's only called from ceval.c and is not an
extern-able name.
2001-10-15 20:51:38 +00:00
Guido van Rossum f35f06963b Another contributor. 2001-10-15 19:55:12 +00:00
Guido van Rossum 825d875371 Add (void *) casts to solve some problems on HP-UX 11.0, as discussed
on SF bug #467145.
2001-10-15 19:44:24 +00:00
Guido van Rossum 1346e83eb0 Patch 471400: escape single-dot lines; by Jason Hildebrand.
RFC 2049 recommends never outputting a line consisting of a single
dot.
2001-10-15 18:44:26 +00:00
Guido van Rossum 5aace07fe0 Use an assert() for the REQ() macro instead of making up our own
assertion.
2001-10-15 17:23:13 +00:00