Commit Graph

216 Commits

Author SHA1 Message Date
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Fred Drake a44d353e2b Trent Mick <trentm@activestate.com>:
The common technique for printing out a pointer has been to cast to a long
and use the "%lx" printf modifier. This is incorrect on Win64 where casting
to a long truncates the pointer. The "%p" formatter should be used instead.

The problem as stated by Tim:
> Unfortunately, the C committee refused to define what %p conversion "looks
> like" -- they explicitly allowed it to be implementation-defined. Older
> versions of Microsoft C even stuck a colon in the middle of the address (in
> the days of segment+offset addressing)!

The result is that the hex value of a pointer will maybe/maybe not have a 0x
prepended to it.


Notes on the patch:

There are two main classes of changes:
- in the various repr() functions that print out pointers
- debugging printf's in the various thread_*.h files (these are why the
patch is large)


Closes SourceForge patch #100505.
2000-06-30 15:01:00 +00:00
Fred Drake 13634cf7a4 This patch addresses two main issues: (1) There exist some non-fatal
errors in some of the hash algorithms. For exmaple, in float_hash and
complex_hash a certain part of the value is not included in the hash
calculation. See Tim's, Guido's, and my discussion of this on
python-dev in May under the title "fix float_hash and complex_hash for
64-bit *nix"

(2) The hash algorithms that use pointers (e.g. func_hash, code_hash)
are universally not correct on Win64 (they assume that sizeof(long) ==
sizeof(void*))

As well, this patch significantly cleans up the hash code. It adds the
two function _Py_HashDouble and _PyHash_VoidPtr that the various
hashing routine are changed to use.

These help maintain the hash function invariant: (a==b) =>
(hash(a)==hash(b))) I have added Lib/test/test_hash.py and
Lib/test/output/test_hash to test this for some cases.
2000-06-29 19:17:04 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Guido van Rossum 9e896b37c7 Marc-Andre's third try at this bulk patch seems to work (except that
his copy of test_contains.py seems to be broken -- the lines he
deleted were already absent).  Checkin messages:


New Unicode support for int(), float(), complex() and long().

- new APIs PyInt_FromUnicode() and PyLong_FromUnicode()
- added support for Unicode to PyFloat_FromString()
- new encoding API PyUnicode_EncodeDecimal() which converts
  Unicode to a decimal char* string (used in the above new
  APIs)
- shortcuts for calls like int(<int object>) and float(<float obj>)
- tests for all of the above

Unicode compares and contains checks:
- comparing Unicode and non-string types now works; TypeErrors
  are masked, all other errors such as ValueError during
  Unicode coercion are passed through (note that PyUnicode_Compare
  does not implement the masking -- PyObject_Compare does this)
- contains now works for non-string types too; TypeErrors are
  masked and 0 returned; all other errors are passed through

Better testing support for the standard codecs.

Misc minor enhancements, such as an alias dbcs for the mbcs codec.

Changes:
- PyLong_FromString() now applies the same error checks as
  does PyInt_FromString(): trailing garbage is reported
  as error and not longer silently ignored. The only characters
  which may be trailing the digits are 'L' and 'l' -- these
  are still silently ignored.
- string.ato?() now directly interface to int(), long() and
  float(). The error strings are now a little different, but
  the type still remains the same. These functions are now
  ready to get declared obsolete ;-)
- PyNumber_Int() now also does a check for embedded NULL chars
  in the input string; PyNumber_Long() already did this (and
  still does)

Followed by:

Looks like I've gone a step too far there... (and test_contains.py
seem to have a bug too).

I've changed back to reporting all errors in PyUnicode_Contains()
and added a few more test cases to test_contains.py (plus corrected
the join() NameError).
2000-04-05 20:11:21 +00:00
Guido van Rossum 4c08d554b9 Many changes for Unicode, by Marc-Andre Lemburg. 2000-03-10 22:55:18 +00:00
Guido van Rossum bffd683f73 The rest of the changes by Trent Mick and Dale Nagata for warning-free
compilation on NT Alpha.  Mostly added casts etc.
2000-01-20 22:32:56 +00:00
Guido van Rossum 57072eb79f Implement the other easy thing: repr() of a float now uses %.17g,
while str() uses %.12g as before.
1999-12-23 19:00:28 +00:00
Barry Warsaw 226ae6ca12 Mainlining the string_methods branch. See branch revision log
messages for specific changes.
1999-10-12 19:54:53 +00:00
Guido van Rossum 9263e78ff2 Tim Peters writes:
1. Fixes float divmod so that the quotient it returns is always an integral
value.

