Commit Graph

134 Commits

Author SHA1 Message Date
Guido van Rossum c410e92974 Jack Jansen:
This patch is a workaround for Macintosh, where the GUSI I/O library
(time, stat, etc) use the MacOS epoch of 1-Jan-1904 and the MSL C
library (ctime, localtime, etc) uses the (apparently ANSI standard)
epoch of 1-Jan-1900. Python programs see the MacOS epoch and we
convert values when needed.
2000-04-26 20:40:13 +00:00
Andrew M. Kuchling c24ca4b192 Fix probable bug; if errno == EINTR, floatsleep() doesn't break out of
a Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS block, but it
   calls Py_BLOCK_THREADS anyway. The change moves Py_BLOCK_THREADS
   to inside the if, so it's only executed when the function
   actually returns unexpectedly.
2000-03-24 20:35:20 +00:00
Jeremy Hylton 7ceab65468 Fix bogus error reporting on strptime: let PyArg_ParseTuple set exception.
Also, wrap long line.
2000-03-14 21:17:16 +00:00
Guido van Rossum 43713e5a28 Massive patch by Skip Montanaro to add ":name" to as many
PyArg_ParseTuple() format string arguments as possible.
2000-02-29 13:59:29 +00:00
Guido van Rossum b2b42ddcb1 The functions asctime() and mktime() are documented to take a 9-tuple
only.  Through some mysterious interaction, they would take 9 separate
arguments as well.  This misfeature is now disabled (to end a
difference with JPython).
2000-01-12 16:38:20 +00:00
Guido van Rossum 09cbb01989 Jack Jansen: Mac has no EINTR. 1999-11-08 15:32:27 +00:00
Guido van Rossum a5456d5042 In floatsleep(), when using select(), ignore EINTR error. 1999-08-19 14:40:27 +00:00
Guido van Rossum ea424e19f1 Apparently __GNU_LIBRARY__ is defined for glibc as well as for libc5.
The test really wanted to distinguish between the two.  So now we test
for __GLIBC__ instead.  I have confirmed that this works for glibc and
I have an email from Christian Tanzer confirming that it works for
libc5, so it should be fine.
1999-04-23 20:59:05 +00:00
Guido van Rossum 0ffdd05cc3 Jonathan Giddy notes, and Chris Lawrence agrees, that some comments on
#else/#endif are wrong, and that #if HAVE_TM_ZONE should be #ifdef.
1999-04-05 21:54:14 +00:00
Guido van Rossum 4958f9af97 #$@%! Forgot to remove a #error directive used for testing. Sorry. 1999-03-29 19:12:41 +00:00
Guido van Rossum 57731607c3 Chris Lawrence writes:
"""
The GNU folks, in their infinite wisdom, have decided not to implement
altzone in libc6; this would not be horrible, except that timezone
(which is implemented) includes the current DST setting (i.e. timezone
for Central is 18000 in summer and 21600 in winter).  So Python's
timezone and altzone variables aren't set correctly during DST.

Here's a patch relative to 1.5.2b2 that (a) makes timezone and altzone
show the "right" thing on Linux (by using the tm_gmtoff stuff
available in BSD, which is how the GLIBC manual claims things should
be done) and (b) should cope with the southern hemisphere.  In pursuit
of (b), I also took the liberty of renaming the "summer" and "winter"
variables to "july" and "jan".  This patch should also make certain
time calculations on Linux actually work right (like the tz-aware
functions in the rfc822 module).

(It's hard to find DST that's currently being used in the southern
hemisphere; I tested using Africa/Windhoek.)
"""
1999-03-29 19:12:04 +00:00
Guido van Rossum d3eb5774ad Patch by Chris Herborth for BeOS code.
He writes:

