Commit Graph

3340 Commits

Author SHA1 Message Date
Tim Peters 64c04d1df3 The module docstring had an RCS ID from 1999 embedded in it. Enough
already <wink>.
2003-02-01 06:27:59 +00:00
Tim Peters cba30e2c96 Trimmed trailing whitespace. 2003-02-01 06:24:36 +00:00
Tim Peters 797ec24e87 Added #defines for proto 2 opcodes; gave the Pickler a proto member;
removed woefully inadequate opcode docs and pointed to pickletools.py
instead.
2003-02-01 06:22:36 +00:00
Tim Peters 70533e28ad New functions alloc_{time,datetime}. Got rid of all setstate-like
functions.  Reworked {time,datetime}_new() to do what their corresponding
setstates used to do in their state-tuple-input paths, but directly,
without constructing an object with throwaway state first.  Tightened
the "is this a state tuple input?" paths to check the presumed state
string-length too, and to raise an exception if the optional second state
element isn't a tzinfo instance (IOW, check these paths for type errors
as carefully as the normal paths).
2003-02-01 04:40:04 +00:00
Tim Peters b57f8f02ba There's no good reason for datetime objects to expose __getstate__()
anymore either, so don't.  This also allows to get rid of obscure code
making __getnewargs__ identical to __getstate__ (hmm ... hope there
wasn't more to this than I realize!).
2003-02-01 02:54:15 +00:00
Tim Peters 1f1b2d2e68 Removed all uses of the out-of-favor __safe_for_unpickling__ magic
attr, and copy_reg.safe_constructors.
2003-02-01 02:16:37 +00:00
Tim Peters 371935fc06 All over: changed comments to reflect pickling is straightforward now,
not the maze it was.
2003-02-01 01:52:50 +00:00
Tim Peters 8a60c2238b delta_setstate(): This waS no longer referenced, so nukeit.
delta_reduce():  Simplified.
2003-02-01 01:47:29 +00:00
Raymond Hettinger 96ef8115dd Move itertools module from the sandbox and into production. 2003-02-01 00:10:11 +00:00
Tim Peters 506be287aa The various datetime object __setstate__() methods are no longer public
(pickling no longer needs them, and immutable objects shouldn't have
visible __setstate__() methods regardless).  Rearranged the code to
put the internal setstate functions in the constructor sections.
Repaired the timedelta reduce() method, which was still producing
stuff that required a public timedelta.__setstate__() when unpickling.
2003-01-31 22:27:17 +00:00
Guido van Rossum 8e0ad0cb0b Ignore the state returned by __reduce__ if it is Py_None. 2003-01-31 21:10:31 +00:00
Guido van Rossum 8f24cdc0d5 SF patch #678257 by Geoff Talvola.
In sendall(), do an internal select before each send() call, instead
of only for the first one.
2003-01-31 18:15:58 +00:00
Guido van Rossum 4f707ac8b1 SF patch 676472 by Geoff Talvola, reviewed by Ben Laurie.
Geoff writes:
  This is yet another patch to _ssl.c that sets the
  underlying BIO to non-blocking if the socket being
  wrapped is non-blocking. It also correctly loops when
  SSL_connect, SSL_write, or SSL_read indicates that it
  needs to read or write more bytes.

  This seems to fix bug #673797 which was not fixed by my
  previous patch.
2003-01-31 18:13:18 +00:00
Walter Dörwald 2e0b18af30 Change the treatment of positions returned by PEP293
error handers in the Unicode codecs: Negative
positions are treated as being relative to the end of
the input and out of bounds positions result in an
IndexError.

Also update the PEP and include an explanation of
this in the documentation for codecs.register_error.

Fixes a small bug in iconv_codecs: if the position
from the callback is negative *add* it to the size
instead of substracting it.

From SF patch #677429.
2003-01-31 17:19:08 +00:00
Walter Dörwald 757246c189 Initialize swappedinput to silence the compiler warning about
uninitialized variables.
2003-01-31 16:26:50 +00:00
Tim Peters 5b8132ffa3 _PyLong_NumBits(): The definition of this was too specific to the quirky
needs of pickling longs.  Backed off to a definition that's much easier
to understand.  The pickler will have to work a little harder, but other
uses are more likely to be correct <0.5 wink>.

_PyLong_Sign():  New teensy function to characterize a long, as to <0, ==0,
or >0.
2003-01-31 15:52:05 +00:00
Tim Peters abc7cd27ff Backward branches are disgusting, at least when a forward branch
is just as easy.
2003-01-31 01:37:35 +00:00
Guido van Rossum 177e41a117 Change the approach to pickling to use __reduce__ everywhere. Most
classes have a __reduce__ that returns (self.__class__,
self.__getstate__()).  tzinfo.__reduce__() is a bit smarter, calling
__getinitargs__ and __getstate__ if they exist, and falling back to
__dict__ if it exists and isn't empty.
2003-01-30 22:06:23 +00:00
Walter Dörwald b4ff1113ca Check whether the choosen encoding requires byte swapping
for this iconv() implementation in the init function.

For encoding: use a byteswapped version of the input if
neccessary.

For decoding: byteswap every piece returned by iconv()
if neccessary (but not those pieces returned from the
callback)

Comment out test_sane() in the test script, because
whether this works depends on whether byte swapping
is neccessary or not (an on Py_UNICODE_SIZE)
2003-01-30 19:55:28 +00:00
Michael W. Hudson 0e986a312f I was in this module anyway, so I did some janitorial things.
METH_NOARGS functions are still called with two arguments, one NULL,
so put that back into the function definitions (I didn't know this
until recently).

Make get_history_length() METH_NOARGS.
2003-01-30 14:17:16 +00:00
Michael W. Hudson 796df156cd Add the get_completer() function based on Michael Stone's patch in
[ 676342 ] after using pdb readline does not work correctly

which is required to fix that bug.  So maaybe a bugfix candidate.
2003-01-30 10:12:51 +00:00
Michael W. Hudson 5e83b7a9cc Teach the parsermodule about floor division. Fixes
[ 676521 ] parser module validation failure

bugfix candidate.
2003-01-29 14:20:23 +00:00
Tim Peters baefd9e552 Added new private API function _PyLong_NumBits. This will be used at the
start for the C implemention of new pickle LONG1 and LONG4 opcodes (the
linear-time way to pickle a long is to call _PyLong_AsByteArray, but
the caller has no idea how big an array to allocate, and correct
calculation is a bit subtle).
2003-01-28 20:37:45 +00:00
Barry Warsaw 7871154c2e Bump the version number 2003-01-28 17:30:46 +00:00
Fred Drake 4faea015f7 Update to the final version released as Expat 1.95.6 (maintaining
Martin's integration changes).
2003-01-28 06:42:40 +00:00
Guido van Rossum 99d4abf8a2 Support socket timeout in SSL, by Geoff Talvola.
(SF patch #675750, to fix SF bug #675552.)
2003-01-27 22:22:50 +00:00
Martin v. Löwis 7a565f0b9b Fix reference counting of iconvcodec_Type. Fixes #670715.
Remove GC code; the base type does not need GC.
2003-01-27 11:39:04 +00:00
Neal Norwitz 57c115c8ad Get rid of compiler warnings on Redhat 2003-01-26 16:26:20 +00:00
Martin v. Löwis 727fe66f27 Add _iconv_codec to Setup.dist. Use PyModule_ functions. 2003-01-26 11:48:20 +00:00
Martin v. Löwis 9789aefa61 Patch #670715: Universal Unicode Codec for POSIX iconv. 2003-01-26 11:30:36 +00:00
Martin v. Löwis c35d199404 Undo inclusion of Python.h. Remove HAVE_MEMCPY section.
Update Windows command line.
2003-01-26 08:40:50 +00:00
Martin v. Löwis 94ac339d21 Uncomment usage of expat_config.h 2003-01-25 22:48:51 +00:00
Martin v. Löwis fc03a94aac Incorporate Expat 1.95.6. 2003-01-25 22:41:29 +00:00
Tim Peters 8d81a012ef date and datetime comparison: when we don't know how to
compare against "the other" argument, we raise TypeError,
in order to prevent comparison from falling back to the
default (and worse than useless, in this case) comparison
by object address.

That's fine so far as it goes, but leaves no way for
another date/datetime object to make itself comparable
to our objects.  For example, it leaves Marc-Andre no way
to teach mxDateTime dates how to compare against Python
dates.

Discussion on Python-Dev raised a number of impractical
ideas, and the simple one implemented here:  when we don't
know how to compare against "the other" argument, we raise
TypeError *unless* the other object has a timetuple attr.
In that case, we return NotImplemented instead, and Python
will give the other object a shot at handling the
comparison then.

Note that comparisons of time and timedelta objects still
suffer the original problem, though.
2003-01-24 22:36:34 +00:00
Tim Peters 8bb5ad2e56 Updated the astimezone() proof to recover from all the last week's
changes (and there were a lot of relevant changes!).
2003-01-24 02:44:45 +00:00
Neal Norwitz 2fbe5378f9 Fix typo 2003-01-23 21:09:05 +00:00
Tim Peters 2a44a8d332 SF bug 660872: datetimetz constructors behave counterintuitively (2.3a1).
This gives much the same treatment to datetime.fromtimestamp(stamp, tz) as
the last batch of checkins gave to datetime.now(tz):  do "the obvious"
thing with the tz argument instead of a senseless thing.
2003-01-23 20:53:10 +00:00
Tim Peters 10cadce41e Reimplemented datetime.now() to be useful. 2003-01-23 19:58:02 +00:00
Tim Peters b1049e8eca fromutc(): Repair incorrect failure return, as noted by NealN. Thanks! 2003-01-23 17:20:36 +00:00
Tim Peters 52dcce24e2 Bringing the code and test suite into line with doc and NEWS changes
checked in two days agao:

Refactoring of, and new rules for, dt.astimezone(tz).

dt must be aware now, and tz.utcoffset() and tz.dst() must not return None.
The old dt.astimezone(None) no longer works to change an aware datetime
into a naive datetime; use dt.replace(tzinfo=None) instead.

The tzinfo base class now supplies a new fromutc(self, dt) method, and
datetime.astimezone(tz) invokes tz.fromutc().  The default implementation
of fromutc() reproduces the same results as the old astimezone()
implementation, but tzinfo subclasses can override fromutc() if the
default implementation isn't strong enough to get the correct results
in all cases (for example, this may be necessary if a tzinfo subclass
models a time zone whose "standard offset" (wrt UTC) changed in some
year(s), or in some variations of double-daylight time -- the creativity
of time zone politics can't be captured in a single default implementation).
2003-01-23 16:36:11 +00:00
Martin v. Löwis 70c3dda2fb Convert booleans to integers in IntVar.set. Fixes #671741.
Return booleans from _tkinter.getboolean.
Convert booleans to Tcl booleans in AsObj.
2003-01-22 09:17:38 +00:00
Martin v. Löwis cd9a8b6bcf Avoid usage of PyDoc_STR in 2.2 compatibility code. 2003-01-21 21:52:57 +00:00
Martin v. Löwis c847f4040d Conditionalize features not found in PyXML 1.95.2. 2003-01-21 11:09:21 +00:00
Martin v. Löwis 069dde2be3 Merge with PyXML 1.71:
60: Added support for the SkippedEntityHandler, new in Expat 1.95.4.
61: Added support for namespace prefixes, which can be enabled by setting the
    "namespace_prefixes" attribute on the parser object.
65: Disable profiling changes for Python 2.0 and 2.1.
66: Update pyexpat to export the Expat 1.95.5 XML_GetFeatureList()
    information, and tighten up a type declaration now that Expat is using
    an incomplete type rather than a void * for the XML_Parser type.
67: Clarified a comment.
    Added support for XML_UseForeignDTD(), new in Expat 1.95.5.
68: Refactor to avoid partial duplication of the code to construct an
    ExpatError instance, and actually conform to the API for the exception
    instance as well.
69: Remove some spurious trailing whitespace.
    Add a special external-entity-ref handler that gets installed once a
    handler has raised a Python exception; this can cancel actual parsing
    earlier if there's an external entity reference in the input data
    after the the Python excpetion has been raised.
70: Untabify APPEND.
71: Backport PyMODINIT_FUNC for 2.2 and earlier.
2003-01-21 10:58:18 +00:00
Tim Peters 327098a613 New rule for tzinfo subclasses handling both standard and daylight time:
When daylight time ends, an hour repeats on the local clock (for example,
in US Eastern, the clock jumps from 1:59 back to 1:00 again).  Times in
the repeated hour are ambiguous.  A tzinfo subclass that wants to play
with astimezone() needs to treat times in the repeated hour as being
standard time.  astimezone() previously required that such times be
treated as daylight time.  There seems no killer argument either way,
but Guido wants the standard-time version, and it does seem easier the
new way to code both American (local-time based) and European (UTC-based)
switch rules, and the astimezone() implementation is simpler.
2003-01-20 22:54:38 +00:00
Neal Norwitz fa56e2dc40 SF # 669553, fix memory (ref) leaks
Will backport.
2003-01-19 15:40:09 +00:00
Tim Peters 513a1cd103 Windows flavor of floatsleep(): folded long lines, introduced a temp
var for clarity.
2003-01-19 04:54:58 +00:00
Raymond Hettinger 9543b34006 SF patch #670423: Add missing identity tests to operator.c 2003-01-18 23:22:20 +00:00
Tim Peters 8b19a93b87 When time.localtime() is passed a tick count the platform C localtime()
function can't handle, don't raise IOError -- that doesn't make sense.
Raise ValueError instead.

Bugfix candidate.
2003-01-17 20:08:54 +00:00
Gregory P. Smith b6c9f78074 bugfix: do not double-close DB cursor during deallocation when the
underlying DB has already been closed (and thus all of its cursors).
        This fixes a potential segfault.
        SF pybsddb bug id 667343
bugfix: close the DB object when raising an exception due to an error
        during DB.open.  This prevents an exception when closing the
        environment about not all databases being closed.
        SF pybsddb bug id 667340
2003-01-17 08:42:50 +00:00
Gregory P. Smith aa71f5f2b4 bugfix: allow the module to work with python compiled without thread support.
closes sourceforge pybsddb bug id 669533.
2003-01-17 07:56:16 +00:00
Gregory P. Smith c25fd3fb48 bugfix: disallow use of DB_TXN after commit() or abort(), prevents a
coredump or segmentation violation.

Sourceforge patch ID 664896:
http://sourceforge.net/tracker/index.php?func=detail&aid=664896&group_id=13900&atid=313900

The bug was reported on the pybsddb-users mailing list.
2003-01-17 07:52:59 +00:00
Tim Peters a9bc168f95 Got rid of the internal datetimetz type. 2003-01-11 03:39:11 +00:00
Tim Peters a032d2eb7f Minor fiddling to make the next part easier. Introduced an internal
HASTZINFO() macro.
2003-01-11 00:15:54 +00:00
Neal Norwitz faa7b9bb4c Get build working on Redhat 7.2 linux 2.4.7 2003-01-10 21:27:54 +00:00
Neal Norwitz e604c02a80 SF #665913, Fix mmap module core dump with unix
Closing an mmap'ed file (calling munmap) twice on Solaris caused a core dump.

Will backport.
2003-01-10 20:52:16 +00:00
Neal Norwitz 8e914d9a1d Get rid of compiler warnings 2003-01-10 15:29:16 +00:00
Tim Peters 37f398282b Got rid of the timetz type entirely. This was a bit trickier than I
hoped it would be, but not too bad.  A test had to change:
time.__setstate__() can no longer add a non-None tzinfo member to a time
object that didn't already have one, since storage for a tzinfo member
doesn't exist in that case.
2003-01-10 03:49:02 +00:00
Tim Peters 33e0f383d4 Removed more now-pointless pickle code. 2003-01-10 02:05:14 +00:00
Tim Peters 7d4b315cca Deleted pickle/unpickle code for the old datetime and time classes -- it's
unreachable now.
2003-01-08 20:51:36 +00:00
Tim Peters 0bf60bd67f Utterly minimal changes to collapse datetimetz into datetime, and timetz
into time.  This is little more than *exporting* the datetimetz object
under the name "datetime", and similarly for timetz.  A good implementation
of this change requires more work, but this is fully functional if you
don't stare too hard at the internals (e.g., right now a type named
"datetime" shows up as a base class of the type named "datetime").  The
docs also need extensive revision, not part of this checkin.
2003-01-08 20:40:01 +00:00
Jack Jansen b8941f2dbe Added a couple of casts to make this compile with CodeWarrior. 2003-01-08 16:28:45 +00:00
Barry Warsaw 5676bd1c2d all_ins(): EX_OK and friends, constants from sysexits.h 2003-01-07 20:57:09 +00:00
Guido van Rossum 6d0d3655af Fix from Michael Stone for SF bug #660476 and #513033 (bogus thread
state swaps in readline).
2003-01-07 20:34:19 +00:00
Guido van Rossum 05ac449d29 A few more whitespace normalizations. 2003-01-07 20:04:12 +00:00
Guido van Rossum 74f3143d18 Various cleanups:
- Whitespace normalization.

- Cleaned up some comments.

- Broke long lines.
2003-01-07 20:01:29 +00:00
Raymond Hettinger 625812f618 SF patch #662433: Fill arraymodule's tp_iter and sq_contains slots 2003-01-07 01:58:52 +00:00
Jason Tishler fb8595df4f Patch #661760: Cygwin auto-import module patch
The attached patch enables shared extension
modules to build cleanly under Cygwin without
moving the static initialization of certain function
pointers (i.e., ones exported from the Python
DLL core) to a module initialization function.

Additionally, this patch fixes the modules that
have been changed in the past to accommodate
Cygwin.
2003-01-06 12:41:26 +00:00
Tim Peters 75a6e3bd1a datetime_from_timet_and_us(): ignore leap seconds if the platform
localtime()/gmtime() insists on delivering them, + associated doc
changes.

Redid the docs for datetimtez.astimezone().
2003-01-04 18:17:36 +00:00
Martin v. Löwis 3a57d9de07 Fix typo. 2003-01-04 08:54:59 +00:00
Martin v. Löwis 6a759d9e00 Remove appartment check from dooneevent. Fixes #660961.
Check whether self is NULL in mainloop.
2003-01-04 08:36:57 +00:00
Tim Peters adf642038e A new implementation of astimezone() that does what we agreed on in all
cases, plus even tougher tests of that.  This implementation follows
the correctness proof very closely, and should also be quicker (yes,
I wrote the proof before the code, and the code proves the proof <wink>).
2003-01-04 06:03:15 +00:00
Neal Norwitz 506a224688 Fix compiler warning 2003-01-04 01:02:25 +00:00
Martin v. Löwis 3919571f82 Wrap doc strings in PyDoc_STRVAR. Fix .string docstring. Provide default
macro definitions for older Python releases.
2003-01-04 00:33:13 +00:00
Tim Peters 4fede1a36b Completed astimezone()'s correctness proof. This also proves we can get
the desired compromise behavior during the "problem hour" when DST ends
cheaply (but I haven't yet implemented that).
2003-01-04 00:26:59 +00:00
Martin v. Löwis 25c7b50e8f Convert Tcl path objects to strings. Fixes #661357.
Provide .string attribute and __unicode for Tcl_Objs.
2003-01-04 00:08:09 +00:00
Just van Rossum 9a3129c148 Fix for bug #661136
Lesson learned: kids should not be allowed to use API's starting
with an underscore :-/
zipimport in 2.3a1 is even more broken than I thought: I attemped
to _PyString_Resize a string created by PyString_FromStringAndSize,
which fails for strings with length 0 or 1 since the latter returns
an interned string in those cases. This would cause a SystemError
with empty source files (and no matching pyc) in the zip archive.
I rewrote the offending code to simply allocate a new buffer and
avoid _PyString_Resize altogether.
Added a test that would've caught the problem.
2003-01-03 11:18:56 +00:00
Raymond Hettinger 36cd2bf459 SF patch 660559: Use METH_O and METH_NOARGS where possible
Simplify code and speed access by using PyArg_UnpackTuple, METH_O and
METH_NOARGS in three modules that can benefit from it.
2003-01-03 08:24:58 +00:00
Tim Peters 397301eccb The tzinfo methods utcoffset() and dst() must return a timedelta object
(or None) now.  In 2.3a1 they could also return an int or long, but that
was an unhelpfully redundant leftover from an earlier version wherein
they couldn't return a timedelta.  TOOWTDI.
2003-01-02 21:28:08 +00:00
Tim Peters 710fb1548a astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
2003-01-02 19:35:54 +00:00
Tim Peters c5dc4da125 The astimezone() correctness proof endured much pain to prove what
turned out to be 3 special cases of a single more-general result.
Proving the latter instead is a real simplification.
2003-01-02 17:55:03 +00:00
Tim Peters 5d644dd25a SF bug 661086: datetime.today() truncates microseconds.
On Windows, it was very common to get microsecond values (out of
.today() and .now()) of the form 480999, i.e. with three trailing
nines.  The platform precision is .001 seconds, and fp rounding
errors account for the rest.  Under the covers, that 480999 started
life as the fractional part of a timestamp, like .4809999978.
Rounding that times 1e6 cures the irritation.

Confession:  the platform precision isn't really .001 seconds.  It's
usually worse.  What actually happens is that MS rounds a cruder value
to a multiple of .001, and that suffers its own rounding errors.

A tiny bit of refactoring added a new internal utility to round
doubles.
2003-01-02 16:32:54 +00:00
Just van Rossum d35c6db526 Ugh, zipimport is virtually broken in 2.3a1 :-( It worked by accident in
the test set as it only tested with a zip archive in the current directory,
but it doesn't work at all for packages when the zip archive was specified
as an absolute path. It's a real embarrassing bug: a strchr call should
have been strrchr; fever apparently implies dyslexia.

Second stupid bug: the zipimport test failed with a name error
__importer__ (which I had renamed to __loader__ everywhere but here).
I would've sworn I ran the test after that change but that can't be true.
What I don't understand that noone reported a failing test_zipimport.py
before the release of 2.3a1.
2003-01-02 12:55:48 +00:00
Andrew MacIntyre 34d3e2d22a OS/2 sockets do not support AF_UNIX, even though EMX headers define it 2003-01-02 12:45:34 +00:00
Tim Peters c3bb26a099 Completed astimezone's correctness proof. That doesn't mean it's
correct by your lights, it means that-- barring coding errors --it
implements what it intended to implement.
2003-01-02 03:14:59 +00:00
Tim Peters f36151556f A quicker astimezone() implementation, rehabilitating an earlier
suggestion from Guido, along with a formal correctness proof of the
trickiest bit.  The intricacy of the proof reveals how delicate this
is, but also how robust the conclusion:  correctness doesn't rely on
dst() returning +- one hour (not all real time zones do!), it only
relies on:

1. That dst() returns a (any) non-zero value if and only if daylight
   time is in effect.

and

2. That the tzinfo subclass implements a consistent notion of time zone.

The meaning of "consistent" was a hidden assumption, which is now an
explicit requirement in the docs.  Alas, it's an unverifiable (by the
datetime implementation) requirement, but so it goes.
2003-01-01 21:51:37 +00:00
Martin v. Löwis 14e73b1864 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal. 2003-01-01 09:51:12 +00:00
Tim Peters b5a16f3375 datetimetz_astimezone(): Speed optimizations -- although I'd rather
find a more elegant algorithm (OTOH, the hairy new implementation allows
user-written tzinfo classes to be elegant, so it's a big win even if
astimezone() remains hairy).

Darn!  I've only got 10 minutes left to get falling-down drunk!  I suppose
I'll have to smoke crack instead now.
2003-01-01 04:48:01 +00:00
Neal Norwitz 13af1142fc Try to get compilation working for cygwin 2002-12-31 21:55:16 +00:00
Jason Tishler bbe8961698 Patch #660485: Cygwin _tkinter Tcl/Tk 8.3 patch
The attached patch enables Cygwin Python to
build cleanly against the latest Cygwin Tcl/Tk
which is based on Tcl/Tk 8.3. It also prevents
building against the real X headers, if installed.
2002-12-31 20:30:46 +00:00
Jeremy Hylton accb62b28e SF patch [ 597919 ] compiler package and SET_LINENO
A variety of changes from Michael Hudson to get the compiler working
with 2.3.  The primary change is the handling of SET_LINENO:

# The set_lineno() function and the explicit emit() calls for
# SET_LINENO below are only used to generate the line number table.
# As of Python 2.3, the interpreter does not have a SET_LINENO
# instruction.  pyassem treats SET_LINENO opcodes as a special case.

A few other small changes:
 - Remove unused code from pycodegen and pyassem.
 - Fix error handling in parsermodule.  When PyParser_SimplerParseString()
   fails, it sets an exception with detailed info.  The parsermodule
   was clobbering that exception and replacing it was a generic
   "could not parse string" exception.  Keep the original exception.
2002-12-31 18:17:44 +00:00
Tim Peters 521fc15e62 A new, and much hairier, implementation of astimezone(), building on
an idea from Guido.  This restores that the datetime implementation
never passes a datetime d to a tzinfo method unless d.tzinfo is the
tzinfo instance whose method is being called.  That in turn allows
enormous simplifications in user-written tzinfo classes (see the Python
sandbox US.py and EU.py for fully fleshed-out examples).

d.astimezone(tz) also raises ValueError now if d lands in the one hour
of the year that can't be expressed in tz (this can happen iff tz models
both standard and daylight time).  That it used to return a nonsense
result always ate at me, and it turned out that it seemed impossible to
force a consistent nonsense result under the new implementation (which
doesn't know anything about how tzinfo classes implement their methods --
it can only infer properties indirectly).  Guido doesn't like this --
expect it to change.

New tests of conversion between adjacent DST-aware timezones don't pass
yet, and are commented out.

Running the datetime tests in a loop under a debug build leaks 9
references per test run, but I don't believe the datetime code is the
cause (it didn't leak the last time I changed the C code, and the leak
is the same if I disable all the tests that invoke the only function
that changed here).  I'll pursue that next.
2002-12-31 17:36:56 +00:00
Martin v. Löwis ba2f875d90 Eliminate C++ comment. 2002-12-31 17:34:30 +00:00
Neal Norwitz 6700e47b3c Fix compilation errors on HPUX11 2002-12-31 16:16:07 +00:00
Just van Rossum 3f0b542f25 removed unused get_short() function 2002-12-31 15:47:42 +00:00
Martin v. Löwis c8b2e770cf Restore signalhandler in case of error. Fix type of signal handler. 2002-12-31 14:30:26 +00:00
Martin v. Löwis 24a880b499 Patch #656590: /dev/ptmx support for ptys. 2002-12-31 12:55:15 +00:00
Neal Norwitz b70557f13d Make sure zip_path is null-terminated, since it's on the stack 2002-12-31 12:45:12 +00:00
Just van Rossum f8b6de168b - added missing decref
- whitespace normalization
2002-12-31 09:51:59 +00:00
Greg Ward 744f0fd655 Add build_namelists() to expose the OSS macros SOUND_DEVICE_LABELS and
SOUND_DEVICE_NAMES as 'control_labels' and 'control_names'.
2002-12-31 03:23:59 +00:00
Greg Ward 58ae13c1b2 Rename the parameter 'xp' in several methods to 'self', since that's
what it is.
2002-12-31 03:07:21 +00:00
Greg Ward 499b73e1cd For symmetry with the mixer interface, rename oss_t to oss_audio_t and
OSSType to OSSAudioType.
2002-12-31 03:04:52 +00:00
Greg Ward da1cacb38b Add a bunch of comments to clearly delineate sections of the code. 2002-12-31 03:02:23 +00:00
Greg Ward 2d6f9a9a86 Yet another renaming of some mixer methods:
devices(), stereodevices(), recdevices() ->
  controls(), stereocontrols(), reccontrols()

Based on recommendation of Hannu Savolainen <hannu@opensound.com>:

  The right term to use for things like bass/treble/mic/vol/etc is
  "control".

  "Device" refers to different mixer devices (/dev/mixer0 to /dev/mixerN).

  "Channel" cannot be used because it refers to mono/stereo/multich
  channels. In fact most mixer controls have left/right channels so ...
2002-12-31 02:54:43 +00:00
Greg Ward f05aa10eae Rename more mixer methods: getrecsrc() -> get_recsrc(),
setrecsrc() -> set_recsrc().
2002-12-30 23:19:32 +00:00
Jack Jansen 5eaeaf9174 Added casts to forestall warnings with MetroWerks. 2002-12-30 23:06:14 +00:00
Tim Peters f271c272a2 Squashed compiler wng from MSVC6. 2002-12-30 22:44:03 +00:00
Tim Peters 1ea93f2b1d Wouldn't compile on Windows; fixed. 2002-12-30 22:42:57 +00:00
Just van Rossum 52e14d640b PEP 302 + zipimport:
- new import hooks in import.c, exposed in the sys module
- new module called 'zipimport'
- various changes to allow bootstrapping from zip files

I hope I didn't break the Windows build (or anything else for that
matter), but then again, it's been sitting on sf long enough...

Regarding the latest discussions on python-dev: zipimport sets
pkg.__path__ as specified in PEP 273, and likewise, sys.path item such as
/path/to/Archive.zip/subdir/ are supported again.
2002-12-30 22:08:05 +00:00
Tim Peters e39a80c362 Bite the bullet on all the indirect timetz and datetimetz tzinfo methods:
make the callers figure out the right tzinfo arguments to pass, instead of
making the callees guess.  The code is uglier this way, but it's less
brittle (when the callee guesses, the caller can get surprised).
2002-12-30 21:28:52 +00:00
Barry Warsaw 9a0d779c7d Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
version 4.1.1 and works with up to BerkeleyDB 4.1.25.
2002-12-30 20:53:52 +00:00
Tim Peters bad8ff089a A step on the way to making tzinfo classes writable by mortals: get rid
of the timetz case.  A tzinfo method will always see a datetimetz arg,
or None, now.  In the former case, it's still possible that it will get
a datetimetz argument belonging to a different timezone.  That will get
fixed next.
2002-12-30 20:52:32 +00:00
Martin v. Löwis 5b177f18ee Silence cast warnings for Tcl 8.3. 2002-12-30 18:14:15 +00:00
Guido van Rossum faf5e4d48f Patch 659834 by Magnus Lie Hetland:
Check for readline 2.2 features.  This should make it possible to
compile readline.c again with GNU readline versions 2.0 or 2.1; this
ability was removed in readline.c rev. 2.49.  Apparently the older
versions are still in widespread deployment on older Solaris
installations.  With an older readline, completion behavior is subtly
different (a space is always added).
2002-12-30 16:25:41 +00:00
Greg Ward ad4d9b9749 Untabify. 2002-12-30 03:02:22 +00:00
Greg Ward e70376646e Whitespace fixes to conform to coding standards. 2002-12-30 03:01:48 +00:00
Greg Ward 5c5c577c08 Comment fix. 2002-12-30 02:58:04 +00:00
Greg Ward 37897c2672 Rename some mixer methods:
* channels() -> devices()
  * stereochannels() -> stereodevices()
  * recchannels() -> recdevices()
  * getvol() -> get()
  * setvol() -> set()
This is for (slightly) more consistency with the OSS ioctl names
(READ_DEVMASK, READ_RECMASK, READ_STEREODEVS).

Also make sure the C function names correspond more closely to the
Python method names for mixer methods.
2002-12-30 02:43:36 +00:00
Greg Ward 7b43c68162 Remove 'x_' prefix from oss_t and oss_mixer_t struct members.
(It added nothing, and served no obvious purpose.)

Export SOUND_MIXER_NRDEVICES constant.
2002-12-30 02:29:28 +00:00
Raymond Hettinger 40f6217092 SF patch 658251: Install a C implementation of the Mersenne Twister as the
core generator for random.py.
2002-12-29 23:03:38 +00:00
Raymond Hettinger 3c736f1a41 Demonstrate use of PyType_Ready() in the example. 2002-12-29 17:16:49 +00:00
Raymond Hettinger ea3fdf44a2 SF patch #659536: Use PyArg_UnpackTuple where possible.
Obtain cleaner coding and a system wide
performance boost by using the fast, pre-parsed
PyArg_Unpack function instead of PyArg_ParseTuple
function which is driven by a format string.
2002-12-29 16:33:45 +00:00
Tim Peters 4643bd9a9c Apparently FreeBSD enables some HW floating-point exceptions by default.
This can cause core dumps when Python runs.  Python relies on the 754-
(and C99-) mandated default "non-stop" mode for FP exceptions.  This
patch from Ben Laurie disables at least one FP exception on FreeBSD at
Python startup time.
2002-12-28 21:56:08 +00:00
Martin v. Löwis 5b26abb37a Gracefully delay runtime error up to 1s. Add .willdispatch(). 2002-12-28 09:23:09 +00:00
Martin v. Löwis 438b534ad0 Patch #657889: Implement posix.getloadavg. 2002-12-27 10:16:42 +00:00
Tim Peters 8702d5f33f And put back a little code duplication, in the form of asserts. 2002-12-27 02:26:16 +00:00
Tim Peters 00237037ae Squash recently-introduced code duplication. 2002-12-27 02:21:51 +00:00
Tim Peters 60c76e4016 Make comparison and subtraction of aware objects ignore tzinfo if the
operands have identical tzinfo members (meaning object identity -- "is").
I misunderstood the intent here, reading wrong conclusion into
conflicting clues.
2002-12-27 00:41:11 +00:00
Tim Peters 80475bb4d2 Implemented datetime.astimezone() and datetimetz.astimezone(). 2002-12-25 07:40:55 +00:00
Guido van Rossum 75bfd0585b Add an XXX comment about relative imports. 2002-12-24 18:10:07 +00:00
Tim Peters 12bf339aea Implemented .replace() methods for date, datetime, datetimetz, time and
timetz.
2002-12-24 05:41:27 +00:00
Jack Jansen 0a116f3a29 Squashed compiler warnings by adding casts, making sure prototypes are in
scope and looking at types.
2002-12-23 21:03:36 +00:00
Tim Peters 2736285035 call_utc_tzinfo_method(): Got rid of the label and the gotos. 2002-12-23 16:17:39 +00:00
Tim Peters d684415572 I give up: unless I write my own strftime by hand, datetime just can't
be trusted with years before 1900, so now we raise ValueError if a date or
datetime or datetimetz .strftime() method is called with a year before
1900.
2002-12-22 20:58:42 +00:00
Tim Peters 83b85f1d6c Python's strftime implementation does strange things with the year,
such that the datetime tests failed if the envar PYTHON2K was set.
This is an utter mess, and the datetime module's strftime functions
inherit it.  I suspect that, regardless of the PYTHON2K setting, and
regardless of platform limitations, the datetime strftime wrappers
will end up delivering nonsense results (or bogus exceptions) for
any year before 1900.  I should probably just refuse to accept years
earlier than that -- else we'll have to implement strftime() by hand.
2002-12-22 20:34:46 +00:00
Tim Peters 14b6941197 classify_object(): Renamed more meaningfully, to classify_utcoffset().
Also changed logic so that instances of user-defined subclasses of date,
time, and datetime are called OFFSET_NAIVE instead of OFFSET_UNKNOWN.
2002-12-22 18:10:22 +00:00
Tim Peters 855fe88b24 Implemented a Wiki suggestion:
{timetz,datetimetz}.{utcoffset,dst}() now return a timedelta (or None)
instead of an int (or None).

tzinfo.{utcoffset,dst)() can now return a timedelta (or an int, or None).

Curiously, this was much easier to do in the C implementation than in the
Python implementation (which lives in the Zope3 code tree) -- the C code
already had lots of hair to extract C ints from offset objects, and used
C ints internally.
2002-12-22 03:43:39 +00:00
Martin v. Löwis 9c36c29156 Use wcscoll for _locale.strcoll if available. 2002-12-21 18:34:06 +00:00
Tim Peters 328fff7214 format_utcoffset(): The natural type of the buflen arg is size_t, so
used that.

wrap_strftime():  Removed the most irritating uses of buf.

TestDate.test_ordinal_conversions():  The C implementation is fast enough
that we can afford to check the endpoints of every year.  Also added
tm_yday tests at the endpoints.
2002-12-20 01:31:27 +00:00
Neal Norwitz dfb8086760 Fix another long vs int mismatch. test_datetime now passes on alpha 2002-12-19 02:30:56 +00:00
Tim Peters 0b0f41cf1f Fixed typo in string. 2002-12-19 01:44:38 +00:00
Neal Norwitz c296c63c73 Fix crash on alphas due to mismatch between 'l' format and int variables. 2002-12-19 00:42:03 +00:00
Tim Peters ba873472d2 delta_str(): Purged last uses of sprintf (in favor of PyOS_snprintf). 2002-12-18 20:19:21 +00:00
Jack Jansen 51cd8a2d24 "time_second" is apparently a #define on MacOSX. Renamed the (static)
routine to py_time_second.
2002-12-17 20:57:24 +00:00
Guido van Rossum bd43e9195b Fix GCC warnings. It turns out two out of three pointed to real bugs! 2002-12-16 20:34:55 +00:00
Tim Peters 2a799bf77a datetime escapes the sandbox. The Windows build is all set. I leave it
to others to argue about how to build it on other platforms (on Windows
it's in its own DLL).
2002-12-16 20:18:38 +00:00
Raymond Hettinger 866964c3a3 Apply SF patch 652930: Add optional base argument to math.log(x[, base]). 2002-12-14 19:51:34 +00:00
Guido van Rossum 0847c5c6c7 execve(), spawnve(): add some extra sanity checking to env;
PyMapping_Check() doesn't guarantee that PyMapping_Size() won't raise
an exception, nor that keys and values are lists.

Also folded some long lines and did a little whitespace normalization.

Probably a 2.2 backport candidate.
2002-12-13 18:36:22 +00:00
Jack Jansen 747c3d3f02 We need macglue on MacPython-OS9 too. 2002-12-13 15:20:53 +00:00
Martin v. Löwis 7d1349553b Always initialize objc. 2002-12-12 19:05:48 +00:00
Marc-André Lemburg b28de0d79f Patch to make _codecs a builtin module. This is necessary since
Python 2.3 will support source code encodings which rely on the
builtin codecs being available to the parser.

Remove struct dependency from codecs.py
2002-12-12 17:37:50 +00:00
Greg Ward b69bb3d019 Typo fix. 2002-12-12 17:35:45 +00:00
Martin v. Löwis b5bfb9f38c Support threads-enabled Tcl installations. 2002-12-12 17:07:58 +00:00
Martin v. Löwis 135594648f This is not used anymore. 2002-12-11 19:55:48 +00:00
Greg Ward 3d9994d3b0 Add OSS mixer interface (from Nicholas FitzRoy-Dale <wzdd@lardcave.net>):
* add oss_mixer_t and OSSMixerType
  * add newossmixerobject(), oss_mixer_dealloc(), ossopenmixer()
  * add _do_ioctl_1_internal() to support mixer ioctls
  * add mixer methods: oss_mixer_{close,fileno,channels,stereo_channels,
    rec_channels,getvol,setvol,getrecsrc,setrecsrc}()
  * add oss_mixer_methods list
  * add oss_mixer_getattr() (why?!)
  * export SOUND_MIXER_* constants from soundcard.h
2002-12-11 15:12:01 +00:00
Greg Ward da9f853b49 Prepare for the coming mixer support patch: change _do_ioctl_0() and
_do_ioctl_1() so they take a file descriptor rather than an oss_t
pointer.
2002-12-11 14:49:59 +00:00
Greg Ward 8c6b6a9f1e Finish expunging the 'linuxaudiodev' name:
* rename oss_t to lad_t, Ladtype to OSSType,
  * rename lad_*() methods to oss_*()
  * rename lad_methods list to oss_methods
Patch and impetus supplied by Nicholas FitzRoy-Dale <wzdd@lardcave.net>.
2002-12-11 14:43:13 +00:00
Martin v. Löwis cf8f47ea95 Patch #650422: Use Posix AF_ constants instead of PF_ ones. 2002-12-11 13:10:57 +00:00
Martin v. Löwis 33ec3ba217 Remove C++ comment. Silence unsigned char* cast warning. 2002-12-07 14:57:11 +00:00
Martin v. Löwis 2fb661fb80 Remove C++ comment. 2002-12-07 14:56:36 +00:00
Tim Peters 4e52ca82ae A patch from Kevin Jacobs, plugging several leaks discovered when
running the sandbox datetime tests.

Bugfix candidate.
2002-12-07 02:43:28 +00:00
Martin v. Löwis 9e43730ca3 Don't include <ioctl.h> unless on __VMS. 2002-12-06 12:57:26 +00:00
Martin v. Löwis 79acb9edfa Patch #614055: Support OpenVMS. 2002-12-06 12:48:53 +00:00
Jason Tishler d0ebd7edb1 Patch #649060: Cygwin bz2module patch
This patch enables the bz2 module to build cleanly under Cygwin.
2002-12-05 20:31:53 +00:00
Martin v. Löwis e07e18d41b Decode untyped strings from UTF-8. 2002-12-04 19:54:36 +00:00
Skip Montanaro 56643679f4 correct wording of comments about old bsddb (now bsddb185) module 2002-12-02 00:27:10 +00:00
Greg Ward 9a568eb245 Expunge any remaining mentions of linuxaudiodev -- it's ossaudiodev now! 2002-11-30 23:20:09 +00:00
Greg Ward 97708bc6f8 Rename LinuxAudioError to OSSAudioError ('ossaudiodev.error').
Use OSSAudioError much less frequently -- all real I/O errors (ie. any
time open(), read(), write(), ioctl(), or select() return an error)
become IOError.  OSSAudioError is only used now for bad open() mode.
2002-11-30 23:17:10 +00:00
Greg Ward 1e0f57d0bb Added mode 'rw' for full-duplex (play and record at the same time) mode.
Added _EXPORT_INT macro to export an integer constant to Python-space.
Use it for all the AFMT_* constants, and update the list of AFMT_*
constants to match what's in Linux 2.4: add AFMT_{QUERY,IMA_ADPCM,
MPEG,AC3}.  This should probably be tested with older versions of OSS,
eg. with Linux 2.2 and 2.0.

Export all SNDCTL_* ioctl numbers (where "all" is the set found in
/usr/include/linux/soundcard.h on my Debian 3.0 system -- again
Linux 2.4).  Again needs to be tested with older OSS versions.
2002-11-30 23:05:26 +00:00
Greg Ward 131bce035a * Don't put the device in non-blocking mode at open() time; this makes
it impossible to access blocking mode!

* Rename write() to writeall(), and add a write() method that just
  does one write().

* Rearrange/simplify writeall(): in particular, don't supply a timeout
  to select().  Let it block forever if it has to.

* Add a bunch of simple ioctl() wrappers: nonblock(), setfmt(),
  getfmts(), channels(), speed(), sync(), reset(), post().  These
  wrap, respectively, SNDCTL_DSP_NONBLOCK, SNDCTL_DSP_SETFMT,
  SNDCTL_DSP_GETFMTS, etc.

* Reduce flush() (which was a wrapper for the SNDCTL_DSP_SYNC ioctl) to
  an alias for sync().

* Rearrange the lad_methods list to reflect the order in which the
  methods are defined, and add some grouping comments.
2002-11-30 22:56:44 +00:00
Greg Ward 04613a9308 ossaudiodev -- Python interface to the OSS (Open Sound System) API.
This module is a replacement for linuxaudiodev, which will eventually
be deprecated.

Initial revision is rev 2.20 of linuxaudiodev.c, with a rewritten
header comment.
2002-11-30 22:47:45 +00:00
Greg Ward a34b1a0749 Allow the device name to be passed to linuxaudiodev.open(), for
consistency with the built-in open() (and every other sane open()
function, for that matter).  The two valid ways to call this open() are
now open(mode) and open(device, mode).

For backwards compatibility, retain the old open(mode) calling syntax --
this makes the error message when you call open(device) a bit confusing,
but oh well.

This is the first half of SF patch #644977.
2002-11-27 22:19:15 +00:00
Martin v. Löwis 4ec2e7071e Avoid including tclInt.h. 2002-11-26 22:12:12 +00:00
Martin v. Löwis 8c8aa5d666 Rename want_objects to wantobjects throughout, for consistency. 2002-11-26 21:39:48 +00:00
Martin v. Löwis ffad633af9 Patch #518625: Return objects in Tkinter. 2002-11-26 09:28:05 +00:00
Martin v. Löwis 52ea7e9244 Patch #632973: Implement _getdefaultlocale for OS X. 2002-11-26 09:05:36 +00:00
Martin v. Löwis b5c980b802 Add unidata_version. Bump generator version number. 2002-11-25 09:13:37 +00:00
Martin v. Löwis d5169bad94 Regenerate from Unicode 3.2.0 to include all First/Last ranges. 2002-11-24 23:10:08 +00:00
Martin v. Löwis 8d93ca1383 Verify that the code in CJK UNIFIED IDEOGRAPH- actually denotes an ideograph. 2002-11-23 22:10:29 +00:00
Martin v. Löwis 677bde2dd1 Patch #626485: Support Unicode normalization. 2002-11-23 22:08:15 +00:00
Martin v. Löwis ef7fe2e813 Implement names for CJK unified ideographs. Add name to KeyError output.
Verify that the lookup for an existing name succeeds.
2002-11-23 18:01:32 +00:00
Martin v. Löwis 2f4be4e38a Fix off-by-one error. 2002-11-23 17:11:06 +00:00
Martin v. Löwis 7d41e29c58 Patch #626548: Support Hangul syllable names. 2002-11-23 12:22:32 +00:00
Martin v. Löwis b2c7affbaa Merge with bsddb3 2002.11.23.10.42.36 2002-11-23 11:26:07 +00:00
Martin v. Löwis e17af7b3db Include Python.h first. 2002-11-23 09:16:19 +00:00
Neal Norwitz 8d4c9817a2 Fix SF # 640557, '64-bit' systems and the dbm module
datum.dsize can apparently be long on some systems.
Ensure we pass an int* to PyArg_Parse("s#"), not &datum.dsize

Will backport.
2002-11-22 23:29:31 +00:00
Fredrik Lundh 09705f0b89 fix for SF #635398 (don't "downcast" return strings from unicode to ascii) 2002-11-22 12:46:35 +00:00
Martin v. Löwis 0073f2e428 Fix --disable-unicode compilation problems. 2002-11-21 23:52:35 +00:00
Walter Dörwald 3b918c3787 Comment out the getcwdu implementation for --disable-unicode builds 2002-11-21 20:18:46 +00:00
Michael W. Hudson 2100798b8c Always call tparm with 10 arguments. It seems it's not varargs i
more often than it is.  In response to bug:

[ 641808 ] Portability of Modules/_cursesmodule.c

submitted by Nick Mclaren.
2002-11-21 14:17:51 +00:00
Martin v. Löwis 21645fc073 Don't try to use unsupported DB versions. 2002-11-19 08:30:08 +00:00
Martin v. Löwis 6aa4a1f29c Import PyBSDDB 3.4.0. Rename historical wrapper to bsddb185. 2002-11-19 08:09:52 +00:00
Neil Schemenauer 47ec6c0790 Don't use PyNumber_Float() since it's is nearly useless. Instead, rely on
PyFloat_AsDouble to generate a good error message.
2002-11-18 16:02:29 +00:00
Walter Dörwald 08c4cc4127 Use PyInt_AsLong instead of PyInt_AS_LONG after the call to
PyNumber_Int, because now PyNumber_Int might return a long,
and PyInt_AsLong can handle that, whereas PyInt_AS_LONG can't.

This closes SF bug #629989.
2002-11-12 11:42:20 +00:00
Neal Norwitz addfe0c09c Make private functions static so we don't pollute the namespace 2002-11-10 14:33:26 +00:00
Martin v. Löwis 774348c8d6 Fix typo. 2002-11-09 19:54:06 +00:00
Tim Peters 6ee6db81c2 bz2_compress/bz2_decompress: more casting away LONG_LONG for
_PyString_Resize calls.
2002-11-09 04:33:36 +00:00
Tim Peters 39185d622d BZ2Decomp_decompress(): Fixed more long vs LONG_LONG confusions. 2002-11-09 04:31:38 +00:00
Tim Peters 2858e5e84b BZ2Comp_flush(): Fixed more int vs LONG_LONG confusions. 2002-11-09 04:30:08 +00:00
Tim Peters f29f0c6a78 BZ2Comp_compress(): Explicitly cast the LONG_LONG size argument to
_PyString_Resize to int.
2002-11-09 04:28:17 +00:00
Tim Peters 07f075cebb BZ2Comp_compress(): changed decl of totalout to LONG_LONG, since it's
solely used to hold LONG_LONG values, and the compiler rightfully warns
about potential data loss otherwise.
2002-11-09 04:26:02 +00:00
Tim Peters a17c0c4509 Repaired signed-vs-unsigned mismatch. 2002-11-09 04:23:31 +00:00
Tim Peters e32280987c This couldn't compile on WIndows, due to hardcoded "long long". Repaired. 2002-11-09 04:21:44 +00:00
Gustavo Niemeyer 49ea7be7e9 * Modules/bz2module.c
(BZ2File_dealloc): Call Util_DropReadAhead().
  (*): Included aesthetic changes by Neal Norwitz.
2002-11-08 14:31:49 +00:00
Michael W. Hudson 019a78e76d Assorted patches from Armin Rigo:
[ 617309 ] getframe hook (Psyco #1)
[ 617311 ] Tiny profiling info (Psyco #2)
[ 617312 ] debugger-controlled jumps (Psyco #3)

These are forward ports from 2.2.2.
2002-11-08 12:53:11 +00:00
Thomas Heller 1f043e28f4 Enforce valid filemode. Fixes SF Bug #623464. 2002-11-07 16:00:59 +00:00
Gustavo Niemeyer c523b04b0f Fixed sre bug "[#581080] Provoking infinite scanner loops".
This bug happened because: 1) the scanner_search and scanner_match methods
were not checking the buffer limits before increasing the current pointer;
and 2) SRE_SEARCH was using "if (ptr == end)" as a loop break, instead of
"if (ptr >= end)".

* Modules/_sre.c
  (SRE_SEARCH): Check for "ptr >= end" to break loops, so that we don't
  hang forever if a pointer passing the buffer limit is used.
  (scanner_search,scanner_match): Don't increment the current pointer
  if we're going to pass the buffer limit.

* Misc/NEWS
  Mention the fix.
2002-11-07 03:28:56 +00:00
Andrew M. Kuchling 7e23f00948 [Patch #633635 from David M. Cooke]
Make keyname raise ValueError if passed -1, avoiding a segfault
   Make getkey() match the docs and raise an exception in nodelay mode
   The return type of getch() is int, not chtype
2002-11-06 14:15:36 +00:00
Gustavo Niemeyer 4e7be06a65 Fixed bug #470582, using a modified version of patch #527371,
from Greg Chapman.

* Modules/_sre.c
  (lastmark_restore): New function, implementing algorithm to restore
  a state to a given lastmark. In addition to the similar algorithm used
  in a few places of SRE_MATCH, restore lastindex when restoring lastmark.
  (SRE_MATCH): Replace lastmark inline restoring by lastmark_restore(),
  function. Also include it where missing. In SRE_OP_MARK, set lastindex
  only if i > lastmark.

* Lib/test/re_tests.py
* Lib/test/test_sre.py
  Included regression tests for the fixed bugs.

* Misc/NEWS
  Mention fixes.
2002-11-06 14:06:53 +00:00
Gustavo Niemeyer 7d7930bb3f * bzmodule.c
More fixes of XDECREF'd values not initialized.
2002-11-05 18:41:53 +00:00
Neal Norwitz 18142c0ca7 Fix SF #633935, test_bz2 fails
Needed to init ret since it was Py_XDECREF()d on error.
All regressions pass in debug build for me.
2002-11-05 18:17:32 +00:00
Gustavo Niemeyer f8ca8364c9 Patch implementing bz2 module.
* setup.py
  (PyBuildExt.detect_modules): Included bz2 module detection.

* Modules/bz2module.c
* Lib/test/test_bz2.py
* Doc/lib/libbz2.tex
  Included files implementing, testing, and documenting bz2 module.

* Doc/Makefile.deps
* Doc/lib/lib.tex
  Include references to libbz2.tex.

* Misc/NEWS
  (Library): Mention distutils' c++ linkage patch, and new bz2 module.
2002-11-05 16:50:05 +00:00
Neal Norwitz 662390681e SF #633013, Fix NIS causing interpreter core dump
Prevent the lengths passed to PyString_FromStringAndSize()
from being negative in some cases.
2002-11-04 23:21:09 +00:00
Neal Norwitz 39d22e5693 Use O_NONBLOCK rather than O_NDELAY, so we get POSIX non-blocking I/O.
On HPUX, Solaris, Tru64 (Dec UNIX), and IRIX (I think),
O_NONBLOCK is the POSIX version of non-blocking I/O
which is what we want.

On Linux and FreeBSD (at least), O_NONBLOCK and O_NDELAY are the same.
So this change should have no negative effect on those platforms.

Tested on Linux, Solaris, HPUX.

Thanks to Anders Qvist for diagnosing this problem.
2002-11-02 19:55:21 +00:00
Neal Norwitz 94a83fdc15 Fix SF #632624, test_resource failure on alpha/64bit
Return PyLongs instead ot PyInts.
On alphas, 9223372036854775807 became -1.
2002-11-02 17:46:24 +00:00
Martin v. Löwis d631ebe20b Remove extra argument in mknod. Fixes #632628. 2002-11-02 17:42:33 +00:00
Walter Dörwald 0ae2981dec Add docstrings to register, lookup, register_error
and lookup_error. This closes SF patch #630622.
2002-10-31 13:36:29 +00:00
Andrew M. Kuchling 3adefccdcb Use personal e-mail address 2002-10-30 21:08:34 +00:00
Martin v. Löwis 566f6afe9a Patch #512981: Update readline input stream on sys.stdin/out change. 2002-10-26 14:39:10 +00:00
Martin v. Löwis c9d07dfc87 Remove duplicate definitions of _XOPEN_SOURCE_EXTENDED. 2002-10-26 13:36:13 +00:00
Martin v. Löwis 9def6a3a77 Update to Unicode 3.2 database. 2002-10-18 16:11:54 +00:00
Fred Drake 5134a54df9 Fix minor whitespace nit, for consistency with Python's C style rules. 2002-10-17 20:37:50 +00:00
Martin v. Löwis 60a5d72908 Patch #623780: Replace obsolete struct macros. 2002-10-16 20:28:25 +00:00
Martin v. Löwis f607bdaa77 Add PyStructSequence_UnnamedField. Add stat_float_times.
Use integers in stat tuple, optionally floats in named fields.
2002-10-16 18:27:39 +00:00
Guido van Rossum 1e700d24e9 posix_execve(): add missing argument for "et" format in PyArg_Parse()
call.  This caused mysterious crashes (hard to debug because it was
happening in a child process).
2002-10-16 16:52:11 +00:00
Neal Norwitz c18b308229 Fix a few docstrings, remove extra commas 2002-10-11 22:19:42 +00:00
Neal Norwitz 98a355d0b3 SF #621948, update docstring for md5 by David M. Cooke. Will backport. 2002-10-11 21:53:01 +00:00
Martin v. Löwis dbe3f76270 Patch #569139: Implementation of major, minor and makedev. 2002-10-10 14:27:30 +00:00
Guido van Rossum 60c8a3aba8 GNU readline() mistakenly sets the LC_CTYPE locale.
This is evil.  Only the user or the app's main() should do this!
We must save and restore the locale around the rl_initialize() call.
2002-10-09 21:27:33 +00:00
Martin v. Löwis 114619e1ed Apply file system default encoding to exec and spawn path and arguments. 2002-10-07 06:44:21 +00:00
Tim Peters 92e4dd8657 s/_alloca/alloca/g; Windows doesn't need the former, at least not unless
__STDC__ is defined (or something like that ...).
2002-10-05 01:47:34 +00:00
Mark Hammond d389036069 Trivial fix to the pep277 checkin: ensure that exceptions always have a filename attribute (previously did only when string filenames were passed, but not when unicode) 2002-10-03 07:24:48 +00:00
Mark Hammond c2e85bd4e2 Patch 594001: PEP 277 - Unicode file name support for Windows NT. 2002-10-03 05:10:39 +00:00
Martin v. Löwis 3c6d6f2ff7 Support UCS-4 builds. 2002-10-01 18:50:56 +00:00
Martin v. Löwis 71e25a0e06 Eliminate constness warnings with Tcl 8.4. 2002-10-01 18:08:06 +00:00
Martin v. Löwis 6bfa2e6892 Drop support for Tk 8.0 and 8.1. 2002-10-01 17:48:31 +00:00
Martin v. Löwis 21ee4091e1 Patch #615069: Fix build problems on SCO Open Server 5. Backported to 2.2. 2002-09-30 16:19:48 +00:00
Guido van Rossum 9b1a80baf4 Patch for the DEC Alpha under Linux, by Lee Busby. 2002-09-26 16:52:02 +00:00
Thomas Heller 7bdabe67a3 I did fix too much - including winsock.h is sufficient. 2002-09-24 17:03:26 +00:00
Thomas Heller 106f4c7ba7 On Windows, call WSAGetLastError() to retrieve the error number.
Bugfix candidate, will backport to release22-maint myself.
2002-09-24 16:51:00 +00:00
Fred Drake 117ac85c4e Be more careful with the type of the xmlhandlersetter; it takes an
XML_Parser, which happens to be a pointer type, not an XML_Parser*.
This generated warnings when compiled with Expat 1.95.5, which no
longer defines XML_Parser to be void*.
2002-09-24 16:24:54 +00:00
Martin v. Löwis 8eb92a014b Patch #608999: Fix portability problems with MIPSPro 7.x 2002-09-19 08:03:21 +00:00
Martin v. Löwis 29275c9331 Deal with NULL fields in mkpwent. 2002-09-17 09:34:06 +00:00
Martin v. Löwis ceb7c18c10 Deal with a NULL gr_passwd. Reported by Anders Qvist. 2002-09-17 07:05:25 +00:00
Martin v. Löwis 658009afdb Make BadPickleGet a class. Fixes #609164. 2002-09-16 17:26:24 +00:00
Guido van Rossum bd6be7aba5 I think it makes more sense that the pseudo filename used by fdopen()
be "<fdopen>" rather than "(fdopen)".
2002-09-15 18:45:46 +00:00
Neal Norwitz bcf9f9eb3b SF # 602108 ensure string is null terminated after strncpy 2002-09-13 14:35:56 +00:00
Michael W. Hudson 806d1c817a Fix *really* embarrassing typo reported by Raymond Hettinger. 2002-09-11 17:09:45 +00:00
Michael W. Hudson 02ff6a9952 A slight change to SET_LINENO-less tracing.
This makes things a touch more like 2.2.  Read the comments in
Python/ceval.c for more details.
2002-09-11 15:36:32 +00:00
Tim Peters 96940cf30d extract_time(): Squash compiler warning about possibly information-
losing implicit double->long cast.
2002-09-10 15:37:28 +00:00
Martin v. Löwis 076b209ca4 Add missing return statement. 2002-09-10 15:04:41 +00:00
Martin v. Löwis 6aa9fdb86a Use utimes(2) where available to support microsecond timestamps. 2002-09-10 09:16:13 +00:00
Martin v. Löwis a32c994129 Always generate floats for stat_result; fix configure test. 2002-09-09 16:17:47 +00:00
Martin v. Löwis 94717ed1d4 Patch #606592: Subsecond timestamps in stat_result. 2002-09-09 14:24:16 +00:00
Neal Norwitz b567392bbf SF bug # 585792, Invalid mmap crashes Python interpreter
Raise ValueError if user passes a size to mmap which is larger
than the file.
2002-09-05 21:48:07 +00:00
Neal Norwitz 884baa1e6b --with(out)-thread is deprecated according to configure --help 2002-09-05 21:31:04 +00:00
Guido van Rossum 83a072d953 Update the module doc comment. 2002-09-03 19:10:18 +00:00
Guido van Rossum 960bc5490b (Most of) SF patch 601369 (Christos Georgiou): obmalloc,structmodule:
64bit, big endian (issue 2 only).

This adds a bunch of memcpy calls via a temporary variable to avoid
alignment errors.  That's needed for some platforms.
2002-09-03 18:42:21 +00:00
Fred Drake f57b22a716 Minor change for symmetry with PyXML: PyDoc_STR should not include
the "safety" parentheses since some older compilers refuse to compile
the module then, claiming that static initializers are non-constant.

This doesn't actually make any difference for Python, since these
definitions are not used when compiling with a version of Python that
already defines the PyDoc_* macros.
2002-09-02 15:54:06 +00:00
Walter Dörwald 3aeb632c31 PEP 293 implemention (from SF patch http://www.python.org/sf/432401) 2002-09-02 13:14:32 +00:00
Guido van Rossum 674deb2eea SF bug 601775 - some int results that should be bool. 2002-09-01 15:06:28 +00:00
Raymond Hettinger 5959c559df Added __pow__(a,b) to the operator module. Completes the pattern of
all operators having a counterpart in the operator module.

Closes SF bug #577513.
2002-08-19 03:19:09 +00:00
Tim Peters 7dca21e59f SF bug 595919: popenN return only text mode pipes
popen2() and popen3() created text-mode pipes even when binary mode
was asked for.  This was specific to Windows.
2002-08-19 00:42:29 +00:00
Guido van Rossum 84b2bed435 Squash a few calls to the hideously expensive PyObject_CallObject(o,a)
-- replace then with slightly faster PyObject_Call(o,a,NULL).  (The
difference is that the latter requires a to be a tuple; the former
allows other values and wraps them in a tuple if necessary; it
involves two more levels of C function calls to accomplish all that.)
2002-08-16 17:01:09 +00:00
Barry Warsaw 0a51b58e6b base64.decodestring('') should return '' instead of raising an
exception.  The bug fix for SF #430849 wasn't quite right.  This
closes SF bug #595671.  I'll backport this to Python 2.2.
2002-08-15 22:14:24 +00:00
Michael W. Hudson dd32a91cc0 This is my patch
[ 587993 ] SET_LINENO killer

Remove SET_LINENO.  Tracing is now supported by inspecting co_lnotab.

Many sundry changes to document and adapt to this change.
2002-08-15 14:59:02 +00:00
Martin v. Löwis 8a8da798a5 Patch #505705: Remove eval in pickle and cPickle. 2002-08-14 07:46:28 +00:00
Neal Norwitz 72cf6a8c07 Fix memory leaks reported by valgrind 2002-08-14 02:03:50 +00:00
Skip Montanaro 23b5918f68 add some example docstrings using PyDoc_STR 2002-08-14 01:45:37 +00:00
Skip Montanaro d9e7d24557 add PyDoc_STR and PyDoc_STRVAR calls as examples for module authors 2002-08-14 01:44:33 +00:00
Neal Norwitz 200788ce45 Allow more docstrings to be removed during compilation in some modules 2002-08-13 22:20:41 +00:00
Guido van Rossum 4030714a93 For new-style classes, we can now test for tp_del instead of asking
for a __del__ attribute, to see if there's a finalizer.
2002-08-09 17:39:14 +00:00
Sjoerd Mullender 9cf424b04b On Cygwin, put stdin, stderr, and stdout in binary mode when the -u
flag is given (to mimic native Windows).
2002-08-09 13:35:18 +00:00
Neal Norwitz 90128ba22c SF bug #592645 fix memory leak in socket.getaddrinfo 2002-08-09 03:37:42 +00:00
Fred Drake 9d416a7c10 Update the text on the Expat module and library. 2002-08-09 02:39:13 +00:00
Guido van Rossum 12e3c710db The other half of the patches added to SF patch 555085 by A I
MacIntyre.  At least on OS/2, a subsequent connect() on a nonblocking
socket returns errno==EISCONN to indicate success.  This seems
harmless on Unix.
2002-08-08 20:39:30 +00:00
Guido van Rossum 22a97159cd Clean up some docstrings. Some docstrings didn't show their return
value; others were inconsistent in what to name the argument or return
value; a few module-global functions had "socket." in front of their
name, against convention.
2002-08-08 20:37:08 +00:00
Jason Tishler 4df78cddaa Patch #588561: Cygwin _hotshot patch
YA Cygwin module patch very similar to other patches
that I have submitted.  I tested under Cygwin and Red
Hat Linux 7.1.
2002-08-08 19:46:15 +00:00
Martin v. Löwis 3f19b10ca5 Replace abort with Py_FatalError. 2002-08-07 16:21:51 +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
Guido van Rossum 8ee5243434 Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py. 2002-08-06 17:14:04 +00:00
Fred Drake 5f8a23f32f Since the errno module is needed by os._execvpe(), and that is used by the
setup.py (indirectly) script to build the standard dynamically loaded
modules, the errno module is being made static so it will always be
available.
Closes SF bug #591205 (needed on trunk only).
2002-08-05 18:06:17 +00:00
Martin v. Löwis 7d6e19d70c Add trace_frame. Fixes #534864. Backported to 2.2. 2002-08-04 08:24:49 +00:00
Martin v. Löwis 5a39530274 Add recursion counter for pickling. Fixes #576084.
2.2 bugfix candidate (may cause RuntimeError for applications that
currently work fine).
2002-08-04 08:20:23 +00:00
Fred Drake 610291cf5a Fix ref(), proxy() docstrings, based on comments from David Abrahams. 2002-08-02 20:23:40 +00:00
Skip Montanaro 71ffc5cc4b add #include branch for compilation with Berkeley DB 2002-08-02 17:13:01 +00:00
Jack Jansen 21ed16acbe Added one call to Py_Main(), for OSX framework builds only, that will get the
actual script to run in case we are running from an applet. If we are indeed
running an applet we skip the normal option processing leaving it all to the
applet code.

This allows us to get use the normal python binary in the Python.app bundle,
giving us all the normal command line options through PythonLauncher while
still allowing Python.app to be used as the template for building applets.

Consequently, pythonforbundle is gone, and Mac/Python/macmain.c isn't used
on OSX anymore.
2002-08-02 14:11:24 +00:00
Mark Hammond fe51c6d66e Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
for Py_Main().

Thanks to Kalle Svensson and Skip Montanaro for the patches.
2002-08-02 02:27:13 +00:00
Jack Jansen ea0c3828c0 - Get _environ through the NSEnviron call in a MacOSX framework. This allows
us to completely decouple the framework from the executable, so we
  can use a two-level namespace.
- Do framework builds with a twolevel namespace.
- Reorganized the code that creates the minimal framework in the build
  directory, to make it more robust against incomplete frameworks (from
  earlier aborted builds, or builds of previous Python versions).
2002-08-01 21:57:49 +00:00
Michael W. Hudson b6a4505123 Cray fixup as seen in bug #558153. 2002-07-31 09:54:24 +00:00
Neal Norwitz cfa1f52941 Revert changes to use PyArg_Parse(), so any sequence will continue to work -- Spotted by Just van Rossum 2002-07-30 12:27:43 +00:00
Neal Norwitz 50584b4c78 Use PyArg_ParseTuple() instead of PyArg_Parse() which is deprecated 2002-07-30 01:23:07 +00:00
Neal Norwitz 50d5d4fe31 Fix docstring to be consistent with parameter name (prefix) 2002-07-30 01:17:43 +00:00
Neal Norwitz 1169011f6f SF patch #584245, get python to link on OSF1 (Dec Unix) 2002-07-30 01:08:28 +00:00
Michael W. Hudson 56796f672f Fix for
[ 587875 ] crash on deleting extended slice

The array code got simpler, always a good thing!
2002-07-29 14:35:04 +00:00
Martin v. Löwis 0cec0ffc78 Patch #573770: Implement lchown. 2002-07-28 16:33:45 +00:00
Martin v. Löwis ddc6f4748e Pass length of result structure into setipaddr. Fixes bug #565747.
Committed to 2.2 branch.
2002-07-28 16:10:31 +00:00
Neal Norwitz 2026584016 SF patch #577031, remove PyArg_NoArgs() since it's deprecated
Explicitly use METH_OLDARGS
2002-07-28 15:23:23 +00:00
Neal Norwitz 77c72bb323 SF patch #577031, remove PyArg_Parse() since it's deprecated 2002-07-28 15:12:10 +00:00
Neal Norwitz ce233b462d Fix last checkin, can't use " inside a string 2002-07-28 13:53:05 +00:00
Martin v. Löwis 611a7101ca Patch #552812: Better description in "python -h" for -u. 2002-07-28 10:34:08 +00:00
Martin v. Löwis 09c35f78fe Patch #575827: allow threads inside SSL creation. 2002-07-28 09:57:45 +00:00
Jeremy Hylton 825e47b655 Put checks for error returns in the right place. 2002-07-25 16:37:51 +00:00
Jeremy Hylton c075e197d6 Extended socket.htonl and ntohl to accept longs.
Fixes SF bug #568322.

The code should raise an OverflowError if the long is > 32 bits, even
on platforms where sizeof(long) > 4.
2002-07-25 16:01:12 +00:00
Mark Hammond 62b1ab1b31 Replace DL_IMPORT with PyMODINIT_FUNC and remove "/export:init..." link
command line for Windows builds.  This should allow MSVC to import and
build the Python MSVC6 project files without error.
2002-07-23 06:31:15 +00:00
Guido van Rossum 0b624f69b5 unpack_string(): avoid a compiler warning (about a real bug!) by
copying the result of fgetc() into an int variable before testing it
for EOF.
2002-07-20 00:38:01 +00:00
Fred Drake 814f9fe806 Return NULL instead of 0 from function with a pointer return value. 2002-07-19 22:03:03 +00:00
Guido van Rossum d3c46d5463 Patch to call the Pure python strptime implementation if there's no
C implementation.  See SF patch 474274, by Brett Cannon.

(As an experiment, I'm adding a line that #undefs HAVE_STRPTIME,
so that you'll always get the Python version.  This is so that it
gets some good exercise.  We should eventually delete that line.)
2002-07-19 17:06:47 +00:00
Guido van Rossum ad65490628 Bail out early from internal_select() when socket file descriptor
closed.  Prevents core dump.
2002-07-19 12:44:59 +00:00
Mark Hammond 8235ea1c3a Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT. 2002-07-19 06:55:41 +00:00
Tim Peters a12b4cfaa5 A Python float is a C double; redeclare defaulttimeout as such; stops
compiler wngs on Windows.
2002-07-18 22:38:44 +00:00
Guido van Rossum 1693ba8bf8 Silence warning about getdefaulttimeout in PyMethodDef. 2002-07-18 21:11:26 +00:00
Jeremy Hylton 7fa4bfa173 Fix indentation. 2002-07-18 20:58:57 +00:00
Fred Drake 666bf52a16 - When the log reader detects end-of-file, close the file.
- The log reader now provides a "closed" attribute similar to the
  profiler.
- Both the profiler and log reader now provide a fileno() method.
- Use METH_NOARGS where possible, allowing simpler code in the method
  implementations.
2002-07-18 19:11:44 +00:00
Guido van Rossum 9d0c8cee66 Add default timeout functionality. This adds setdefaulttimeout() and
getdefaulttimeout() functions to the socket and _socket modules, and
appropriate tests.
2002-07-18 17:08:35 +00:00
Fred Drake 5c3ed3db9a Mark the closed attribute of the profiler with PyDoc_STR(), and added
a docstring for the info attribute of the logreader object.
2002-07-17 19:38:05 +00:00
Fred Drake d1eb8b61d0 Added a docstring for the closed attribute.
write_header():  When we encounter a non-string object in sys.path, record
    a fairly mindless placeholder rather than dying.  Possibly could record
    the repr of the object found, but not clear whether that matters.
2002-07-17 18:54:20 +00:00
Tim Peters 0c32279626 Removed more stray instances of statichere, but left _sre.c alone. 2002-07-17 16:49:03 +00:00
Jeremy Hylton 938ace69a0 staticforward bites the dust.
The staticforward define was needed to support certain broken C
compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the
static keyword when it was used with a forward declaration of a static
initialized structure.  Standard C allows the forward declaration with
static, and we've decided to stop catering to broken C compilers.  (In
fact, we expect that the compilers are all fixed eight years later.)

I'm leaving staticforward and statichere defined in object.h as
static.  This is only for backwards compatibility with C extensions
that might still use it.

XXX I haven't updated the documentation.
2002-07-17 16:30:39 +00:00
Guido van Rossum 9cb64b954a Some modernization. Get rid of the redundant next() method. Always
assume tp_iter and later fields exist.  Use PyObject_GenericGetAttr
instead of providing our own tp_getattr hook.
2002-07-17 16:15:35 +00:00
Fred Drake f042db6a94 Remove RCSId; this produces annoying warnings.
This is already removed from Expat 1.95.4, so the problem will not
recur when we update.
2002-07-17 14:45:33 +00:00
Guido van Rossum 2335100b6a Wipe out some warnings about non-ANSI code and an unsafe arg to
isdigit().
2002-07-17 14:33:34 +00:00
Jeremy Hylton 39c6116483 Given the persistent id code a shot at a class before calling save_global().
Some persistent picklers (well, probably, the *only* persistent
pickler) would like to pickle some classes in a special way.
2002-07-16 19:47:43 +00:00
Mark Hammond 975e3921ae Fix bug 581232 - [Windows] Can not interrupt time.sleep()
time.sleep() will now be interrupted on the main thread when Ctrl+C is pressed.  Other threads are never interrupted.
2002-07-16 01:29:19 +00:00
Tim Peters ee66d0c3d5 /F revealed that ShellExecute() only requires shellapi.h, not the
full-blown windows.h, so changed accordingly.
2002-07-15 16:10:55 +00:00
Mark Hammond 155adbdcbb Fix bug 231273 - [windows] os.popen doens't kill subprocess when interrupted
Don't pass CREATE_NEW_CONSOLE to CreateProcess(), meaning our child process is in the same "console group" and therefore interrupted by the same Ctrl+C that interrupts the parent.
2002-07-14 23:28:16 +00:00
Tim Peters 7a1f91709b WINDOWS_LEAN_AND_MEAN: There is no such symbol, although a very few
MSDN sample programs use it, apparently in error.  The correct name
is WIN32_LEAN_AND_MEAN.  After switching to the correct name, in two
cases more was needed because the code actually relied on things that
disappear when WIN32_LEAN_AND_MEAN is defined.
2002-07-14 22:14:19 +00:00
Jeremy Hylton 9ee91f11b3 remove decl of unused variable 2002-07-11 22:02:33 +00:00
Jeremy Hylton 0e1f7a82e9 Do more robust test of whether global objects are accessible.
PyImport_ImportModule() is not guaranteed to return a module object.
When another type of object was returned, the PyModule_GetDict() call
return NULL and the subsequent GetItem() seg faulted.

Bug fix candidate.
2002-07-11 22:01:40 +00:00
Tim Peters 803526b9e2 Trashcan cleanup: Now that cyclic gc is always there, the trashcan
mechanism is no longer evil:  it no longer plays dangerous games with
the type pointer or refcounts, and objects in extension modules can play
along too without needing to edit the core first.

Rewrote all the comments to explain this, and (I hope) give clear
guidance to extension authors who do want to play along.  Documented
all the functions.  Added more asserts (it may no longer be evil, but
it's still dangerous <0.9 wink>).  Rearranged the generated code to
make it clearer, and to tolerate either the presence or absence of a
semicolon after the macros.  Rewrote _PyTrash_destroy_chain() to call
tp_dealloc directly; it was doing a Py_DECREF again, and that has all
sorts of obscure distorting effects in non-release builds (Py_DECREF
was already called on the object!).  Removed Christian's little "embedded
change log" comments -- that's what checkin messages are for, and since
it was impossible to correlate the comments with the code that changed,
I found them merely distracting.
2002-07-07 05:13:56 +00:00
Tim Peters 943382c8e5 Removed WITH_CYCLE_GC #ifdef-ery. Holes:
+ I'm not sure what to do about configure.in.  Left it alone.

+ Ditto pyexpat.c.  Fred or Martin will know what to do.
2002-07-07 03:59:34 +00:00
Michael W. Hudson 8b7f131f8b gc_list_move defined but not used. 2002-07-04 17:11:36 +00:00
Tim Peters 934c1a1c6b Another stab at SF 576327: zipfile when sizeof(long) == 8
binascii_crc32():  The previous patch forced this to return the same
result across platforms.  This patch deals with that, on a 64-bit box,
the *entry* value may have "unexpected" bits in the high four bytes.

Bugfix candidate.
2002-07-02 22:24:50 +00:00
Tim Peters aab713bdf7 visit_decref(): Added another assert. 2002-07-02 22:15:28 +00:00
Tim Peters a98011c388 Fix for SF bug #576327: zipfile when sizeof(long) == 8
binascii_crc32():  Make this return a signed 4-byte result across
platforms.  The other way to make this platform-independent would be to
make it return an unsigned unbounded int, but the evidence suggests
other code out there treats it like a signed 4-byte int (e.g., existing
code writing the result with struct.pack "l" format).

Bugfix candidate.
2002-07-02 20:20:08 +00:00
Jeremy Hylton 4e54730ed5 Repair badly formatted code. 2002-07-02 18:25:00 +00:00
Tim Peters 6fc13d9595 Finished transitioning to using gc_refs to track gc objects' states.
This was mostly a matter of adding comments and light code rearrangement.
Upon untracking, gc_next is still set to NULL.  It's a cheap way to
provoke memory faults if calling code is insane.  It's also used in some
way by the trashcan mechanism.
2002-07-02 18:12:35 +00:00
Fred Drake b28467b713 Do not depend on pymemcompat.h (was only used for PyXML); Martin likes
it all inline.
2002-07-02 15:44:36 +00:00
Jack Jansen 84262fb1f3 Mac OS X Jaguar (developer preview) seems to have a working getaddrinfo(). 2002-07-02 14:40:42 +00:00
Tim Peters ea405639bf Reserved another gc_refs value for untracked objects. Every live gc
object should now have a well-defined gc_refs value, with clear transitions
among gc_refs states.  As a result, none of the visit_XYZ traversal
callbacks need to check IS_TRACKED() anymore, and those tests were removed.
(They were already looking for objects with specific gc_refs states, and
the gc_refs state of an untracked object can no longer match any other
gc_refs state by accident.)
Added more asserts.
I expect that the gc_next == NULL indicator for an untracked object is
now redundant and can also be removed, but I ran out of time for this.
2002-07-02 00:52:30 +00:00
Fred Drake 7c75bf2090 Bring this back into sync with PyXML revision 1.58. 2002-07-01 14:02:31 +00:00
Tim Peters 19b74c7868 OK, I couldn't stand it <0.5 wink>: removed all uncertainty about what's
in gc_refs, even at the cost of putting back a test+branch in
visit_decref.

The good news:  since gc_refs became utterly tame then, it became
clear that another special value could be useful.  The move_roots() and
move_root_reachable() passes have now been replaced by a single
move_unreachable() pass.  Besides saving a pass over the generation, this
has a better effect:  most of the time everything turns out to be
reachable, so we were breaking the generation list apart and moving it
into into the reachable list, one element at a time.  Now the reachable
stuff stays in the generation list, and the unreachable stuff is moved
instead.  This isn't quite as good as it sounds, since sometimes we
guess wrongly that a thing is unreachable, and have to move it back again.

Still, overall, it yields a significant (but not dramatic) boost in
collection speed.
2002-07-01 03:52:19 +00:00
Tim Peters 93cd83e4ae visit_decref(): Two optimizations.
1. You're not supposed to call this with a NULL argument, although the
   docs could be clearer about that.  The other visit_XYZ() functions
   don't bother to check.  This doesn't either now, although it does
   assert non-NULL-ness now.

2. It doesn't matter whether the object is currently tracked, so don't
   bother checking that either (if it isn't currently tracked, it may
   have some nonsense value in gc_refs, but it doesn't hurt to
   decrement gibberish, and it's cheaper to do so than to make everyone
   test for trackedness).

It would be nice to get rid of the other tests on IS_TRACKED.  Perhaps
trackedness should not be a matter of not being in any gc list, but
should be a matter of being in a new "untracked" gc list.  This list
simply wouldn't be involved in the collection mechanism.  A newly
created object would be put in the untracked list.  Tracking would
simply unlink it and move it into the gen0 list.  Untracking would do
the reverse.  No test+branch needed then.  visit_move() may be vulnerable
then, though, and I don't know how this would work with the trashcan.
2002-06-30 21:31:03 +00:00
Tim Peters 8839617cc9 SF bug #574132: Major GC related performance regression
"The regression" is actually due to that 2.2.1 had a bug that prevented
the regression (which isn't a regression at all) from showing up.  "The
regression" is actually a glitch in cyclic gc that's been there forever.

As the generation being collected is analyzed, objects that can't be
collected (because, e.g., we find they're externally referenced, or
are in an unreachable cycle but have a __del__ method) are moved out
of the list of candidates.  A tricksy scheme uses negative values of
gc_refs to mark such objects as being moved.  However, the exact
negative value set at the start may become "more negative" over time
for objects not in the generation being collected, and the scheme was
checking for an exact match on the negative value originally assigned.
As a result, objects in generations older than the one being collected
could get scanned too, and yanked back into a younger generation.  Doing
so doesn't lead to an error, but doesn't do any good, and can burn an
unbounded amount of time doing useless work.

A test case is simple (thanks to Kevin Jacobs for finding it!):

x = []
for i in xrange(200000):
    x.append((1,))

Without the patch, this ends up scanning all of x on every gen0 collection,
scans all of x twice on every gen1 collection, and x gets yanked back into
gen1 on every gen0 collection.  With the patch, once x gets to gen2, it's
never scanned again until another gen2 collection, and stays in gen2.

Bugfix candidate, although the code has changed enough that I think I'll
need to port it by hand.  2.2.1 also has a different bug that causes
bound method objects not to get tracked at all (so the test case doesn't
burn absurd amounts of time in 2.2.1, but *should* <wink>).
2002-06-30 17:56:40 +00:00
Martin v. Löwis 6238d2b024 Patch #569753: Remove support for WIN16.
Rename all occurrences of MS_WIN32 to MS_WINDOWS.
2002-06-30 15:26:10 +00:00
Martin v. Löwis b4fcf4d102 Define PyDoc_STRVAR if it is not available (PyXML 1.54).
Remove support for Python 1.5 (PyXML 1.55).
2002-06-30 06:40:55 +00:00
Martin v. Löwis 6b2cf0e5ea Undo usage of PyOS_snprintf (rev. 1.51 of PyXML). 2002-06-30 06:03:35 +00:00
Fred Drake 2a3d7db93e Added character data buffering to pyexpat parser objects.
Setting the buffer_text attribute to true causes the parser to collect
character data, waiting as long as possible to report it to the Python
callback.  This can save an enormous number of callbacks from C to
Python, which can be a substantial performance improvement.

buffer_text defaults to false.
2002-06-28 22:56:48 +00:00
Fred Drake 71b63ff342 pyexpat code cleanup and minor refactorings:
The handlers array on each parser now has the invariant that None will
never be set as a handler; it will always be NULL or a Python-level
value passed in for the specific handler.

have_handler():  Return true if there is a Python handler for a
    particular event.

get_handler_name():  Return a string object giving the name of a
    particular handler.  This caches the string object so it doesn't
    need to be created more than once.

get_parse_result():  Helper to allow the Parse() and ParseFile()
    methods to share the same logic for determining the return value
    or exception state.

PyUnknownEncodingHandler(), PyModule_AddIntConstant():
    Made these helpers static.  (The later is only defined for older
    versions of Python.)

pyxml_UpdatePairedHandlers(), pyxml_SetStartElementHandler(),
pyxml_SetEndElementHandler(), pyxml_SetStartNamespaceDeclHandler(),
pyxml_SetEndNamespaceDeclHandler(), pyxml_SetStartCdataSection(),
pyxml_SetEndCdataSection(), pyxml_SetStartDoctypeDeclHandler(),
pyxml_SetEndDoctypeDeclHandler():
    Removed.  These are no longer needed with Expat 1.95.x.

handler_info:
    Use the setter functions provided by Expat 1.95.x instead of the
    pyxml_Set*Handler() functions which have been removed.

Minor code formatting changes for consistency.
Trailing whitespace removed.
2002-06-28 22:29:01 +00:00
Neil Schemenauer c9051640f8 Fix small bug. The count of objects in all generations younger then the
collected one should be zeroed.
2002-06-28 19:16:04 +00:00
Fred Drake b91a36b230 Integrate the changes from PyXML's version of pyexpat.c revisions
1.47, 1.48, 1.49 (name interning support).
2002-06-27 19:40:48 +00:00
Jack Jansen c5601f4839 Undefine DPRINTF before defining it, there was a conflict with some other
definition.
2002-06-26 20:41:30 +00:00
Jack Jansen 3a96702b2b Undefine TRUE and FALSE before redefining them. 2002-06-26 20:40:42 +00:00
Fred Drake f7ce04dcb4 Clean up docstrings:
- Include a blank line between the signature line and the description
  (Guido sez).
- Don't include "-> None" for API functions that always return None
  because they don't have a meaningful return value.
2002-06-20 18:31:21 +00:00
Michael W. Hudson 9c14badc5f Fix the bug described in
http://mail.python.org/pipermail/python-dev/2002-June/025461.html

with test cases.

Also includes extended slice support for arrays, which I thought I'd
already checked in but obviously not.
2002-06-19 15:44:15 +00:00
Guido van Rossum a0b9075816 Corect speling and add \n\ to line ends in new docstring for access(). 2002-06-18 16:22:43 +00:00
Fred Drake 7f59124693 Clarified documentation for os.access().
Patch contributed by Sean Reifschneider.
Closes SF patch #570618.
2002-06-18 16:15:51 +00:00
Tim Peters 0add0e86c7 Removed newmodule.c from the project, and removed references to it from
the Windowish builds.
2002-06-16 01:34:49 +00:00
Guido van Rossum bea18ccde6 SF patch 568629 by Oren Tirosh: types made callable.
These built-in functions are replaced by their (now callable) type:

    slice()
    buffer()

and these types can also be called (but have no built-in named
function named after them)

    classobj (type name used to be "class")
    code
    function
    instance
    instancemethod (type name used to be "instance method")

The module "new" has been replaced with a small backward compatibility
placeholder in Python.

A large portion of the patch simply removes the new module from
various platform-specific build recipes.  The following binary Mac
project files still have references to it:

    Mac/Build/PythonCore.mcp
    Mac/Build/PythonStandSmall.mcp
    Mac/Build/PythonStandalone.mcp

[I've tweaked the code layout and the doc strings here and there, and
added a comment to types.py about StringTypes vs. basestring.  --Guido]
2002-06-14 20:41:17 +00:00
Skip Montanaro 57454e57f8 This introduces stricter library/header file checking for the Berkeley DB
library.  Since multiple versions can be installed simultaneously, it's
crucial that you only select libraries and header files which are compatible
with each other.  Version checking is done from highest version to lowest.
Building using version 1 of Berkeley DB is disabled by default because of
the hash file bugs people keep rediscovering.  It can be enabled by
uncommenting a few lines in setup.py.  Closes patch 553108.
2002-06-14 20:30:31 +00:00
Neal Norwitz 4178515035 SF # 533070 Silence AIX C Compiler Warnings
Warning caused by using &func.  & is not necessary.
2002-06-13 21:42:51 +00:00
Neal Norwitz 0c2c17c473 Use new PyDoc_STRVAR macro 2002-06-13 21:22:11 +00:00
Neal Norwitz 35fc7606f0 SF #561244 Micro optimizations
Convert loops to memset()s.
2002-06-13 21:11:11 +00:00
Martin v. Löwis 606edc1d97 Patch #568235: Add posix.setpgid. 2002-06-13 21:09:11 +00:00
Martin v. Löwis 14f8b4cfcb Patch #568124: Add doc string macros. 2002-06-13 20:33:02 +00:00
Guido van Rossum 7b8bac106a Fix non-blocking connect() for Windows. Refactored the code
that retries the connect() call in timeout mode so it can be shared
between connect() and connect_ex(), and needs only a single #ifdef.

The test for this was doing funky stuff I don't approve of,
so I removed it in favor of a simpler test.  This allowed me
to implement a simpler, "purer" form of the timeout retry code.
Hopefully that's enough (if you want to be fancy, use non-blocking
mode and decode the errors yourself, like before).
2002-06-13 16:07:04 +00:00
Guido van Rossum 11ba094957 Major overhaul of timeout sockets:
- setblocking(0) and settimeout(0) are now equivalent, and ditto for
  setblocking(1) and settimeout(None).

- Don't raise an exception from internal_select(); let the final call
  report the error (this means you will get an EAGAIN error instead of
  an ETIMEDOUT error -- I don't care).

- Move the select to inside the Py_{BEGIN,END}_ALLOW_THREADS brackets,
  so other theads can run (this was a bug in the original code).

- Redid the retry logic in connect() and connect_ex() to avoid masking
  errors.  This probably doesn't work for Windows yet; I'll fix that
  next.  It may also fail on other platforms, depending on what
  retrying a connect does; I need help with this.

- Get rid of the retry logic in accept().  I don't think it was needed
  at all.  But I may be wrong.
2002-06-13 15:07:44 +00:00
Andrew MacIntyre 74a3bec592 _Py prefix is verboten for static entry points 2002-06-13 11:55:14 +00:00
Andrew MacIntyre 7aec4a2e2c work around name clash with OS/2 TCPIP routine sock_init() 2002-06-13 11:53:52 +00:00
Skip Montanaro a039274ccc patch #562492 - prevent duplicate lines in history
also call using_history() to properly initialize history variables
2002-06-11 14:32:46 +00:00
Martin v. Löwis f90ae20354 Patch #488073: AtheOS port. 2002-06-11 06:22:31 +00:00
Guido van Rossum 804cdca7ea Don't accept null bytes in the key. 2002-06-10 19:46:18 +00:00
Guido van Rossum db9198a8b5 SF bug 563750 (Alex Martelli): posix_tmpfile():
The file returned by tmpfile() has mode w+b, so use that in the call
to PyFile_FromFile().

Bugfix candidate.
2002-06-10 19:23:22 +00:00
Guido van Rossum 1790e65d43 Move the conex_finally label up, so that the errno value is always
returned.
2002-06-07 19:55:29 +00:00
Guido van Rossum e8008f0013 I decided to change the interaction between setblocking() and
settimeout().   Already, settimeout() canceled non-blocking mode; now,
setblocking() also cancels the timeout.  This is easier to document.

(XXX should settimeout(0) be an alias for setblocking(0)?  They seem
to have roughly the same effect.  Also, I'm not sure that the code in
connect() and accept() is correct in all cases.  We'll sort this out
soon enough.)
2002-06-07 03:36:20 +00:00
Guido van Rossum c4fcfa3457 Major cleanup. Renamed static methods to avoid Py prefix. Other misc
cleanup as well, e.g. renamed NTinit to os_init.
2002-06-07 03:19:37 +00:00
Guido van Rossum be8db07ab5 Repair a comment. 2002-06-07 02:27:50 +00:00
Guido van Rossum 3eede5ad81 Whitespace normalization, folding long lines, uniform comment
delimiters.  Also repaired some docstrings and comments.
2002-06-07 02:08:35 +00:00
Guido van Rossum b9e916a0b5 Correct several blunders in the timeout code, mostly my own fault (for
not testing it -- apparently test_timeout.py doesn't test anything
useful):

In internal_select():

- The tv_usec part of the timeout for select() was calculated wrong.

- The first argument to select() was one too low.

- The sense of the direction argument to internal_select() was
  inverted.

In PySocketSock_settimeout():

- The calls to internal_setblocking() were swapped.

Also, repaired some comments and fixed the test for the return value
of internal_select() in sendall -- this was in the original patch.
2002-06-07 01:42:47 +00:00
Jeremy Hylton 8a13518d25 Remove casts to PyObject * when declaration is for PyObject * 2002-06-06 23:23:55 +00:00
Guido van Rossum 67f7a38849 SF patch 555085 (timeout socket implementation) by Michael Gilfix.
I've made considerable changes to Michael's code, specifically to use
the select() system call directly and to store the timeout as a C
double instead of a Python object; internally, -1.0 (or anything
negative) represents the None from the API.

I'm not 100% sure that all corner cases are covered correctly, so
please keep an eye on this.  Next I'm going to try it Windows before
Tim complains.

No way is this a bugfix candidate. :-)
2002-06-06 21:08:16 +00:00
Guido van Rossum c9a55776c8 The insint() function is not used. Nuke it. 2002-06-06 20:41:10 +00:00
Guido van Rossum e1c478ff8a The tp_new implementation should initialize the errorhandler field,
otherwise this code could segfault:

  from socket import socket
  s = socket.__new__(socket)
  s.recv(100)
2002-06-06 20:08:25 +00:00
Neal Norwitz b5b5a260ea Fix SF bug #557436, TclError is a str should be an Exception
Make Tkinter.TclError derive from Exception, it was a string.
2002-06-04 17:14:07 +00:00
Neal Norwitz 3e12905e03 Remove unused static function 2002-05-31 21:47:02 +00:00
Guido van Rossum 84271bb34f SF #558432: Prevent Annoying ' ' from readline (Holker Krekel).
readline in all python versions is configured
    to append a 'space' character for a successful
    completion. But for almost all python expressions
    'space' is not wanted (see coding conventions PEP 8).
    For example if you have a function 'longfunction'
    and you type 'longf<TAB>' you get 'longfunction '
    as a completion. note the unwanted space at the
    end.

    The patch fixes this behaviour by setting readline's
    append_character to '\0' which means don't append
    anything. This doesn't work with readline < 2.1
    (AFAIK nowadays readline2.2 is in good use).

    An alternative approach would be to make the
    append_character
    accessable from python so that modules like
    the rlcompleter.py can set it to '\0'.

[Ed.: I think expecting readline >= 2.2 is fine.  If a completer wants
another character they can append that to the keyword in the list.]
2002-05-30 15:41:56 +00:00
Neil Schemenauer 8b6b491ed7 The logreader object did not always refill the input buffer correctly
and got confused by certain log files.  Remove logreader_refill and the
associated logic and replace with fgetc.
2002-05-29 18:19:14 +00:00
Guido van Rossum e85ee8d815 Issue an explicit error when we can't find an appropriate type for
UINT4.
2002-05-29 14:00:22 +00:00
Michael W. Hudson 1e1542fcff This is patch
[ 558914 ] Build md5.c fails on Cray T3E

I've also deleted a comment that I didn't understand.  Feel free to
put it back if it makes/made sense to you.
2002-05-29 10:32:24 +00:00
Michael W. Hudson 34f20eac98 This is patch
[ 559250 ] more POSIX signal stuff

Adds support (and docs and tests and autoconfery) for posix signal
mask handling -- sigpending, sigprocmask and sigsuspend.
2002-05-27 15:08:24 +00:00
Guido van Rossum 2d3b986480 Disambiguate the grammar for backtick.
The old syntax suggested that a trailing comma was OK inside backticks,
but in fact (due to ideosyncrasies of pgen) it was not.  Fix the grammar
to avoid the ambiguity.  Fred: you may want to update the refman.
2002-05-24 15:47:06 +00:00
Tim Peters c9ca5c82f9 Whitespace normalization. 2002-05-23 15:49:38 +00:00
Neil Schemenauer a2b11ecb08 Add IS_TRACKED and IS_MOVED macros. This makes the logic a little more clear. 2002-05-21 15:53:24 +00:00
Michael W. Hudson 1755ad9b02 array_tounicode isn't defined in --disable-unicode builds...
I have a patch to make the test work too, but it's not pretty so
I'll submit it to sf.
2002-05-13 10:14:59 +00:00
Raymond Hettinger d6f2267a83 Added degrees() and radians() to mathmodule. Closes patch 552452 and
feature request 426539.
2002-05-13 03:56:10 +00:00
Martin v. Löwis 000e37c3c4 Patch #551011: Fix compilation problems with Cygwin. 2002-05-08 07:16:37 +00:00
Martin v. Löwis 2b41b0d6a7 Rename posix_WCONTINUED to posix_WIFCONTINUED, call WIFCONTINUED inside,
add it to the posix_methods.
2002-05-04 13:13:41 +00:00
Neil Schemenauer 2880ae53e6 Move all data for a single generation into a structure. The set of
generations is now an array.  This cleans up some code and makes it easy
to change the number of generations.  Also, implemented a
gc_list_is_empty() function.  This makes the logic a little clearer in
places.  The performance impact of these changes should be negligible.

One functional change is that allocation/collection counters are always
zeroed at the start of a collection.  This should fix SF bug #551915.
This change is too big for back-porting but the minimal patch on SF
looks good for a bugfix release.
2002-05-04 05:35:20 +00:00
Martin v. Löwis b9132a2a15 Indicate delayed initialization of slots. Suggested by tim.one. 2002-05-02 20:34:12 +00:00
Martin v. Löwis edbffc1725 Patch #551009: Initialize array type dynamically. 2002-05-02 20:09:59 +00:00
Martin v. Löwis c6a7d7ef49 Guard gettext and friends with HAVE_LIBINTL_H. Fixes #549907. 2002-05-02 12:16:29 +00:00
Fred Drake 0ebacc8b38 Pickler_clear_memo(): convert to METH_NOARGS. 2002-05-01 20:36:39 +00:00
Guido van Rossum a883a3d5fd See discussion at SF bug 547537.
Unicode objects are currently taken as binary data by the write()
method.  This is not what Unicode users expect, nor what the
StringIO.py code does.  Until somebody adds a way to specify binary or
text mode for cStringIO objects, change the format string to use "t#"
instead of "s#", so that it will request the "text buffer" version.
This will try the default encoding for Unicode objects.

This is *not* a 2.2 bugfix (since it *is* a semantic change).
2002-04-29 13:54:48 +00:00
Tim Peters fa8efab30f _PyObject_GC_New: Could call PyObject_INIT with a NULL 1st argument.
_PyObject_GC_NewVar:  Could call PyObject_INIT_VAR likewise.

Bugfix candidate.
2002-04-28 01:57:25 +00:00
Tim Peters 5de9842b34 Repair widespread misuse of _PyString_Resize. Since it's clear people
don't understand how this function works, also beefed up the docs.  The
most common usage error is of this form (often spread out across gotos):

	if (_PyString_Resize(&s, n) < 0) {
		Py_DECREF(s);
		s = NULL;
		goto outtahere;
	}

The error is that if _PyString_Resize runs out of memory, it automatically
decrefs the input string object s (which also deallocates it, since its
refcount must be 1 upon entry), and sets s to NULL.  So if the "if"
branch ever triggers, it's an error to call Py_DECREF(s):  s is already
NULL!  A correct way to write the above is the simpler (and intended)

	if (_PyString_Resize(&s, n) < 0)
		goto outtahere;

Bugfix candidate.
2002-04-27 18:44:32 +00:00
Jeremy Hylton d95efe4257 Check for overflow errors in setrlimit(),
and reflow a long line.
2002-04-23 20:15:04 +00:00
Fred Drake 106c1a0e7a WCOREDUMP(), WIFCONTINUED(), WCONTINUED, WUNTRACED: New.
isatty(), WIFEXITED(), WIFSIGNALED(), WIFSTOPPED(): Changed to return
    bools instead of ints.
2002-04-23 15:58:02 +00:00
Anthony Baxter 8388895fe4 SF patch [ 545523 ] patch for 514433 bsddb.dbopen (NULL)
closes SF #514433

can now pass 'None' as the filename for the bsddb.*open functions,
and you'll get an in-memory temporary store.

docs are ripped out of the bsddb dbopen man page. Fred may want to
clean them up.

Considering this for 2.2, but not 2.1.
2002-04-23 02:11:05 +00:00
Neal Norwitz 8ee3cd47a9 #546156, Remove load_false()/load_true(), they are not used 2002-04-21 23:44:34 +00:00
Neal Norwitz 0e0ee598fc #544265, Remove warnings for passing const to free() 2002-04-21 15:03:18 +00:00
Neal Norwitz 3d94942000 #546163, fix link problem on Solaris 8 for makedev when using mknod 2002-04-20 13:46:43 +00:00
Martin v. Löwis 6af3e2dc31 Forward port of patch # 500311: Work around for buggy https servers.
Fixes #494762.
2002-04-20 07:47:40 +00:00
Martin v. Löwis 2ea2c9d1c3 Patch #546194: Check constants individually. Fixes 534143 on OpenBSD.
Will backport to 2.2.
2002-04-19 21:04:41 +00:00
Neal Norwitz fdbeb5a4ce #546155, remove posix_int() it is not used 2002-04-19 14:58:40 +00:00
Jeremy Hylton c72737e7b6 Fix SF #544995 (zlib crash on second flush call)
Bug fix by mhammond.

Bug fix candidate for 2.2, not present in 2.1.
2002-04-19 14:37:07 +00:00
Martin v. Löwis bbeb1e6d91 Document the build process more precisely. Suggested by Hugh Sasse. 2002-04-19 09:47:23 +00:00
Fred Drake 4d1e64bb46 posix_fildes(): New helper: run a function that takes a file descriptor
and returns None.  This allows any object that supports the fileno()
    method to be passed as a file descriptor, not just an integer.

posix_fchdir():  New exposed function: implements posix.fchdir().  This
    closes SF feature #536796.

posix_fsync(), posix_fdatasync():  Convert to use posix_fildes() instead
    of posix_int().  This also changes them from METH_VARARGS to METH_O
    functions.

setup_confname_table():  Remove unused variable.  Change to take a module
    rather than a dict to save the resulting table into.

setup_confname_tables():  Change to take a module instead of a dict to
    pass to setup_confname_table().
2002-04-15 19:40:07 +00:00
Neal Norwitz 726e013eff Remove unused variable reported by Walter Dörwald 2002-04-15 16:29:00 +00:00
Martin v. Löwis 06a83e90aa Patch #543447: Add posix.mknod. 2002-04-14 10:19:44 +00:00
Fred Drake 88c9344986 initpwd(): Clean up initialization, avoid PyModule_GetDict(). 2002-04-13 21:07:45 +00:00
Tim Peters af3e8de580 First stab at rationalizing the PyMem_ API. Mixing PyObject_xyz with
PyMem_{Del, DEL} doesn't work yet (compilation problems).

pyport.h:  _PyMem_EXTRA is gone.

pmem.h:  Repaired comments.  PyMem_{Malloc, MALLOC} and
PyMem_{Realloc, REALLOC} now make the same x-platform guarantees when
asking for 0 bytes, and when passing a NULL pointer to the latter.

object.c:  PyMem_{Malloc, Realloc} just call their macro versions
now, since the latter take care of the x-platform 0 and NULL stuff
by themselves now.

pypcre.c, grow_stack():  So sue me.  On two lines, this called
PyMem_RESIZE to grow a "const" area.  It's not legit to realloc a
const area, so the compiler warned given the new expansion of
PyMem_RESIZE.  It would have gotten the same warning before if it
had used PyMem_Resize() instead; the older macro version, but not the
function version, silently cast away the constness.  IMO that was a wrong
thing to do, and the docs say the macro versions of PyMem_xyz are
deprecated anyway.  If somebody else is resizing const areas with the
macro spelling, they'll get a warning when they recompile now too.
2002-04-12 07:22:56 +00:00
Neil Schemenauer aa769ae468 PyObject_Del can now be used as a function designator. 2002-04-12 02:44:10 +00:00
Neil Schemenauer fec4eb1be1 Allow PyObject_Del to be used as a function designator. Provide binary
compatibility function.

Make PyObject_GC_Track and PyObject_GC_UnTrack functions instead of
trivial macros wrapping functions.  Provide binary compatibility
functions.
2002-04-12 02:41:03 +00:00
Jack Jansen 8ab04b4d65 Got rid of ifdefs for long-obsolete GUSI versions. 2002-04-11 20:46:23 +00:00
Thomas Heller 1630520e5c Fix an obvious bug. 2002-04-09 12:50:13 +00:00
Martin v. Löwis 688357e035 Patch #512005: getrusage() returns struct-like object. 2002-04-08 21:28:20 +00:00
Guido van Rossum 8fdc75ba5e Lock methods acquire() and locked() now return bools. 2002-04-07 06:32:21 +00:00
Guido van Rossum e276339cea Implement an idea by Paul Rubin:
Change pickling format for bools to use a backwards compatible
encoding.  This means you can pickle True or False on Python 2.3
and Python 2.2 or before will read it back as 1 or 0.  The code
used for pickling bools before would create pickles that could
not be read in previous Python versions.
2002-04-05 19:30:08 +00:00
Tim Peters bc0e910826 Convert a pile of obvious "yes/no" functions to return bool. 2002-04-04 22:55:58 +00:00
Guido van Rossum 2e1c09c1fd Removed old Digital Creations copyright/license notices (with
permission from Paul Everitt).  Also removed a few other references to
Digital Creations and changed the remaining ones to Zope Corporation.
2002-04-04 17:52:50 +00:00
Guido van Rossum 77f6a65eb0 Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
2002-04-03 22:41:51 +00:00
Fred Drake a2bd8d3816 Remove direct manipulation of the module dict. 2002-04-03 21:39:26 +00:00
Mark Hammond e7fefbf68d Fix bugs:
457466: popenx() argument mangling hangs python
 226766: popen('python -c"...."') tends to hang

Fixes argument quoting in w9xpopen.exe for Windows 9x.  w9xpopen.exe
also never attempts to display a MessageBox when not executed
interactively.

Added test_popen() test.  This test currently just executes
"python -c ..." as a child process, and checks that the expected
arguments were all recieved correctly by the child process.  This
test succeeds for me on Win9x, win2k and Linux, and I hope it does
for other popen supported platforms too :)
2002-04-03 01:47:00 +00:00
Neal Norwitz b0aaec5706 Convert more METH_OLDARGS & PyArg_Parse()
Please review.
2002-04-02 18:26:33 +00:00
Neal Norwitz 187ae56166 Get rid of more PyArg_Parse & METH_OLDARGS.
PyArg_Parse( "s" )  -> PyString_AsString
  PyArg_Parse( "t#" ) -> PyString_AsStringAndSize
2002-04-02 18:17:57 +00:00
Martin v. Löwis 2f6ef4c630 Reindent. Break long lines. Move comments before the statements. 2002-04-01 17:40:08 +00:00
Fred Drake 4baedc1d9b Use the PyModule_Add*() APIs instead of manipulating the module dict
directly.
2002-04-01 14:53:37 +00:00
Fred Drake 9bb7432114 Remove all but one use of the module dict. 2002-04-01 14:49:59 +00:00
Fred Drake d63e504d33 Remove unused variable and call to PyModule_GetDict(). 2002-04-01 14:30:50 +00:00
Fred Drake acee69faf8 Switch to using METH_NOARGS where possible.
Convert to use PyModule_*() instead of manipulating the module dict directly.
2002-04-01 14:28:58 +00:00
Martin v. Löwis 43c9d8ad23 Remove UNLESS. 2002-04-01 12:34:33 +00:00
Fred Drake f4e3484692 Use the PyModule_*() API instead of manipulating the module dictionary
directly.
2002-04-01 03:45:06 +00:00
Neal Norwitz 02098fa56b Get rid of all METH_OLDARGS & PyArg_Parse.
Fix floating point exception if mpz.powm(10, 1, 0) (modulus == 0).
Add a test.
2002-04-01 01:37:14 +00:00
Neal Norwitz dfd59e039a mpz_float() only takes one parameter now 2002-03-31 22:02:37 +00:00
Neal Norwitz 767f83539d Get rid of warnings due to changing to METH_NOARGS 2002-03-31 16:13:39 +00:00
Neal Norwitz 28faa1bf28 Convert METH_OLDARGS -> METH_NOARGS: remove args parameter
Use METH_OLDARGS explicitly rather than implicitly.
2002-03-31 15:56:56 +00:00
Neal Norwitz bb2769f580 Revert use of METH_OLDARGS (use 0) to support 1.5.2 2002-03-31 15:46:00 +00:00
Neal Norwitz b82d34f91e Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Please review for correctness.
2002-03-31 15:43:28 +00:00
Neal Norwitz ba3a16c6c3 Remove METH_OLDARGS:
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
  Convert METH_OLDARGS -> METH_NOARGS: remove args parameter
Please review.  All tests pass, but some modules don't have tests.
I spot checked various functions to try to make sure nothing broke.
2002-03-31 15:27:00 +00:00
Neal Norwitz 50905b557b Convert from using METH_OLDARGS to METH_NOARGS.
These should be safe.
2002-03-31 14:57:24 +00:00