Commit Graph

3197 Commits

Author SHA1 Message Date
Gregory P. Smith f655dff807 DB.remove() needs to set the internal DB handle to NULL after being called.
(sourceforge pybsddb bug #737970).

Also: don't allow other threads to run during calls that invalidate the
DB handle.
2003-05-15 00:13:18 +00:00
Martin v. Löwis a94568a753 Patch #734231: Update RiscOS support. In particular, correct
riscospath.extsep, and use os.extsep throughout.
2003-05-10 07:36:56 +00:00
Michael W. Hudson 505c4c2858 Simple fix for
[ 733781 ] fcntl fails to build on old RH Linux
2003-05-09 10:45:20 +00:00
Martin v. Löwis 28e9ce9df2 Patch #734118: Add {get|set}busywaitinterval. 2003-05-09 08:19:48 +00:00
Just van Rossum 16e426bb15 Yet another addition to [731644]: only use the lock if thread-support
is enabled.
2003-05-09 08:12:00 +00:00
Just van Rossum 09aecd7a0d Addition to [731644]: also use the lock when using the getaddrinfo
emulation (ie. when HAVE_GETADDRINFO isn't defined).
2003-05-09 08:03:44 +00:00
Just van Rossum 1040d2ce7d [ 731644] & [ 604210 ] Release the GIL around getaddrinfo(), yet protect
access with lock on those platforms that getaddrinfo() isn't (known to be)
thread-safe. Thanks to MvL for mentoring this patch.
2003-05-09 07:53:18 +00:00
Skip Montanaro c797ceb545 add open function to bsddb185 module so the file format sniffing can be
restricted to the whichdb module
2003-05-06 20:38:52 +00:00
Martin v. Löwis e941617671 Patch #724588: Check whether the address of hstrerror and inet_pton can
be taken, and define NI_MAX{HOST|SERV} if necessary.
2003-05-03 10:12:45 +00:00
Martin v. Löwis dd6cd65b98 Implement tcl object __cmp__. 2003-05-03 09:45:12 +00:00
Martin v. Löwis c16f3bd8a3 Patch #708495: Port more stuff to OpenVMS. 2003-05-03 09:14:54 +00:00
Raymond Hettinger 7c2bb5bc57 * Added a substantial number of edge case and argument tests for
the itertoolsmodule.
* Taught itertools.repeat(obj, n) to treat negative repeat counts as
  zero.  This behavior matches that for sequences and prevents
  infinite loops.
2003-05-03 05:59:48 +00:00
Raymond Hettinger 341deb74e7 The previous made the stop argument optional.
It is better to be explicit and just allow stop to be None.
2003-05-02 19:44:20 +00:00
Raymond Hettinger 14ef54cd83 SF bug #730685: itertools.islice stop argument is not optional
* itertools.islice() stop argument did not perform as documented.
* beefed-up test suite
2003-05-02 19:04:37 +00:00
Tim Peters e2df5ffa53 SF patch 731504: Typo in datetimemodule.c comment.
s/isofomat/isoformat/, by Steven Taschuk.
2003-05-02 18:39:55 +00:00
Anthony Baxter 0e85f9d6fd Patch 731209: Restore socketmodule's behaviour with dotted quad addresses
to that of Python2.1. Such nnn.nnn.nnn.nnn addresses are just used directly,
not passed to the resolver for a pointless lookup.
2003-05-02 15:40:46 +00:00
Martin v. Löwis 1869ec5cb7 Convert tcl objects to strings in getvar/setvar. Fixes #730506. 2003-05-01 05:47:00 +00:00
Martin v. Löwis fccac2e61a Patch #725942: Always rename emulation functions. 2003-05-01 05:20:46 +00:00
Andrew M. Kuchling c24fe36c57 Allow _sre.c to compile with Python 2.2 2003-04-30 13:09:08 +00:00
Guido van Rossum 24ccca1565 When an unhandled exception happens, report the repr() of the function
that was used to start the thread.  This is useful to track down the
source of the problem when there is no traceback, as can happen when a
daemon thread gets to run after Python is finialized (a new kind of
event, somehow this is now possible due to changes in Py_Finalize()).
2003-04-29 19:44:05 +00:00
Gustavo Niemeyer 572f5233f0 Applying patch #728656, by logistix, fixing opening of nonexistent
bz2 files. Also, included a testcase for this problem.
2003-04-29 14:53:08 +00:00
Gustavo Niemeyer caf1c9dfe7 - Included detailed documentation in _sre.c explaining how, when, and why
to use LASTMARK_SAVE()/LASTMARK_RESTORE(), based on the discussion
  in patch #712900.

- Cleaned up LASTMARK_SAVE()/LASTMARK_RESTORE() usage, based on the
  established rules.

- Moved the upper part of the just commited patch (relative to bug #725106)
  to outside the for() loop of BRANCH OP. There's no need to mark_save()
  in every loop iteration.
2003-04-27 14:42:54 +00:00
Gustavo Niemeyer 3646ab98af Fix for part of the problem mentioned in #725149 by Greg Chapman.
This problem is related to a wrong behavior from mark_save/restore(),
which don't restore the mark_stack_base before restoring the marks.
Greg's suggestion was to change the asserts, which happen to be
the only recursive ops that can continue the loop, but the problem would
happen to any operation with the same behavior. So, rather than
hardcoding this into asserts, I have changed mark_save/restore() to
always restore the stackbase before restoring the marks.

Both solutions should fix these two cases, presented by Greg:

>>> re.match('(a)(?:(?=(b)*)c)*', 'abb').groups()
('b', None)
>>> re.match('(a)((?!(b)*))*', 'abb').groups()
('b', None, None)

The rest of the bug and patch in #725149 must be discussed further.
2003-04-27 13:25:21 +00:00
Gustavo Niemeyer c34f2555bd Applied patch #725106, by Greg Chapman, fixing capturing groups
within repeats of alternatives. The only change to the original
patch was to convert the tests to the new test_re.py file.

This patch fixes cases like:

>>> re.match('((a)|b)*', 'abc').groups()
('b', '')

Which is wrong (it's impossible to match the empty string),
and incompatible with other regex systems, like the following
examples show:

% perl -e '"abc" =~ /^((a)|b)*/; print "$1 $2\n";'
b a

% echo "abc" | sed -r -e "s/^((a)|b)*/\1 \2|/"
b a|c
2003-04-27 12:34:14 +00:00
Gustavo Niemeyer c23fb77477 Applying patch #726869 by Andrew I MacIntyre, reducing in _sre.c the
recursion limit for certain setups of FreeBSD and OS/2.
2003-04-27 06:58:54 +00:00
Gustavo Niemeyer 7628f1ffff Applying patch by Neal Norwitz:
[#727759] get bzip2 to build on Solaris 8 (old bzip library)
2003-04-27 06:25:24 +00:00
Guido van Rossum 47dfa4a89a Patch by Jp Calderone:
- The socket module now provides the functions inet_pton and inet_ntop
  for converting between string and packed representation of IP addresses.
  See SF patch #658327.

This still needs a bit of work in the doc area, because it is not
available on all platforms (especially not on Windows).
2003-04-25 05:48:32 +00:00
Thomas Heller 3457e4bd80 New support functions for test_getargs2.
Theres now a separate function for each of the format codes
b, B, H, I, k, i, l, L, K.
2003-04-24 16:14:27 +00:00
Raymond Hettinger 352f9477da SF patch 695710: fix bug 678519: cStringIO self iterator
(requested by GvR. patch contributed by Michael Stone)
2003-04-24 15:50:11 +00:00
Barry Warsaw c74e4a5351 Added a comment about backward compatibility requirements and a link
to the PyBSDDB project at SourceForge.
2003-04-24 14:28:08 +00:00
Andrew M. Kuchling 360088f206 [Patch #679505] Trigger DeprecationWarning on importing the rotor module 2003-04-24 13:17:13 +00:00
Raymond Hettinger 84fc9aa6ce SF 686323: Minor array module enhancements
Allows use of tuples for the initializer.
2003-04-24 10:41:55 +00:00
Raymond Hettinger 88ba1e39ec SF Patch 685051: fix for 680789: reprs in arraymodule
(contributed by logistix; substantially reworked by rhettinger).

To create a representation of non-string arrays, array_repr() was
starting with a base Python string object and repeatedly using +=
to concatenate the representation of individual objects.

Logistix had the idea to convert to an intermediate tuple form and
then join it all at once.  I took advantage of existing tools and
formed a list with array_tolist() and got its representation through
PyObject_Repr(v) which already has a fast implementation for lists.
2003-04-23 17:27:00 +00:00
Tim Peters 11b2306960 Enable os.fsync() for Windows, mapping it to MS's _commit() there. The
docs here are best-guess:  the MS docs I could find weren't clear, and
some even claimed _commit() has no effect on Win32 systems (which is
easily shown to be false just by trying it).
2003-04-23 02:39:17 +00:00
Raymond Hettinger 9a9c436036 PyObject_IsTrue() can return an error condition.
Adding code to handle it properly.
2003-04-23 00:14:18 +00:00
Mark Hammond a69d409f05 Update to the new PyGILState APIs to simplify and correct thread-state
management.  Old code still #ifdef'd out - I may remove this in a sec,
but for now, let's get it in and things passing the tests again!
2003-04-22 23:13:27 +00:00
Gustavo Niemeyer 3c9068bbec Made MAX_UNTIL/MIN_UNTIL code more coherent about mark protection,
accordingly to further discussions with Greg Chapman in patch #712900.
2003-04-22 15:39:09 +00:00
Neal Norwitz 699cbb7676 Get test_capi & test_getargs2 to pass on alphas
* UINT_MAX -> ULONG_MAX since we are dealing with longs
  * ParseTuple needs &int for 'i' and &long for 'l'
    There may be a better way to do this, but this works.
2003-04-22 01:28:57 +00:00
Andrew MacIntyre baf25b06a6 apply Mark Hammond's PEP 311 changes to the EMX ripoff of the Windows
popen[234]() code
2003-04-21 14:22:36 +00:00
Andrew MacIntyre 75e0145bb5 - DosSetExtLIBPATH objects to a NULL pointer, but a pointer to a NULL
string does what is expected (ie unset [BEGIN|END]LIBPATH)

- set the size of the DosQuerySysInfo buffer correctly; it was safe,
  but incorrect (allowing a 1 element overrun)
2003-04-21 14:19:51 +00:00
Gustavo Niemeyer be733ee7fb More work on bug #672491 and patch #712900.
I've applied a modified version of Greg Chapman's patch. I've included
the fixes without introducing the reorganization mentioned, for the sake
of stability. Also, the second fix mentioned in the patch don't fix the
mentioned problem anymore, because of the change introduced by patch
#720991 (by Greg as well). The new fix wasn't complicated though, and is
included as well.

As a note. It seems that there are other places that require the
"protection" of LASTMARK_SAVE()/LASTMARK_RESTORE(), and are just waiting
for someone to find how to break them. Particularly, I belive that every
recursion of SRE_MATCH() should be protected by these macros. I won't
do that right now since I'm not completely sure about this, and we don't
have much time for testing until the next release.
2003-04-20 07:35:44 +00:00
Gustavo Niemeyer 1aca359e89 - Fixed bug #672491. This change restores the behavior of lastindex/lastgroup
to be compliant with previous python versions, by backing out the changes
  made in revision 2.84 which affected this. The bugfix for backtracking is
  still maintained.
2003-04-20 00:45:13 +00:00
Mark Hammond 8d98d2cb95 New PyGILState_ API - implements pep 311, from patch 684256. 2003-04-19 15:41:53 +00:00
Martin v. Löwis 78e2f06cc6 Fully support 32-bit codes. Enable BIGCHARSET in UCS-4 builds. 2003-04-19 12:56:08 +00:00
Martin v. Löwis 2548c730c1 Implement IDNA (Internationalized Domain Names in Applications). 2003-04-18 10:39:54 +00:00
Thomas Heller a4ea603b05 SF # 595026: support for masks in getargs.c.
New functions:
  unsigned long PyInt_AsUnsignedLongMask(PyObject *);
  unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
  unsigned long PyLong_AsUnsignedLongMask(PyObject *);
  unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);

New and changed format codes:

b unsigned char 0..UCHAR_MAX
B unsigned char none **
h unsigned short 0..USHRT_MAX
H unsigned short none **
i int INT_MIN..INT_MAX
I * unsigned int 0..UINT_MAX
l long LONG_MIN..LONG_MAX
k * unsigned long none
L long long LLONG_MIN..LLONG_MAX
K * unsigned long long none

Notes:

* New format codes.

** Changed from previous "range-and-a-half" to "none"; the
range-and-a-half checking wasn't particularly useful.

New test test_getargs2.py, to verify all this.
2003-04-17 18:55:45 +00:00
Guido van Rossum e13ddc9ec8 - New C API PyGC_Collect(), same as calling gc.collect().
- Call this in Py_Finalize().
- Expand the Misc/NEWS text on PY_LONG_LONG.
2003-04-17 17:29:22 +00:00
Martin v. Löwis 6f29ff319b Support UCS-4 Tcl for UCS-4 Python builds. Fixes #719880. 2003-04-16 20:34:55 +00:00
Raymond Hettinger 954bcf5fe0 Minor source formatting fixes. 2003-04-16 18:40:04 +00:00
Martin v. Löwis ee24e9cad0 Use object interface for global vars. Fixes #721171.
Also move complete processing of get/set/delvar calls to target thread.
2003-04-15 20:33:20 +00:00
Guido van Rossum 8b7a9a38c6 The date class is now properly subclassable. (SF bug #720908)
(This is only the tip of the iceberg; the time and datetime classes
need the same treatment.)
2003-04-14 22:01:58 +00:00
Guido van Rossum 41c99e7f96 SF patch #720991 by Gary Herron:
A small fix for bug #545855 and Greg Chapman's
addition of op code SRE_OP_MIN_REPEAT_ONE for
eliminating recursion on simple uses of pattern '*?' on a
long string.
2003-04-14 17:59:34 +00:00
Andrew M. Kuchling dff694bb9d Fix docstring typo 2003-04-14 15:31:27 +00:00
Jeremy Hylton 42a8aedb29 Make readers and writers participate in garbage collection.
Fix memory leak in dialect_init().
2003-04-14 02:20:55 +00:00
Tim Peters 38fc837fa9 Must declare vrbls at the tops of blocks in C89 (wouldn't compile). 2003-04-13 03:25:15 +00:00
Skip Montanaro 7b01a83488 use PyModule_Add{Int,String}Constant() where appropriate
(thanks to Neal Norwitz for the code review, BTW)
2003-04-12 19:23:46 +00:00
Skip Montanaro 577c7a763d tighten up string checks
make csv_{get,unregister}_dialect METH_O functions to avoid PyArg_ParseTuple
2003-04-12 19:17:14 +00:00
Skip Montanaro 860fc0b1d5 add writerows docstring
conditionally exclude Unicode functions
2003-04-12 18:57:52 +00:00
Skip Montanaro 98f16e0074 typo 2003-04-11 23:10:13 +00:00
Skip Montanaro dfa35fa3b6 typo 2003-04-11 21:40:01 +00:00
Skip Montanaro 3bc093b717 zap commented out bit of code 2003-04-11 19:33:55 +00:00
Raymond Hettinger 502168a86e SF patch #718867: Fix reference leak for time.strptime
(contributed by Brett Cannon)
2003-04-10 16:03:22 +00:00
Jeremy Hylton 7b5ce7f25a Make Unpickler objects colletable.
Bugfix candidate.
2003-04-09 21:25:30 +00:00
Jeremy Hylton 4cf6319cd2 Make Picklers collectable.
Bug fix candidate.
2003-04-09 21:05:12 +00:00
Guido van Rossum 69c2b88392 Fix two crashes on Windows:
- CHECK_VALID() was checking the wrong value for a closed fd
- fseek(&_iob[fileno], ...) doesn't work for fileno >= 20
2003-04-09 19:31:02 +00:00
Guido van Rossum fc29646a2e Don't use (PyObject *)PyObject_Type(x). It is a leaky and verbose way
of saying x->ob_type.
2003-04-09 17:53:22 +00:00
Just van Rossum 547eb42d75 tentative fix for #712322: modification time stamp checking failed
when DST began.
2003-04-08 20:07:15 +00:00
Tim Peters 730f5535ba s/referrents/referents/g. Gotta love that referrers remains rife with rs. 2003-04-08 17:17:17 +00:00
Tim Peters 0f81ab6d88 Finished implementing gc.get_referrents(): dealt with error and end
cases, wrote docs, added a test.
2003-04-08 16:39:48 +00:00
Tim Peters fb2ab4d5ae Comment repair; no semantic changes. 2003-04-07 22:41:24 +00:00
Tim Peters f6b8045ca5 Reworked has_finalizer() to use the new _PyObject_Lookup() instead
of PyObject_HasAttr(); the former promises never to execute
arbitrary Python code.  Undid many of the changes recently made to
worm around the worst consequences of that PyObject_HasAttr() could
execute arbitrary Python code.

Compatibility is hard to discuss, because the dangerous cases are
so perverse, and much of this appears to rely on implementation
accidents.

To start with, using hasattr() to check for __del__ wasn't only
dangerous, in some cases it was wrong:  if an instance of an old-
style class didn't have "__del__" in its instance dict or in any
base class dict, but a getattr hook said __del__ existed, then
hasattr() said "yes, this object has a __del__".  But
instance_dealloc() ignores the possibility of getattr hooks when
looking for a __del__, so while object.__del__ succeeds, no
__del__ method is called when the object is deleted.  gc was
therefore incorrect in believing that the object had a finalizer.

The new method doesn't suffer that problem (like instance_dealloc(),
_PyObject_Lookup() doesn't believe __del__ exists in that case), but
does suffer a somewhat opposite-- and even more obscure --oddity:
if an instance of an old-style class doesn't have "__del__" in its
instance dict, and a base class does have "__del__" in its dict,
and the first base class with a "__del__" associates it with a
descriptor (an object with a __get__ method), *and* if that
descriptor raises an exception when __get__ is called, then
(a) the current method believes the instance does have a __del__,
but (b) hasattr() does not believe the instance has a __del__.

While these disagree, I believe the new method is "more correct":
because the descriptor *will* be called when the object is
destructed, it can execute arbitrary Python code at the time the
object is destructed, and that's really what gc means by "has a
finalizer":  not specifically a __del__ method, but more generally
the possibility of executing arbitrary Python code at object
destruction time.  Code in a descriptor's __get__() executed at
destruction time can be just as problematic as code in a
__del__() executed then.

So I believe the new method is better on all counts.

Bugfix candidate, but it's unclear to me how all this differs in
the 2.2 branch (e.g., new-style and old-style classes already
took different gc paths in 2.3 before this last round of patches,
but don't in the 2.2 branch).
2003-04-07 19:21:15 +00:00
Tim Peters 1155887a74 initgc(): Rewrote to use the PyModule_AddXYZ API; cuts code size. 2003-04-06 23:30:52 +00:00
Tim Peters 259272b7a0 handle_finalizers(): Rewrote to call append_objects() and gc_list_merge()
instead of looping.  Smaller and clearer.  Faster, too, when we're not
appending to gc.garbage:  gc_list_merge() takes constant time, regardless
of the lists' sizes.

append_objects():  Moved up to live with the other list manipulation
utilities.
2003-04-06 19:41:39 +00:00
Tim Peters 50c61d5a6c Switched from METH_VARARGS to METH_NOARGS for the 7 module functions that
take no arguments; cuts generated code size.
2003-04-06 01:50:50 +00:00
Tim Peters bf384c256e Reworked move_finalizer_reachable() to create two distinct lists:
externally unreachable objects with finalizers, and externally unreachable
objects without finalizers reachable from such objects.  This allows us
to call has_finalizer() at most once per object, and so limit the pain of
nasty getattr hooks.  This fixes the failing "boom 2" example Jeremy
posted (a non-printing variant of which is now part of test_gc), via never
triggering the nasty part of its __getattr__ method.
2003-04-06 00:11:39 +00:00
Tim Peters f6ae7a43eb move_finalizers(): Rewrote. It's not necessary for this routine
to special-case classic classes, or to worry about refcounts;
has_finalizer() deleted the current object iff the first entry in
the unreachable list has changed.  I don't believe it was correct
to check for ob_refcnt == 1, either:  the dealloc routine would get
called by Py_DECREF then, but there's nothing to stop the dealloc
routine from ressurecting the object, and then gc would remain at
the head of the unreachable list despite that its refcount temporarily
fell to 0 (and that would lead to an infinite loop in move_finalizers()).

I'm still worried about has_finalizer() resurrecting other objects
in the unreachable list:  what's to stop them from getting collected?
2003-04-05 18:40:50 +00:00
Tim Peters 86b993b6cf New comments. Rewrote has_finalizer() as a sequence of ifs instead of
squashed-together conditional operators; makes it much easier to step
thru in the debugger, and to set a breakpoint on the only dangerous
path.
2003-04-05 17:35:54 +00:00
Tim Peters 93ad66dea9 Fixed new seemingly random segfaults, by moving the initialization of
delstr from initgc() into collect().  initgc() isn't called unless the
user explicitly imports gc, so can be used only for initialization of
user-visible module features; delstr needs to be initialized for proper
internal operation, whether or not gc is explicitly imported.

Bugfix candidate?  I don't know whether the new bug was backported to
2.2 already.
2003-04-05 17:15:44 +00:00
Jeremy Hylton ce136e985a Fix Tim's boom example.
move_finalizers() moves every object from unreachable to collectable
or finalizers, unless the object is deallocated first.
2003-04-04 19:59:06 +00:00
Greg Ward 76ffb1918d Use fcntl() to put the audio device *back* into blocking mode after
opening it in non-blocking mode.  Both Guido and David Hammerton have
reported that this fixes their problems with ossaudiodev -- hooray!
2003-04-04 01:47:42 +00:00
Jeremy Hylton 059b094e29 Add get_referrents() helper function. 2003-04-03 16:29:13 +00:00
Jeremy Hylton 5bd378bfca Add get_referrents() helper function. 2003-04-03 16:28:38 +00:00
Martin v. Löwis 7fb697b5d2 Revert Patch #670715: iconv support. 2003-04-03 04:49:12 +00:00
Barry Warsaw 1baa982c31 init_bsddb(): Added a few symbols that Greg forgot. 2003-03-31 19:51:29 +00:00
Neal Norwitz ddb4f62650 SF patch #667548, Add some audio constants by Michael Pruett
Also remove a few unused variables.  Built on IRIX 6.5.
2003-03-30 21:49:18 +00:00
Neal Norwitz 1ac3e39913 Get build working with pre-C99 compilers 2003-03-30 20:51:29 +00:00
Martin v. Löwis f26d63b3e1 Patch #650412: Check whether the address of flock and getpagesize
can be taken, and use _SC_PAGE_SIZE if getpagesize is not available.
2003-03-30 17:23:49 +00:00
Martin v. Löwis 852ba7eb2a Patch #672053: Return a result from Py_Main, instead of exiting. 2003-03-30 17:09:58 +00:00
Martin v. Löwis e98922fb80 Patch #695250: Suppress COPYRIGHT if site.py is not read. Fixes #672614.
Will backport to 2.2.
2003-03-30 17:00:39 +00:00
Martin v. Löwis a965649386 Wrap thread stuff in WITH_THREAD. Fixes #704641. 2003-03-30 08:44:58 +00:00
Martin v. Löwis 52ae6f67d9 Fake bool API for Python 2.2. 2003-03-30 08:26:04 +00:00
Martin v. Löwis b9a0f91218 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285. 2003-03-29 10:06:18 +00:00
Gregory P. Smith 6e5c1792d9 4.1.5 2003-03-27 17:25:10 +00:00
Gregory P. Smith fe11d3e0d4 Adds support for the DBEnv->set_timeout() method. 2003-03-27 17:23:29 +00:00
Skip Montanaro a16b21fb0a add comment about 2.2 compatibility
dump empty TODO comment
2003-03-23 14:32:54 +00:00
Neal Norwitz 29fd2baf82 Make private function and data static. 2003-03-23 13:21:03 +00:00
Neal Norwitz 2deaddb0d6 Get rid of warning on IRIX 2003-03-21 03:08:31 +00:00
Neal Norwitz b59798b157 Add support for os.openpty() on AIX which uses /dev/ptc instead of /dev/ptmx. 2003-03-21 01:43:31 +00:00
Tim Peters ef4b7ed42b Squash compiler wng about signed-vs-unsigned mismatch. 2003-03-21 01:35:28 +00:00
Skip Montanaro 2497982bbb add _csv build line 2003-03-20 23:37:24 +00:00