I had an off-by-1000 error in floatsleep(),
and the problem with time.clock() is that it's not implemented properly
on QNX... ANSI says it's supposed to return _CPU_ time used by the
process, but on QNX it returns the amount of real time used... so I was
confused.
1999-03-09 16:07:23 +00:00
Guido van Rossum c222ec28a5 Patch by Tadayoshi Funaba (with some changes) to be smarter about
guessing what happened when strftime() returns 0.  Is it buffer
overflow or was the result simply 0 bytes long?  (This happens for an
empty format string, or when the format string is a single %Z and the
timezone is unknown.)  if the buffer is at least 256 times as long as
the format, assume the latter.
1999-02-23 00:00:10 +00:00
Guido van Rossum 360eb9f278 We don't support leap seconds, so the seconds field of a time 9-tuple
should be in the range [0-59].  Noted by Tadayoshi Funaba.
1999-02-22 16:19:52 +00:00
Guido van Rossum 446ccfe1ac The doc string for strptime had the arguments reversed -- the string
comes first, the format second!  Scott Cotton discovered this.
1999-01-07 18:29:26 +00:00
Guido van Rossum 0a6363d7e1 Get rid of the strptype() declaration -- on some BSD systems, it's a
conflict, and it should be declared in time.h anyway.
(Too bad if gcc -Wall won't be happy if it isn't declared...)
1999-01-03 13:00:34 +00:00
Guido van Rossum 3886bb6997 Add DL_EXPORT() to all modules that could possibly be used
on BeOS or Windows.
1998-12-04 18:50:17 +00:00
Guido van Rossum c20687355b Make gcc -Wall happy:
(1) add dummy decl for strptime();
(2) move the code to set accept2dyear to the front of inittime().
1998-10-07 16:35:25 +00:00
Guido van Rossum 2645241add Fixes for OS/2 by Jeff Rush. 1998-09-28 22:07:11 +00:00
Guido van Rossum cfbaecc546 Y2K fix affecting asctime(), mktime(), strftime().
2-digit years are now converted using rules that are (according to
Fredrik Lundh) recommended by POSIX or X/Open: 0-68 mean 2000-2068,
69-99 mean 1969-1999.

2-digit years are now only accepted if time.accept2dyear is set to a
nonzero integer; if it is zero or not an integer or absent, only year
values >= 1900 are accepted.  Year values 100-1899 and negative year
values are never accepted.

The initial value of time.accept2dyear depends on the environment
variable PYTHONY2K: if PYTHONY2K is set and non-empty,
time.accept2dyear is initialized to 0; if PYTHONY2K is empty or not
set, time.accept2dyear is initialized to 0.
1998-08-25 14:51:12 +00:00
Guido van Rossum bcc207484a Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:53:56 +00:00
Guido van Rossum 0ef577b966 Added doc strings. 1998-06-27 20:38:36 +00:00
Guido van Rossum 87ce7bbc39 Added strptime, if it exists. Modified after a patch by Jesse Hallio. 1998-06-09 16:30:31 +00:00
Guido van Rossum 1f41f846a3 Instead of calling mktime(), which has all sorts of unwanted side
effects, simply zero out the struct tm buffer before using it; this
should take care of the BSD folks' concern just as well.
1998-04-27 19:04:26 +00:00
Guido van Rossum 60cd813810 Check for HAVE_MKTIME (if you don't have it, some tests will fail, but
at least the build will now succeed).  For Sony NEWS-OS, BSD 4.3 based.
1998-03-06 17:16:21 +00:00
Guido van Rossum 7853570651 Raise ValueError: "unconvertible time" when ctime() returns NULL,
instead of dumping core.
1998-03-03 22:19:10 +00:00
Guido van Rossum 1d0d7e4e48 At Jeff Rush' request, add Py_BEGIN/END_ALLOW_THREADS around call to
DosSleep().
1997-12-29 20:03:10 +00:00
Guido van Rossum be1eb0d9ed (1) call mktime() just before strftime(); it normalizes the buffer and
may set the timezone name for BSD systems...

(2) fake all of the timezone variables for the mac.
1997-12-08 21:56:43 +00:00
Guido van Rossum 7bf22de753 Patch for QNX, by Chris Herborth. 1997-12-02 20:34:19 +00:00
Guido van Rossum 8e9ebfd337 os2 patch by Jeff Rush 1997-11-22 21:53:48 +00:00
Guido van Rossum 8607ae2e57 Move the Py_{{BEGIN,END}_ALLOW,BLOCK}_THREADS macros in time_sleep()
to inside floatsleep().  This is necessary because floatsleep() does
the error handling and it must have grabbed the interpreter lock and
thread state before it can do so.
1997-11-03 22:04:46 +00:00
Guido van Rossum e6a4b7bf3e timezone support for macintosh (Jack) 1997-10-08 15:27:56 +00:00
Guido van Rossum 3917c22125 Win32 precision clock() -- Mark Hammond. 1997-04-02 05:35:28 +00:00
Guido van Rossum a78bfe1985 Issue a more meaningful error if strftime keeps returning a NULL pointer.
Run the loop up to and including 8k.
1997-02-14 16:35:10 +00:00
Barry Warsaw 4a6cf4167b Formatting, and minor error detection 1997-01-13 22:44:55 +00:00
Guido van Rossum 52174577eb Added #ifdef around ``extern int ftime();'' for MS WINDOWS (which has
a conflicting definition somewhere).
Resolved line wrap for error message in ins().
1996-12-09 18:38:52 +00:00
Barry Warsaw ec775c52a2 ins(): missed a renaming in a string: dictinsert =>
PyDict_SetItemString.