2. Fixes float % and float divmod so that the remainder always gets the
right sign (the current code uses a "are the signs different?" test that
doesn't work half the time <wink> when the product of the divisor and the
remainder underflows to 0).
1999-05-06 14:26:34 +00:00
Guido van Rossum d7b5fb858c Fix a problem with Vladimir's PyFloat_Fini code: clear the free list; if
a block cannot be freed, add its free items back to the free list.
This is necessary to avoid leaking when Python is reinitialized later.
1999-03-19 20:59:40 +00:00
Guido van Rossum 3fce883922 Vladimir has restructured his code somewhat so that the blocks are now
represented by an explicit structure.  (There are still too many casts
in the code, but that may be unavoidable.)

Also added code so that with -vv it is very chatty about what it does.
1999-03-12 19:43:17 +00:00
Guido van Rossum f61bbc8182 OK, try again. Vladimir gave me a fix for the alignment bus error,
so here's his patch again.  This time it works (at least on Solaris,
Linux and Irix).
1999-03-12 00:12:21 +00:00
Guido van Rossum a060fb2598 Alas, Vladimir's patch caused a bus error (probably double
alignment?), and I didn't test it.  Withdrawing it for now.
1999-03-11 01:47:00 +00:00
Guido van Rossum 881928f7ab Patch by Vladimir Marangoz to allow freeing of the allocated blocks of
floats on finalization.
1999-03-10 22:55:47 +00:00
Guido van Rossum 3c03fa87b6 Hack suggested by Matthias Klose to pull in all relevant entry points
in libmath.a so they are available to mathmodule.so (in case it is
shared).  While this still gets triggered on Solaris 2.x, this appears
to be harmless there.
1997-10-31 17:00:30 +00:00
Guido van Rossum fbbd57e4ca Added _Fini() routines to free up some memory 1997-08-05 02:16:08 +00:00
Guido van Rossum 93ad0df06c Faster floating point allocator, same idea as the int allocator.
By Aaron Watters.
1997-05-13 21:00:42 +00:00
Guido van Rossum c0b618a2cc Quickly renamed the last directory. 1997-05-02 03:12:38 +00:00
Guido van Rossum 45b83915f8 New form of PyFPE_END_PROTECT macro. 1997-03-14 04:32:50 +00:00
Guido van Rossum 09e6ad0c1e Changes for Lee Busby's SIGFPE patch set.
Surround various f.p. operations with  PyFPE_{START,END}_PROTECT macros.
1997-02-14 22:54:21 +00:00
Guido van Rossum 919cf1aff1 New, better hash for floating point and complex 1997-01-11 19:26:21 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum b23a60fd6e Get rid of bogus MSC_VER undef of CHECK() 1996-09-11 20:21:41 +00:00
Guido van Rossum c13bcca268 Test for negative # to the nonintegral float power here.
Expanded powi() in-line.
1996-08-16 20:42:57 +00:00
Guido van Rossum 86c04c252b Correct wrong calculation of pow(0.0, 0.0, negative_number) 1996-08-09 20:50:14 +00:00
Guido van Rossum 9d81b5594e Different logic for defining CHECK(); 16-bit MSC specific define. 1996-06-26 18:27:19 +00:00
Guido van Rossum 363078afa4 make some things static 1996-05-24 20:45:01 +00:00
Guido van Rossum 39739ea0ed better power implementation 1996-01-12 01:22:56 +00:00
Guido van Rossum 07e3a7e781 for MPW __SC__ compiler 1995-02-27 10:13:37 +00:00
Guido van Rossum 67ca701939 NeXT/Sparc 3.3 fix 1995-02-13 16:38:41 +00:00
Guido van Rossum 9fa2c11613 use Py_CHARMASK; and don't check for neg. float to the float power here 1995-02-10 17:00:37 +00:00
Guido van Rossum 4d3468deab don't declare fmod/pow for any STDC compiler 1995-01-17 16:33:14 +00:00
Guido van Rossum 6610ad9d6b Added 1995 to copyright message.
floatobject.c: fix hash().
methodobject.c: support METH_FREENAME flag bit.
1995-01-04 19:07:38 +00:00
Guido van Rossum d7047b395e Lots of minor changes. Note for mappingobject.c: the hash table pointer
can now be NULL.
1995-01-02 19:07:15 +00:00
Guido van Rossum 03093a248d * Include/classobject.h, Objects/classobject.c, Python/ceval.c:
entirely redone operator overloading.  The rules for class
	instances are now much more relaxed than for other built-in types
	(whose coerce must still return two objects of the same type)

	* Objects/floatobject.c: add overflow check when converting float
	to int and implement truncation towards zero using ceil/float

	* Objects/longobject.c: change ValueError to OverflowError when
	converting to int

	* Objects/rangeobject.c: modernized

	* Objects/stringobject.c: use HAVE_LIMITS instead of __STDC__

	* Objects/xxobject.c: changed to use new style (not finished?)
