summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* Try to recover from that glibc's ldexp apparently doesn't set errno onTim Peters2001-09-051-2/+2
| | | | | overflow. Needs testing on Linux (test_long.py and test_long_future.py especially).
* At Guido's suggestion, here's a new C API function, PyObject_Dir(), likeTim Peters2001-09-041-0/+145
| | | | __builtin__.dir(). Moved the guts from bltinmodule.c to object.c.
* Change long/long true division to return as many good bits as it can;Tim Peters2001-09-042-2/+40
| | | | e.g., (1L << 40000)/(1L << 40001) returns 0.5, not Inf or NaN or whatever.
* Move int_true_divide next to the other division routines.Tim Peters2001-09-041-6/+6
|
* Move long_true_divide next to the other division routines (for clarity!).Tim Peters2001-09-041-6/+6
|
* Raise OverflowError when appropriate on long->float conversion. Most ofTim Peters2001-09-043-23/+27
| | | | | | | the fiddling is simply due to that no caller of PyLong_AsDouble ever checked for failure (so that's fixing old bugs). PyLong_AsDouble is much faster for big inputs now too, but that's more of a happy consequence than a design goal.
* PEP 238 documented -Qwarn as warning only for classic int or longGuido van Rossum2001-09-042-2/+2
| | | | | division, and this makes sense. Add -Qwarnall to warn for all classic divisions, as required by the fixdiv.py tool.
* Introduce new private API function _PyLong_AsScaledDouble. Not used yet,Tim Peters2001-09-041-0/+52
| | | | | | | | | | but will be the foundation for Good Things: + Speed PyLong_AsDouble. + Give PyLong_AsDouble the ability to detect overflow. + Make true division of long/long nearly as accurate as possible (no spurious infinities or NaNs). + Return non-insane results from math.log and math.log10 when passing a long that can't be approximated by a double better than HUGE_VAL.
* New restriction on pow(x, y, z): If z is not None, x and y must be ofTim Peters2001-09-033-18/+20
| | | | | integer types, and y must be >= 0. See discussion at http://sf.net/tracker/index.php?func=detail&aid=457066&group_id=5470&atid=105470
* Repair typo in comment.Tim Peters2001-09-021-1/+1
|
* Make dictionary() a real constructor. Accepts at most one argument, "aTim Peters2001-09-021-2/+29
| | | | | | | | | | | | mapping object", in the same sense dict.update(x) requires of x (that x has a keys() method and a getitem). Questionable: The other type constructors accept a keyword argument, so I did that here too (e.g., dictionary(mapping={1:2}) works). But type_call doesn't pass the keyword args to the tp_new slot (it passes NULL), it only passes them to the tp_init slot, so getting at them required adding a tp_init slot to dicts. Looks like that makes the normal case (i.e., no args at all) a little slower (the time it takes to call dict.tp_init and have it figure out there's nothing to do).
* Rewrite the tuple() docstring to parallel the list() docstring.Tim Peters2001-09-021-4/+4
|
* Repair apparent cut'n'pasteo in tuple() docstring.Tim Peters2001-09-021-1/+1
|
* Add warning mode for classic division, almost exactly as specified inGuido van Rossum2001-08-315-5/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PEP 238. Changes: - add a new flag variable Py_DivisionWarningFlag, declared in pydebug.h, defined in object.c, set in main.c, and used in {int,long,float,complex}object.c. When this flag is set, the classic division operator issues a DeprecationWarning message. - add a new API PyRun_SimpleStringFlags() to match PyRun_SimpleString(). The main() function calls this so that commands run with -c can also benefit from -Dnew. - While I was at it, I changed the usage message in main() somewhat: alphabetized the options, split it in *four* parts to fit in under 512 bytes (not that I still believe this is necessary -- doc strings elsewhere are much longer), and perhaps most visibly, don't display the full list of options on each command line error. Instead, the full list is only displayed when -h is used, and otherwise a brief reminder of -h is displayed. When -h is used, write to stdout so that you can do `python -h | more'. Notes: - I don't want to use the -W option to control whether the classic division warning is issued or not, because the machinery to decide whether to display the warning or not is very expensive (it involves calling into the warnings.py module). You can use -Werror to turn the warnings into exceptions though. - The -Dnew option doesn't select future division for all of the program -- only for the __main__ module. I don't know if I'll ever change this -- it would require changes to the .pyc file magic number to do it right, and a more global notion of compiler flags. - You can usefully combine -Dwarn and -Dnew: this gives the __main__ module new division, and warns about classic division everywhere else.
* Fix a memory leak in str_subtype_new(). (All the otherGuido van Rossum2001-08-311-3/+3
| | | | xxx_subtype_new() functions are OK, but I goofed up in this one. :-( )
* Give 'super' a decent repr(), and readonly attributes to access theGuido van Rossum2001-08-301-11/+36
| | | | | type and obj properties. The "bogus super object" message is gone -- this will now just raise an AttributeError.
* PyObject_Repr(): add missing ">" back at end of format string: "<%sGuido van Rossum2001-08-301-1/+1
| | | | object at %p>".
* Squash new compiler wng.Tim Peters2001-08-301-1/+1
|
* Pytype_GenericAlloc(): round up size so we zap all four bytes of theGuido van Rossum2001-08-301-16/+51
| | | | | | | | | | | | __dict__ slot for string subtypes. subtype_dealloc(): properly use _PyObject_GetDictPtr() to get the (potentially negative) dict offset. Don't copy things into local variables that are used only once. type_new(): properly calculate a negative dict offset when tp_itemsize is nonzero. The __dict__ attribute, if present, is now a calculated attribute rather than a structure member.
* More stuff discovered while writing the simplest of testcases:Guido van Rossum2001-08-301-2/+5
| | | | | | | tupledealloc(): only feed the free list when the type is really a tuple, not a subtype. Otherwise, use PyObject_GC_Del(). _PyTuple_Resize(): disallow using this for tuple subtypes.
* Ah, the joy of writing test cases...Guido van Rossum2001-08-301-1/+1
| | | | | long_subtype_new(): fix a typo (type->ob_size instead of tmp->ob_size).
* Removed some unreachable break statements to silence SGI compiler.Sjoerd Mullender2001-08-301-3/+0
|
* Give the internal immutable list type .extend and .pop methods (theyTim Peters2001-08-301-0/+2
| | | | "should have" been added here when they were added to lists).
* Safety measures now that str and tuple are subclassable:Guido van Rossum2001-08-301-1/+9
| | | | | | If tp_itemsize of the basetype is nonzero, only allow empty __slots__ (declaring that no __dict__ should be added), and don't add a weakref offset.
* Make 'super' subclassable. (Not sure how useful this is yet. :-)Guido van Rossum2001-08-301-1/+1
|
* Make unicode subclassable.Guido van Rossum2001-08-301-2/+32
|
* Make str and tuple types subclassable.Guido van Rossum2001-08-302-4/+54
|
* Make getset subclassable.Guido van Rossum2001-08-301-1/+1
|
* Fix typo: double semicolons.Guido van Rossum2001-08-302-2/+2
|
* Squash new compiler wng in debug build.Tim Peters2001-08-301-1/+1
|
* Use new GC API. Remove usage of BASICSIZE macros.Neil Schemenauer2001-08-291-18/+18
|
* Use new GC API.Neil Schemenauer2001-08-297-89/+66
|
* Remove GC related code. It lives in gcmodule now.Neil Schemenauer2001-08-291-26/+1
|
* Make frames a PyVarObject. Use new GC API.Neil Schemenauer2001-08-291-30/+14
|
* Make int, long and float subclassable.Guido van Rossum2001-08-293-14/+111
| | | | This uses a slightly wimpy and wasteful approach, but it works. :-)
* Fix super() so that it is usable for static methods (like __new__) as well.Guido van Rossum2001-08-291-8/+27
| | | | | In particular, the second argument can now be a subclass of the first as well (normally it must be an instance though).
* Fix a typo in SLOT0 macro for the declaration of cache_str.Guido van Rossum2001-08-281-1/+1
| | | | Dunno why I didn't catch this before.
* Finish the previous checkin: also avoid getattr when calling the methodGuido van Rossum2001-08-281-25/+93
| | | | directly.
* Change in policy: when a slot_tp_xxx function looks for the __xxx__ method,Guido van Rossum2001-08-281-15/+57
| | | | | | | | | don't use getattr, but only look in the dict of the type and base types. This prevents picking up all sorts of weird stuff, including things defined by the metaclass when the object is a class (type). For this purpose, a helper function lookup_method() was added. One or two other places also use this.
* Two improvements suggested by Greg Stein:Barry Warsaw2001-08-271-2/+5
| | | | | | | | | PyString_FromFormatV(): In the final resize at the end, we can use PyString_AS_STRING() since we know the object is a string and can avoid the typechecking. PyString_FromFormat(): GS sez: "For safety/propriety, you should call va_end() on the vargs variable."
* PyString_FromFormatV: Massage platform %p output to match what gcc does,Tim Peters2001-08-251-0/+8
| | | | | | | at least in the first two characters. %p is ill-defined, and people will forever commit bad tests otherwise ("bad" in the sense that they fall over (at least on Windows) for lack of a leading '0x'; 5 of the 7 tests in test_repr.py failed on Windows for that reason this time around).
* getset_init(): the function name in the PyArg_ParseTuple() formatGuido van Rossum2001-08-241-1/+1
| | | | should just be "getset", not "getset.__init__".
* Improve the error message issued when an unbound method is called withGuido van Rossum2001-08-241-3/+49
| | | | | | an inappropriate first argument. Now that there are more ways for this to fail, make sure to report the name of the class of the expected instance and of the actual instance.
* repr's converted to using PyString_FromFormat() instead of sprintf'ingBarry Warsaw2001-08-2411-136/+95
| | | | | | into a hardcoded char* buffer. Closes patch #454743.
* PyString_FromFormat() and PyString_FromFormatV(): Largely ripped fromBarry Warsaw2001-08-241-0/+155
| | | | | | | | | | | | | | | | | | | PyErr_Format() these new C API methods can be used instead of sprintf()'s into hardcoded char* buffers. This allows us to fix many situation where long package, module, or class names get truncated in reprs. PyString_FromFormat() is the varargs variety. PyString_FromFormatV() is the va_list variety Original PyErr_Format() code was modified to allow %p and %ld expansions. Many reprs were converted to this, checkins coming soo. Not changed: complex_repr(), float_repr(), float_print(), float_str(), int_repr(). There may be other candidates not yet converted. Closes patch #454743.
* Add 'super', another new object type with magical properties.Guido van Rossum2001-08-241-0/+155
| | | | | | | | | | | super(type) -> unbound super object super(type, obj) -> bound super object; requires isinstance(obj, type) Typical use to call a cooperative superclass method: class C(B): def meth(self, arg): super(C, self).meth(arg);
* Change the getset type to take an optional third function argument:Guido van Rossum2001-08-241-9/+21
| | | | | | the delete function. (Question: should the attribute name also be recorded in the getset object? That makes the protocol more work, but may give us better error messages.)
* getset_descr_set(): guard against deletion (indicated by a set callGuido van Rossum2001-08-241-1/+4
| | | | | with a NULL value), in a somewhat lame way: call the set() function with one argument. Should I add a 3rd function, 'del', instead?
* slot_tp_descr_get(): guard against NULL obj or type (bug reported byGuido van Rossum2001-08-241-2/+11
| | | | | | | Thomas Hellor on python-dev). slot_tp_descr_set(): if value is NULL, call __del__ instead of __set__.
* getset_init(): make the arguments optional.Guido van Rossum2001-08-241-3/+11
| | | | getset_doc: add docstring.