GvR: note the long line > 80 chars.  Wrapping suggestions?
1996-12-09 18:24:35 +00:00
Barry Warsaw 9a2a8a8d31 Greatly renamed. 1996-12-06 23:32:14 +00:00
Guido van Rossum 1bb126fa13 Add extern decl of ftime() to make gcc -Wall happy. 1996-12-06 20:17:44 +00:00
Guido van Rossum 0b1ff66920 Should compare errno to 0, not NULL 1996-11-02 17:31:22 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum 6e8583dcb3 Check for NULL pointer returned from localtime()/gmtime(). 1996-10-08 14:19:52 +00:00
Guido van Rossum b2fb36498d Sleep() turns out to be win32 specific.
The timezone etc. overrides are win16 specific.
Hope I got this right now...
1996-09-07 00:47:35 +00:00
Guido van Rossum cac6c72105 Some changes for better Windows portability. 1996-09-06 13:34:02 +00:00
Guido van Rossum 99d90c0d0e Include "mymath.h" instead of manually declaring math functions. 1996-08-08 19:17:45 +00:00
Guido van Rossum bceeac8dc1 Watcom changes.
Add mktime() overflow test and make it NeXT robust by initializing
the structure from localtime().
1996-05-23 22:53:47 +00:00
Guido van Rossum 1b66a4f01d default CLOCKS_PER_SEC to CLK_TCK if it exists 1996-02-25 04:50:33 +00:00
Guido van Rossum 5416e20037 mark strftime as varargs 1996-02-13 00:14:09 +00:00
Jack Jansen 8ccfc93c2f Removed unused variable 1995-10-03 14:39:44 +00:00
Guido van Rossum 8d8c1eeed7 added time.strftime() 1995-09-13 17:38:35 +00:00
Guido van Rossum cc08112ff4 tiny additions for Windows 3.1 1995-03-14 15:05:41 +00:00
Guido van Rossum a320fd308c changes for MPW 1995-03-09 12:14:15 +00:00
Guido van Rossum 8239f0ffa0 fix leaks 1995-01-22 00:49:01 +00:00
Guido van Rossum 524b588553 Added 1995 to copyright message.
Setup.in: clarified Tk comments somewhat.
structmodule.c: use memcpy() instead of double precision assignment.
1995-01-04 19:10:35 +00:00
Guido van Rossum 3bbc62e9c2 Another bulky set of minor changes.
Note addition of gethostbyaddr() and improved repr() for sockets,
renaming of md5.md5() to md5.new(), and fixing of leaks in threads.
1995-01-02 19:30:30 +00:00
Guido van Rossum 7b1e974b4b Makefile.pre.in: add $(OPT) to link command
audioop.c: fix for MPW
config.c.in: save original argc/argv for Lance
rotormodule.c: new coding conventions
timemodule.c: add casts for Lance
1994-08-29 10:46:42 +00:00
Guido van Rossum b6775db241 Merge alpha100 branch back to main trunk 1994-08-01 11:34:53 +00:00
Guido van Rossum b376a4ad18 * timemodule.c: Add hack for Solaris 2.
* posixmodule.c: don't prototype getcwd() -- it's not portable...
* mappingobject.c: double-check validity of last_name_char in
  dict{lookup,insert,remove}.
* arraymodule.c: need memmove only for non-STDC Suns.
* Makefile: comment out HTML_LIBS and XT_USE by default
* pythonmain.c: don't prototype getopt() -- it's not standardized
* socketmodule.c: cast flags arg to {get,set}sockopt() and addrbuf arg to
  recvfrom() to (ANY*).
