Commit Graph

3635 Commits

Author SHA1 Message Date
Raymond Hettinger 2a2385dbe2 SF bug #1160187: Setup file needs entries for collections, itertools, strop 2005-03-09 23:46:11 +00:00
Raymond Hettinger 984f9bb714 operator.itemgetter() and operator.attrgetter() now support extraction
of multiple fields.  This provides direct support for sorting by
multiple keys.
2005-03-09 16:38:48 +00:00
Martin v. Löwis e2713becd8 Build with --disable-unicode again. Fixes #1158607.
Will backport to 2.4.
2005-03-08 15:03:08 +00:00
Martin v. Löwis b60ae99601 Convert file names of posix.access according to the file system encoding. 2005-03-08 09:10:29 +00:00
Raymond Hettinger c8b6d1bd8c Make functional.partial() more closely match the spec by emulating
some useful features of regular functions:

* Made weak referencable.
* Allow attribute access so a user can set __name__, __doc__, etc.
2005-03-08 06:14:50 +00:00
Greg Ward 50682d0f78 SF #818006: merge from release24-maint branch: add useful read-only
attributes to oss_audio_device object: 'closed', 'name', and 'mode'.
2005-03-07 01:41:11 +00:00
Martin v. Löwis fd78a6f7f8 Patches #925152, #1118602: Avoid reading after the end of the buffer
in pyexpat.GetInputContext. Will backport to 2.4.
2005-03-04 14:37:01 +00:00
Martin v. Löwis 7fe60c0a0a Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.
2005-03-03 11:22:44 +00:00
Brett Cannon 5ce2587b1b Fix grammatical typo in a comment. 2005-03-01 03:16:34 +00:00
Raymond Hettinger 9c323f8de4 SF patch #941881: PEP 309 Implementation (Partial Function Application).
Combined efforts of many including Peter Harris, Hye-Shik Chang,
Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger.
2005-02-28 19:39:44 +00:00
Martin v. Löwis 9533e34024 Patch #1093585: raise a ValueError for negative history items in
remove_history and replace_history. Will backport to 2.4.
2005-02-27 20:33:25 +00:00
Guido van Rossum 54c273c703 The error message "can't start new thread" should not end in a
newline.
2005-02-20 03:02:16 +00:00
Michael W. Hudson 9867ced6c2 Fix
[ 1077106 ] Negative numbers to os.read() cause segfault

