Commit Graph

23492 Commits

Author SHA1 Message Date
Guido van Rossum
443fec3dd9 Major restructuring of _fileobject. Hopefully several things now work
correctly (the test at least succeed, but they don't test everything yet).

Also fix a performance problem in read(-1): in unbuffered mode, this would
read 1 byte at a time.  Since we're reading until EOF, that doesn't make
sense.  Use the default buffer size if _rbufsize is <= 1.
2002-08-08 01:02:16 +00:00
Guido van Rossum
8c94383fa8 Replace docstrings on test functions witrh comments -- then unittest
prints function and module names, which is more informative now that
we repeat some tests in slightly modified subclasses.

Add a test for read() until EOF.

Add test suites for line-buffered (bufsize==1) and a small custom
buffer size (bufsize==2).

Restructure testUnbufferedRead() somewhat to avoid a potentially
infinite loop.
2002-08-08 01:00:28 +00:00
Tim Peters
808eb59fc4 Added info about the right way to leave the body of a trashcan-protected
destructor early.
2002-08-07 20:53:05 +00:00
Guido van Rossum
0906e07442 Fix a subtle bug in the trashcan code I added yesterday to
subtype_dealloc().

When call_finalizer() failed, it would return without going through
the trashcan end macro, thereby unbalancing the trashcan nesting level
counter, and thereby defeating the test case (slottrash() in
test_descr.py).  This in turn meant that the assert in the GC_UNTRACK
macro wasn't triggered by the slottrash() test despite a bug in the
code: _PyTrash_destroy_chain() calls the dealloc routine with an
object that's untracked, and the assert in the GC_UNTRACK macro would
fail on this; but because of an earlier test that resurrects an
object, causing call_finalizer() to fail and the trashcan nesting
level to be unbalanced, so _PyTrash_destroy_chain() was never called.
Calling the slottrash() test in isolation *did* trigger the assert,
however.

So the fix is twofold: (1) call the GC_UnTrack() function instead of
the GC_UNTRACK macro, because the function is safe when the object is
already untracked; (2) when call_finalizer() fails, jump to a label
that exits through the trashcan end macro, keeping the trashcan
nesting balanced.
2002-08-07 20:42:09 +00:00
Raymond Hettinger
ae7ef57cba GvR pointed out that only enclosing function bodies are part of nested scopes. 2002-08-07 20:20:52 +00:00
Guido van Rossum
fb1db4cda1 Add -E and -tt options to the python invocations, as for the Unix tests.
The -tt means modules that mix tabs and spaces will be rejected.
The -E refuses to believe Python options in the environment.
2002-08-07 19:06:27 +00:00
Guido van Rossum
9ed5ae7331 Replace tabs with spaces. (Sorry!) 2002-08-07 19:03:35 +00:00
Guido van Rossum
10e3f411b0 Tighten the unbuffered readline test to distinguish between the two lines. 2002-08-07 19:02:49 +00:00
Guido van Rossum
3c8dd0c6e7 Simplify heapreplace() -- there's no need for an explicit test for
empty heap, since heap[0] raises the appropriate IndexError already.
2002-08-07 18:58:11 +00:00
Guido van Rossum
b2865919cc Document that heappop() and heapreplace() raise IndexError if the heap
is empty.
2002-08-07 18:56:08 +00:00
Raymond Hettinger
83dcf5a290 Apply character{} markup. 2002-08-07 16:53:17 +00:00
Martin v. Löwis
3f19b10ca5 Replace abort with Py_FatalError. 2002-08-07 16:21:51 +00:00
Raymond Hettinger
22c001bd29 Described responsibilty of weakly referenced extension types to initialize
the weakreflist to NULL in the constructor and to fill the tp_flags
slot with Py_TPFLAGS_HAVE_WEAKREFS.  Closes SF bug 586583.
2002-08-07 16:18:54 +00:00
Raymond Hettinger
861bb02448 Describe nested scopes in the tutorial. Closes SF bug 500704. 2002-08-07 16:09:48 +00:00
Guido van Rossum
29bf9157ec Oops. I accidentally commented out some tests. 2002-08-07 16:03:06 +00:00
Jack Jansen
295105f3aa Regenerated with OSA class inheritance and fix for non-ascii chars. 2002-08-07 15:53:42 +00:00
Jack Jansen
7ff034b65b Fixed incorrect logic in determining whether we should initialize
the classes' attribute list.
2002-08-07 15:52:44 +00:00
Raymond Hettinger
3cfdc3402e Documented os.fsync and os.fdatasync. Closes SF bug 584695. 2002-08-07 15:48:17 +00:00
Guido van Rossum
e9f6614ea3 "Unbuffered" mode of class _fileobject wasn't actually unbuffered,
and this broke a Zope "pipelining" test which read multiple responses
from the same connection (this attaches a new file object to the
socket for each response).  Added a test for this too.

(I want to do some code cleanup too, but I thought I'd first fix
the problem with as little code as possible, and add a unit test
for this case.  So that's what this checkin is about.)
2002-08-07 15:46:19 +00:00
Jack Jansen
21f675826e - If an OSA identifier is a Python reserved word we now append an _
in stead of prepending it, which messes up "import * from".
- A few ascii()s added again.
- Changed the getbaseclasses a little, but it still isn't perfect.
2002-08-07 15:44:53 +00:00
Fred Drake
442c7c7743 Clarify that the bool instances are acceptable return values from
__nonzero__(), in response to SF bug #579991.
2002-08-07 15:40:15 +00:00
Martin v. Löwis
2863c10a86 Use Py_FatalError instead of abort. 2002-08-07 15:18:57 +00:00
Jack Jansen
2f7f8c4a64 Don't be over-enthusiastic with the ascii() calls: we don't need it if
the result passes through backticks.
2002-08-07 15:05:42 +00:00
Jack Jansen
8b77767094 Donovan Preston's patch #538395, with some mods by me.
This patch makes inheritance for OSA classes work. The implementation is a
bit convoluted, but I don't immedeately see a simpler way of doing it.

I added calls to ascii() everywhere we output strings that may contain
non-ascii characters (Python has gotten very picky since the encoding
patch:-).

I also removed Donovan's different way of opening resource files: I don't
seem to need it.
2002-08-07 14:49:00 +00:00
Jack Jansen
b2bb87300b Quote the arguments, they may contain strings. 2002-08-07 14:05:58 +00:00
Fred Drake
f7aa164d7a Fix up some more markup problems. 2002-08-07 13:24:09 +00:00
Fred Drake
95fa4ddf7b Change the markup a bit more; the parameter was not marked as \var in the
sample code, and the note was marked as a logical thing.
2002-08-07 12:39:33 +00:00
Martin v. Löwis
019934b3cc Fix PEP 263 code --without-unicode. Fixes #591943. 2002-08-07 12:33:18 +00:00
Steve Holden
63d5bead18 Fix markup errors. 2002-08-07 12:01:41 +00:00
Raymond Hettinger
ca84d65ca7 Expanded the unittests for the new width sensitive PyUnicode_Contains(). 2002-08-06 23:08:51 +00:00
Raymond Hettinger
d9fdb51df6 Document handling of raw-unicode-escapes. Closes SF bug 587087. 2002-08-06 22:36:26 +00:00
Tim Peters
5814187f5b internal_connect(): Windows. When sock_timeout > 0 and connect() yields
WSAEWOULDBLOCK, the second connect() attempt appears to yield WSAEISCONN
on Win98 but WSAEINVAL on Win2K.  So accept either as meaning "yawn,
fine".  This allows test_socket to succeed on my Win2K box (which it
already did on my Win98SE box).
2002-08-06 22:25:02 +00:00
Jack Jansen
d37f75b88a Added a note about the inability to specify a pathname to a non-existing
file in unix-Python.
2002-08-06 22:15:23 +00:00
Jack Jansen
4104b50b52 Changed a sentence that confused some people. 2002-08-06 22:14:23 +00:00
Neal Norwitz
657d222700 Make more functions static 2002-08-06 22:12:52 +00:00
Neal Norwitz
d8b995f5e8 Make readahead functions static 2002-08-06 21:50:54 +00:00
Guido van Rossum
22b1387c51 Fix SF bug 574207 (chained __slots__ dealloc segfault).
This is inspired by SF patch 581742 (by Jonathan Hogg, who also
submitted the bug report, and two other suggested patches), but
separates the non-GC case from the GC case to avoid testing for GC
several times.

Had to fix an assert() from call_finalizer() that asserted that the
object wasn't untracked, because it's possible that the object isn't
GC'ed!
2002-08-06 21:41:44 +00:00
Fred Drake
31f3db39f3 Fix the markup so it doesn't break formatting. 2002-08-06 21:36:06 +00:00
Guido van Rossum
2d702465b3 Add testcase for SF bug 574207 (chained __slots__ dealloc segfault).
Fix forthcoming.
2002-08-06 21:28:28 +00:00
Fred Drake
2d3c03df9a Added references to the email package.
Closes SF bug #586937.
2002-08-06 21:26:01 +00:00
Barry Warsaw
e06741704e Added a test for PyUnicode_Contains() taking into account the width of
Py_UNICODE.
2002-08-06 19:03:56 +00:00
Barry Warsaw
6a043f3fe8 PyUnicode_Contains(): The memcmp() call didn't take into account the
width of Py_UNICODE.  Good catch, MAL.
2002-08-06 19:03:17 +00:00
Skip Montanaro
496e6581e1 get rid of GETNAMEV macro - use GETITEM directly
same idea as getting rid of GETCONST & GETNAME (see patch #506436)
2002-08-06 17:47:40 +00:00
Guido van Rossum
fce538c31e Add a coding cookie, because of the møøse quote. 2002-08-06 17:29:38 +00:00
Guido van Rossum
8cdc03dca5 Update the URL for getting zlib, and update the minimal required
version to 1.1.4 (because of the 1.1.3 security problem).  Also
replace a funny use of line.find() with line.startswith().
2002-08-06 17:28:30 +00:00
Guido van Rossum
0855dd8938 Bump the LOOPS count. 50,000 iterations takes about 5 seconds on my
machine -- that feels just right.
2002-08-06 17:21:20 +00:00
Guido van Rossum
43af5b5852 Add some fine points: METH_KEYWORDS implies METH_VARARGS, and ob_size
is no longer unused in type objects.
2002-08-06 17:18:56 +00:00
Guido van Rossum
8ee5243434 Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py. 2002-08-06 17:14:04 +00:00
Guido van Rossum
97c5fccd77 Remove mention of deprecated xreadlines method. 2002-08-06 17:03:25 +00:00
Barry Warsaw
d79f683772 Describe new "str1 in str2" behavior. 2002-08-06 17:01:51 +00:00