Commit Graph

2863 Commits

Author SHA1 Message Date
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