* pythonrun.c (initsigs): fix prototype, make it static
* intobject.c (LONG_BIT): only #define it if not already defined
* classobject.[ch]: remove all references to unused instance_convert()
* mappingobject.c (getmappingsize): Don't return NULL in int function.
1993-11-23 17:53:17 +00:00
Guido van Rossum e22e6442b7 * config.c: different default PYTHONPATH for MS-DOS
* timemodule.c: change #ifdef TURBO_C into #ifdef MSDOS
* posixmodule.c: MSDOS changes by Marcel van der Peijl (Digicash)
* stropmodule.c: use C isspace(c) to test for whitespace; add
  whitespace, lowercase and uppercase variables to the module.
1993-07-09 10:51:31 +00:00
Guido van Rossum f1dc566328 * Makefile: added all: and default: targets.
* many files: made some functions static; removed "extern int errno;".
* frozenmain.c: fixed bugs introduced on 24 June...
* flmodule.c: remove 1.5 bw compat hacks, add new functions in 2.2a
  (and some old functions that were omitted).
* timemodule.c: added MSDOS floatsleep version .
* pgenmain.c: changed exit() to goaway() and added defn of goaway().
* intrcheck.c: add hack (to UNIX only) so interrupting 3 times
  will exit from a hanging program.  The second interrupt prints
  a message explaining this to the user.
1993-07-05 10:31:29 +00:00
Guido van Rossum 9e90a672b4 * pythonmain.c: -k option, usage message, more environment flags.
(the latter also in frozenmain.c)
* ceval.c: global 'killprint' flag raises exception when printing an
  expression statement's value (useful for finding stray output)
* timemodule.c: add asctime() and ctime().  Change julian date to
  1-based origin (as intended and documented).
* Removed unused DO_TIMES stuff from timemodule.c.  Added 'epoch' and
  'day0' globals (year where time.time() == 0 and day of the week the
  epoch started).
1993-06-24 11:10:19 +00:00
Guido van Rossum 234f942aef * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Added $(SYSDEF) to its build rule in Makefile.
* cgensupport.[ch], modsupport.[ch]: removed some old stuff.  Also
  changed files that still used it...  And made several things static
  that weren't but should have been...  And other minor cleanups...
* listobject.[ch]: add external interfaces {set,get}listslice
* socketmodule.c: fix bugs in new send() argument parsing.
* sunaudiodevmodule.c: added flush() and close().
1993-06-17 12:35:49 +00:00
Guido van Rossum 0b0db8e3a0 Added separate main program for the Mac: macmain.c
stdwinmodule.c: wsetfont can now return an error
Makefile: add CL_USE and CL_LIB*S; config.c: move CL part around
New things in imgfile; also in Makefile.
longobject.c: fix comparison of negative long ints...  [REAL BUG!]
marshal.c: add dumps() and loads() to read/write strings
timemodule.c: make sure there's always a floatsleep()
posixmodule.c: rationalize struct returned by times()
Makefile: add test target, disable imgfile by default
thread.c: Improved coexistance with dl module (sjoerd)
stdwinmodule.c: Change include stdwin.h if macintosh
rotormodule.c: added missing last argument to RTR_?_region calls
confic.c: merged with configmac.c, added 1993 to copyright message
fileobject.c: int compared to NULL in writestring(); change fopenRF ifdef
timemodule.c: simplify times() using mkvalue; include myselect.h
  earlier (for sequent).
posixmodule: for sequent, include unistd.h instead of explicit
  extern definitions and don't define rename()
Makefile: change misleading/wrong MD5 comments
1993-01-21 16:07:51 +00:00
Guido van Rossum 775f4dacbc * Makefile: use cp -r to install the library
* ceval.c: use #ifdef COMPAT_HACKS instead of #if 0
* Makefile: fix to make clmodule.c compile;
  make config.o dependent on libpython.a (so date is always correct)
* timemodule.c: now sleep() also takes a float argument.
* posixmodule.c: added nice().
1993-01-09 17:18:52 +00:00
Guido van Rossum a2b7f40513 * Configure.py: use #!/usr/local/bin/python
* posixmodule.c: move extern function declarations to top
* listobject.c: cmp() arguments must be void* if __STDC__
* Makefile, allobjects.h, panelmodule.c, modsupport.c: get rid of
  strdup() -- it is a portability risk
* Makefile: enclosed ranlib command in parentheses for Sequent Make
  which aborts if the command is not found even if '-' is present
* timemodule.c: time() returns a floating point number, in microsecond
  precision if BSD_TIME is defined.