Sorry for sitting on this for so long!  Is there a chance it could
make 2.3.5?
2005-01-31 17:01:59 +00:00
Neal Norwitz 62679968be Put docstring for getspall into same #ifdef block as function definition
Remove C++ (C99) style comments
2005-01-24 23:33:50 +00:00
Martin v. Löwis c300175547 Patch #579435: Shadow Password Support Module 2005-01-23 09:27:24 +00:00
Martin v. Löwis fe33d0ba87 Default stat_float_times to true. 2005-01-16 08:57:39 +00:00
Andrew McNamara f69d94f6c0 Moved reader \r and \n processing from the iterator to the state machine -
this allows for better handling of newline characters in quoted fields (and
hopefully resolves Bug 967934).
2005-01-13 11:30:54 +00:00
Skip Montanaro 0af3ade6aa Add strptime() constructor to datetime class. Thanks to Josh Spoerri for
the changes.
2005-01-13 04:12:31 +00:00
Andrew McNamara 5cfd83748a Improve wording of parser error message. 2005-01-12 11:39:50 +00:00
Andrew McNamara 7f2053eff3 Add counting of source iterator lines to the reader object - handy for
user error messages (otherwise difficult to do without instrumenting
the source).
2005-01-12 11:17:16 +00:00
Andrew McNamara 0f0599ddc1 When quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields
to floats.
2005-01-12 09:45:18 +00:00
Andrew McNamara 5d45a8dc22 Fix logic problem in quoting=csv.QUOTE_ALL, quotechar=None check, add test. 2005-01-12 08:16:17 +00:00
Andrew McNamara c89f284df8 When using QUOTE_NONNUMERIC, we now test for "numericness" with
PyNumber_Check, rather than trying to convert to a float.  Reimplemented
writer - now raises exceptions when it sees a quotechar but neither
doublequote or escapechar are set. Doublequote results are now more
consistent (eg, single quote should generate """", rather than "",
which is ambiguous).
2005-01-12 07:44:42 +00:00
Andrew McNamara 31d8896ee2 Rename csv.set_field_limit to csv.field_size_limit (since it both sets and
gets).
2005-01-12 03:45:10 +00:00
Andrew McNamara cf0fd5ab29 Add belt and braces check of PyString_AsString return. 2005-01-12 01:16:35 +00:00
Andrew McNamara e4d05c4f93 Set an upper limit on the size of the field buffer, raise an exception
when this limit is reached. Limit defaults to 128k, and is changed
by module set_field_limit() method. Previously, an unmatched quote
character could result in the entire file being read into the field
buffer, potentially exhausting virtual memory.
2005-01-11 07:32:02 +00:00
Andrew McNamara 29bf4e44f6 Now that internal dialect type is immutable, and the dialect registry
only contains instances of the dialect type, we can refer directly to the
dialect instances rather than creating new ones. In other words, if the
dialect comes from the registry, and we apply no further modifications,
the reader/writer can use the dialect object directly.
2005-01-11 04:49:53 +00:00
Andrew McNamara 8c94b42f31 No longer attempt to instantiate python classes describing dialects. This
was done because we were previously performing validation of the dialect
from python, but this is now down within the C module. Also, the method
we were using to detect classes did not work with new-style classes.
2005-01-11 02:18:36 +00:00
Andrew McNamara 86625972a1 Allow dialect-describing keywords to be supplied to register_dialect,
record objects of internal dialect type, rather than instances of
python objects.
2005-01-11 01:28:33 +00:00
Andrew McNamara 91b97463cd Factor out the code for making a dialect instance. 2005-01-11 01:07:23 +00:00
Andrew McNamara dbce2618b1 Only set error string when dict lookup found no matching key (was setting
it for all failures, potentially masking other exceptions).
2005-01-10 23:17:35 +00:00
Andrew McNamara a8292636c6 When parsing args that return a single character, treat null string the
same as None.
2005-01-10 12:25:11 +00:00
Andrew McNamara 37d2bdfa76 Where a string is desired, test for PyBaseString_Type derived type,
rather than using PyString_Check/PyUnicode_Check.
2005-01-10 12:22:48 +00:00
Andrew McNamara 77ead87f30 Add missing PyObject_GC_Track and PyObject_GC_UnTrack calls to csv reader and
writer objects (other GC infrastructure already in place).
2005-01-10 02:09:41 +00:00
Andrew McNamara 36a7691c2d Fix parsing of csv files with escapes (escape character previously would be
left in stream).
2005-01-10 01:04:40 +00:00
Andrew McNamara dd3e6cb213 Fix to use PEP7 brace style. 2005-01-07 06:46:50 +00:00
Andrew McNamara 1196cf185c Improved the implementation of the internal "dialect" type. The new
implementation features better error reporting, and better compliance
with the PEP.
2005-01-07 04:42:45 +00:00
Andrew McNamara 575a00b575 Delete Reader_getiter and replace with PyObject_SelfIter. 2005-01-06 02:25:41 +00:00
Andrew M. Kuchling 3b585b30c0 [Bug #1083110] calling .flush() on decompress objects causes a segfault due to an uninitialized pointer: fixes the problem and adds a test case 2004-12-28 20:10:48 +00:00
Raymond Hettinger 3a4231dd74 Bug #1087216: datetime module documentation missing critical detail 2004-12-19 20:13:24 +00:00
Andrew MacIntyre a3be258477 fix unterminated comment 2004-12-18 09:51:05 +00:00
Raymond Hettinger 6f5b741a46 SF bug #1086555: refcount problem in syslog 2004-12-16 23:52:04 +00:00
Raymond Hettinger b0900e6a21 SF #1085304: Make array.array pickle-able 2004-12-16 16:23:40 +00:00
Gregory P. Smith 8a6a59c58b fixed compilation against BerkeleyDB 3.2.9 (sf bug # 1077040) 2004-12-16 09:47:28 +00:00
Gregory P. Smith 8b7e917ab2 * Adds support for building against BerkeleyDB 4.3.21
* bumped the module version number up to 4.3.0
2004-12-13 09:51:23 +00:00
Andrew MacIntyre a4a8afb4e1 OS/2 specific fixes related to SF bug # 1003471.
Also revise a related function to minimise file handle/pipe leakage
and improve reliability.
2004-12-12 08:30:51 +00:00
Raymond Hettinger a6b45cc31d Eliminate the deprecated option to return None instead of a tuple of arguments in __reduce__(). 2004-12-07 07:05:57 +00:00
Raymond Hettinger b2594050ea Added optional None arguments to itertools.islice(). 2004-12-05 09:25:51 +00:00
Gustavo Niemeyer 166878f544 Fixing bug #1072259 in SRE. 2004-12-02 16:15:39 +00:00
Michael W. Hudson 02d74f68c6 Hear the #error: change the default value of the mutable_arg argument
to ioctl() and remove the warning when it is not supplied.
2004-11-30 14:31:54 +00:00
Hye-Shik Chang 7a8173a477 Rename a static variable "history_length" to "_history_length".
GNU readline exports a global variable that has such a name already
and the collision makes gcc4 doesn't compile the source.
2004-11-25 04:04:20 +00:00
Marc-André Lemburg a9cadcd41b Correct the handling of 0-termination of PyUnicode_AsWideChar()
and its usage in PyLocale_strcoll().

Clarify the documentation on this.

Thanks to Andreas Degert for pointing this out.
2004-11-22 13:02:31 +00:00
Martin v. Löwis fba7369824 Patch #1050475: Fix various x86_64 build issues
regrtest.py: skip rgbimg and imageop as they are not built on 64-bit systems.
_tkinter.c: replace %.8x with %p for printing pointers.
setup.py: add lib64 into the library directories.
2004-11-13 11:13:35 +00:00
Raymond Hettinger 2c45c9ae57 SF patch 1062495: Modules/zipimport.c does not compile on solaris
(Contributed by Niki W. Waibel.)

Simple renaming to avoid a conflict that prevented compilation on Solaris.
2004-11-10 13:08:35 +00:00
Raymond Hettinger 952f8808b2 SF patch #1062279: deque pickling problems
(Contributed by Dima Dorfman.)

* Support pickling of dictionaries in instances of deque subclasses.
* Support pickling of recursive deques.
2004-11-09 07:27:35 +00:00
Jeremy Hylton 80961f3ca9 Fix apparently trivial buffer overflow (SF bug 1060396).
memset() wrote one past the end of the buffer, which was likely to be unused padding or a yet-to-be-initialized local variable.  This routine is already tested by test_socket.
2004-11-07 14:24:25 +00:00
Raymond Hettinger 7d112df94f Bump-up block size. 2004-11-02 02:11:35 +00:00
Walter Dörwald bb9c739806 Add error checks for the bz2, cStringIO and operator modules.
Add function names to various PyArg_ParseTuple calls in bz2module.c.
2004-11-01 17:10:19 +00:00
Tim Peters bc1d1b80d1 gc_list_move(): Make this truly equivalent to remove+append. While
nothing in gc currently cares, the original coding could screw up if,
e.g., you tried to move a node to the list it's already in, and the node
was already the last in its list.
2004-11-01 16:39:57 +00:00
Tim Peters e2d591847c gc list function cleanup.
Introduced gc_list_move(), which captures the common gc_list_remove() +
gc_list_append() sequence.  In fact, no uses of gc_list_append() remained
(they were all in a gc_list_move() sequence), so commented that one out.

gc_list_merge():  assert that `from` != `to`; that was an implicit
precondition, now verified in a debug build.

Others:  added comments about their purpose.
2004-11-01 01:39:08 +00:00
Tim Peters cc2a866cb7 handle_weakrefs(): Simplification -- there's no need to make a second
pass over the unreachable weakrefs-with-callbacks to unreachable objects.
2004-10-31 22:12:43 +00:00
Tim Peters ead8b7ab30 SF 1055820: weakref callback vs gc vs threads
In cyclic gc, clear weakrefs to unreachable objects before allowing any
Python code (weakref callbacks or __del__ methods) to run.

This is a critical bugfix, affecting all versions of Python since weakrefs
were introduced.  I'll backport to 2.3.
2004-10-30 23:09:22 +00:00
Fred Drake 08ebfec75e some platforms still need offsetof() from structmember.h 2004-10-17 19:36:57 +00:00
Raymond Hettinger a9f6092904 Fix and test weak referencing of itertools.tee objects. 2004-10-17 16:40:14 +00:00
Michael W. Hudson 3079391b8d Just remove the #include of signal.h. That it was C++-commented out
was a mistake of mine in updating patch #975056 (I think).
2004-10-14 13:27:14 +00:00
Neal Norwitz f7c8d9320b Use C89 style comment for old compilers 2004-10-14 03:48:30 +00:00
Martin v. Löwis 9171f02132 Synchronize with PyXML 1.79:
73: Restore support for Python 2.1.
74: Factor the previous change differently
79: Conditionalize usage of PyTuple_Pack.
2004-10-13 19:50:11 +00:00
Anthony Baxter 8a560dee72 Patch 977343, Solaris likes sys/loadavg.h. Added support for sys/loadavg.h
detection to configure &c.
2004-10-13 15:30:56 +00:00
Anthony Baxter 9ceaa72ebe Patch #975056 - fixes for restartable signals on *BSD. In addition,
a few remaining calls to signal() were converted to PyOS_setsig().
2004-10-13 14:48:50 +00:00
Raymond Hettinger dcb9d9467c Simplify delitem() code by calling rotate() directly instead of using
arguments passed through tuples.
2004-10-09 16:02:18 +00:00
Michael W. Hudson 8da2b01c3f This is Michiel de Hoon's patch, as attached to the bug report:
[ 1030629 ] PyOS_InputHook broken

with a couple of utterly inconsequential changes by me.
2004-10-07 13:46:33 +00:00
Raymond Hettinger db29e0fe8c SF patch #1035498: -m option to run a module as a script
(Contributed by Nick Coghlan.)
2004-10-07 06:46:25 +00:00
Raymond Hettinger c5fa992069 Armin's patch to prevent overflows. 2004-10-06 17:51:54 +00:00
Armin Rigo 974d757af1 Upon insertion, if memory runs out, the deque was left in a corrupted state.
deque_item(): a performance bug: the linked list of blocks was followed
from the left in most cases, because the test (i < (deque->len >> 1)) was
after "i %= BLOCKLEN".

deque_clear(): replaced a call to deque_len() with deque->len; not sure what
this call was here for, nor if all compilers under the sun would inline it.

deque_traverse(): I belive that it could be called by the GC when the deque
has leftblock==rightblock==NULL, because it is tracked before the first block
is allocated (though closely before).  Still, a C extension module subclassing
deque could provide its own tp_alloc that could trigger a GC collection after
the PyObject_GC_Track()...

deque_richcompare(): rewrote to cleanly check for end-of-iterations instead of
relying on deque.__iter__().next() to succeed exactly len(deque) times -- an
assumption which can break if deques are subclassed.  Added a test.

I wonder if the length should be explicitely bounded to INT_MAX, with
OverflowErrors, as in listobject.c.  On 64-bit machines, adding more than
INT_MAX in the deque will result in trouble.  (Note to anyone/me fixing
this: carefully check for overflows if len is close to INT_MAX in the
following functions: deque_rotate(), deque_item(), deque_ass_item())
2004-10-02 13:59:34 +00:00
Raymond Hettinger 880430e2a5 Replace structure member before decreffing. 2004-10-02 10:56:43 +00:00
Raymond Hettinger d1b3d88bf3 * Bulletproof the method for detecting mutations during iteration.
The previous approach was too easily fooled (a rotate() sufficed).

* Use it->counter to determine when iteration is complete.  The
  previous approach was too complex.

* Strengthen an assertion and add a comment here or there.
2004-10-02 00:43:13 +00:00
Raymond Hettinger 77e8bf1ca4 Restore the block length and add a comment. 2004-10-01 15:25:53 +00:00
Raymond Hettinger 4ca4c7c8cc Clarify the relationship between indices. 2004-10-01 15:14:39 +00:00
Raymond Hettinger 61f05fb96d * Elaborate on the invariant comments and make them more precise.
* Change the centering by one to make it possible to test the module
  with BLOCKLEN's as low as two.  Testing small blocks makes end-point
  errors surface more readily.
2004-10-01 06:24:12 +00:00
Tim Peters 10c7e86454 deque_traverse(): If the deque had one block, and its rightindex was
BLOCKLEN-1, this assert-failed in a debug build, or went wild with a
NULL pointer in a release build.  Reported on c.l.py by Stefan Behnel.
2004-10-01 02:01:04 +00:00
Tim Peters d6e0032768 Typos in new comments. 2004-10-01 01:35:54 +00:00
Tim Peters d8768d3294 Document some reverse-engineered invariants and pragmatic hints. 2004-10-01 01:32:53 +00:00
Tim Peters 6f85356ff7 Definition consistency. 2004-10-01 01:04:50 +00:00
Tim Peters 1065f750cb Trimmed trailing whitespace. 2004-10-01 01:03:29 +00:00
Raymond Hettinger 4cda01e260 * Increase test coverage.
* Have groupby() be careful about decreffing structure members.
2004-09-28 04:45:28 +00:00
Raymond Hettinger 87de0ca741 Silence a compiler warning by supplying the correct argument type to
the htons() function.
2004-09-28 02:19:40 +00:00
Raymond Hettinger 855d9a985b Plug a leak and beef-up test coverage. 2004-09-28 00:03:54 +00:00
Armin Rigo b6aa856f25 Patch #1009075, bug #952953: allow execve with empty 2nd argument 2004-09-27 19:54:33 +00:00
Armin Rigo 9f90439817 Patch #1011240: SystemError generated by struct.pack('P', 'foo'). 2004-09-27 19:27:51 +00:00
Raymond Hettinger 9447874131 Add docstrings for regular expression objects and methods. 2004-09-24 04:31:19 +00:00
Tim Peters 528ca53b74 SF bug #1028306: date-datetime comparison
Treat comparing a date to a datetime like a mixed-type comparison.
2004-09-16 01:30:50 +00:00
Trent Mick 8ea5bdf784 Patch for compilation on IRIX from rwgk on http://python.org/sf/728330 2004-09-13 17:48:41 +00:00
Walter Dörwald 69652035bc SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
decoding incomplete input (when the input stream is temporarily exhausted).
codecs.StreamReader now implements buffering, which enables proper
readline support for the UTF-16 decoders. codecs.StreamReader.read()
has a new argument chars which specifies the number of characters to
return. codecs.StreamReader.readline() and codecs.StreamReader.readlines()
have a new argument keepends. Trailing "\n"s will be stripped from the lines
if keepends is false. Added C APIs PyUnicode_DecodeUTF8Stateful and
PyUnicode_DecodeUTF16Stateful.
2004-09-07 20:24:22 +00:00
Trent Mick a708d6e3b0 Apply patch from http://python.org/sf/728330 to fix socket module compilation on Solaris 2.6, HP-UX 11, AIX 5.1 and (possibly) some IRIX versions. 2004-09-07 17:48:26 +00:00
Raymond Hettinger 9fd5e9a695 Remove redunandant assertions from last checkin. 2004-09-06 23:02:37 +00:00
Raymond Hettinger 658717ed11 SF #1022953: binascii.a2b_hqx("") raises SystemError
Several functions adopted the strategy of altering a full lengthed
string copy and resizing afterwards.  That would fail if the initial
string was short enough (0 or 1) to be interned.  Interning precluded
the subsequent resizing operation.

The solution was to make sure the initial string was at least two
characters long.

Added tests to verify that all binascii functions do not crater when
given an empty string argument.
2004-09-06 22:58:37 +00:00
Raymond Hettinger 8158e84930 Fix erroneous docstring comment. 2004-09-06 07:04:09 +00:00
Gregory P. Smith 442c9fc376 SF bug 1017405: the keys() values() and items() DB methods were
ignoring their transaction (txn) argument.
2004-09-04 01:36:59 +00:00
Gustavo Niemeyer 0506c64086 Fixing bug #817234, which made SRE get into an infinite loop on
empty final matches with finditer(). New test cases included
for this bug and for #581080.
2004-09-03 18:11:59 +00:00
Raymond Hettinger 75ccea3777 SF patch #1020188: Use Py_CLEAR where necessary to avoid crashes
(Contributed by Dima Dorfman)
2004-09-01 07:02:44 +00:00