1994-09-28 15:51:32 +00:00
Guido van Rossum 0b7d02a36f New patches by Andrew to fix various problems 1994-08-12 12:52:35 +00:00
Guido van Rossum b6775db241 Merge alpha100 branch back to main trunk 1994-08-01 11:34:53 +00:00
Sjoerd Mullender a9c3c22c33 * Extended X interface: pixmap objects, colormap objects visual objects,
image objects, and lots of new methods.
* Added counting of allocations and deallocations of builtin types if
  COUNT_ALLOCS is defined.  Had to move calls to NEWREF down in some
  files.
* Bug fix in sorting lists.
1993-10-11 12:54: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 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 9575a44575 * Microscopic corrections to make things compile on the Cray APP.
* Removed one use of $> in Makefile and warned about others.
  Added configurable lines in Makefile to change CC and AR.
1993-04-07 14:06:14 +00:00
Guido van Rossum 9bfef44d97 * Changed all copyright messages to include 1993.
* Stubs for faster implementation of local variables (not yet finished)
* Added function name to code object.  Print it for code and function
  objects.  THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version
  number has changed accordingly)
* Print address of self for built-in methods
* New internal functions getattro and setattro (getattr/setattr with
  string object arg)
* Replaced "dictobject" with more powerful "mappingobject"
* New per-type functio tp_hash to implement arbitrary object hashing,
  and hashobject() to interface to it
* Added built-in functions hash(v) and hasattr(v, 'name')
* classobject: made some functions static that accidentally weren't;
  added __hash__ special instance method to implement hash()
* Added proper comparison for built-in methods and functions
1993-03-29 10:43:31 +00:00
Guido van Rossum e537240c25 * Changed many files to use mkvalue() instead of newtupleobject().
* Fixcprt.py: added [-y file] option, do only files younger than file.
* modsupport.[ch]: added vmkvalue().
* intobject.c: use mkvalue().
* stringobject.c: added "formatstring"; renamed string* to string_*;
  ceval.c: call formatstring for string % value.
* longobject.c: close memory leak in divmod.
* parsetok.c: set result node to NULL when returning an error.
1993-03-16 12:15:04 +00:00
Guido van Rossum 1899c2e055 Made builtins int(), long(), float(), oct() and hex() more generic. 1992-09-12 11:09:23 +00:00
Guido van Rossum e6eefc2231 * classobject.[ch], {float,long,int}object.c, bltinmodule.c:
coercion is now completely generic.
* ceval.c: for instances, don't coerce for + and *; * reverses
  arguments if left one is non-instance numeric and right one sequence.
1992-08-14 12:06:52 +00:00
Guido van Rossum bab9d03855 Copyright for 1992 added 1992-04-05 14:26:55 +00:00
Guido van Rossum 3132a5a7dc answer lint's complaints 1992-03-27 17:28:44 +00:00
Guido van Rossum 56cd67ad47 Get rid of redundant type checks.
Define % operator similar to int%int.
1992-01-26 18:16:35 +00:00
Guido van Rossum 7fa52f84c7 Explicitly check for weird values after calling pow(). 1991-12-16 15:43:14 +00:00
Guido van Rossum 9a9faddbcb Formulate better error strings. 1991-12-10 13:56:55 +00:00
Guido van Rossum 27acb3379e Added NULL function pointers for shift and mask ops. 1991-10-24 14:55:28 +00:00
Guido van Rossum 15ecff4c5e Finally implemented divmod(). 1991-10-20 20:16:45 +00:00
Guido van Rossum 909336104b printobject now returns an error code 1991-06-07 16:10:43 +00:00
Guido van Rossum 27dec7e376 Export float_buf_repr() interface, for marshalling of floats. 1991-06-04 19:42:53 +00:00
Guido van Rossum 70d934601f Fix special cases in pow() 1991-05-28 21:57:39 +00:00
Guido van Rossum 50b4ef64eb Added nonzero test 1991-05-14 11:57:01 +00:00
Guido van Rossum eba1b5efe1 Added (dummy) divmod and (functional) abs.
Fixed comments in number methods list
1991-05-05 20:07:00 +00:00
Guido van Rossum f70e43a073 Added copyright notice. 1991-02-19 12:39:46 +00:00
Guido van Rossum c211ee4b13 Added <errno.h> 1990-12-20 23:06:26 +00:00
Guido van Rossum 3f5da24ea3 "Compiling" version 1990-12-20 15:06:42 +00:00
Guido van Rossum 6923e134fc Moved prototyes for fmod and pow, and don't use them for THINK C. 1990-11-02 17:50:43 +00:00
Guido van Rossum 726749cc5b Added some prototypes. 1990-10-30 13:30:32 +00:00
Guido van Rossum 2a9096b5f9 New errors. 1990-10-21 22:15:08 +00:00
Guido van Rossum 85a5fbbdfe Initial revision 1990-10-14 12:07:46 +00:00