1993-01-04 09:09:59 +00:00
Guido van Rossum 6d946f98bd * macmodule.c: include allobjects.h, not .c
* timemodule.c: the mac has no unistd.h
* classobject.c: fixed several cases of return NULL that should be
  return -1 !!!
1992-08-14 13:49:30 +00:00
Guido van Rossum ff4949eeee * Makefile: cosmetics
* socketmodule.c: get rid of makepair(); fix makesocketaddr to fix
  broken recvfrom()
* socketmodule: get rid of getStrarg()
* ceval.h: move eval_code() to new file eval.h, so compile.h is no
  longer needed.
* ceval.c: move thread comments to ceval.h; always make save/restore
  thread functions available (for dynloaded modules)
* cdmodule.c, listobject.c: don't include compile.h
* flmodule.c: include ceval.h
* import.c: include eval.h instead of ceval.h
* cgen.py: add forground(); noport(); winopen(""); to initgl().
* bltinmodule.c, socketmodule.c, fileobject.c, posixmodule.c,
  selectmodule.c:
  adapt to threads (add BGN/END SAVE macros)
* stdwinmodule.c: adapt to threads and use a special stdwin lock.
* pythonmain.c: don't include getpythonpath().
* pythonrun.c: use BGN/END SAVE instead of direct calls; also more
  BGN/END SAVE calls etc.
* thread.c: bigger stack size for sun; change exit() to _exit()
* threadmodule.c: use BGN/END SAVE macros where possible
* timemodule.c: adapt better to threads; use BGN/END SAVE; add
  longsleep internal function if BSD_TIME; cosmetics
1992-08-05 19:58:53 +00:00
Guido van Rossum 1984f1e1c6 * Makefile adapted to changes below.
* split pythonmain.c in two: most stuff goes to pythonrun.c, in the library.
* new optional built-in threadmodule.c, build upon Sjoerd's thread.{c,h}.
* new module from Sjoerd: mmmodule.c (dynamically loaded).
* new module from Sjoerd: sv (svgen.py, svmodule.c.proto).
* new files thread.{c,h} (from Sjoerd).
* new xxmodule.c (example only).
* myselect.h: bzero -> memset
* select.c: bzero -> memset; removed global variable
1992-08-04 12:41:02 +00:00
Guido van Rossum ed233a5696 Changes for new UNIX-specific built-in module 'select' and new header for
interfaces to variants of select() system call, "myselect.h".  This includes
adding fileno() methods to files, sockets and stdwin.
1992-06-23 09:07:03 +00:00
Guido van Rossum dfd6e46779 Fix for SEQUENT by Jaap Vermeulen 1992-06-12 10:39:22 +00:00
Guido van Rossum f1644a54ad Don't define DO_TIMES (now in posixmodule.c) 1992-04-05 14:25:41 +00:00
Guido van Rossum 2762f250eb Initialized sigsave to shut lint up 1992-03-27 17:22:13 +00:00
Guido van Rossum 27aaa6daa9 Add interface to times(2). 1992-03-12 17:33:14 +00:00
Guido van Rossum 0bb1a51925 AIX fix. 1991-11-27 14:55:18 +00:00
Guido van Rossum 00c567ce6f All mac compilers now use 1904 as the Epoch... 1991-07-27 23:09:30 +00:00
Guido van Rossum 1d2a9ade93 Generalize to macintosh; forget Think 3.0. 1991-06-24 22:23:45 +00:00
Guido van Rossum 6a1f54c09c Include sys/select.h for IBM R2 1991-05-05 20:15:54 +00:00
Guido van Rossum 80c9d88cbf New hacks for include files to get time_t in the most portable way.
Added Turbo C milli functions (courtesy Mark Anacker)
Disable THINK C sleep for 4.0
1991-04-16 08:47:51 +00:00
Guido van Rossum 6590d4a250 Hack for THINK C time function.
Made more functions externally visible.
1991-04-04 10:49:03 +00:00
Guido van Rossum 5662746a9e Made millitimer() and millisleep() global (what the heck...). 1991-04-03 19:15:32 +00:00
Guido van Rossum f70e43a073 Added copyright notice. 1991-02-19 12:39:46 +00:00
Guido van Rossum 426035c543 Added BSD implementations of millisleep. 1991-02-19 12:27:35 +00:00
Guido van Rossum 3f5da24ea3 "Compiling" version 1990-12-20 15:06:42 +00:00
Guido van Rossum 85a5fbbdfe Initial revision 1990-10-14 12:07:46 +00:00