summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* mysnprintf.c: Massive rewrite of PyOS_snprintf and PyOS_vsnprintf, toTim Peters2001-12-031-5/+0
| | | | | | | | | | | | | | | use wrappers on all platforms, to make this as consistent as possible x- platform (in particular, make sure there's at least one \0 byte in the output buffer). Also document more of the truth about what these do. getargs.c, seterror(): Three computations of remaining buffer size were backwards, thus telling PyOS_snprintf the buffer is larger than it actually is. This matters a lot now that PyOS_snprintf ensures there's a trailing \0 byte (because it didn't get the truth about the buffer size, it was storing \0 beyond the true end of the buffer). sysmodule.c, mywrite(): Simplify, now that PyOS_vsnprintf guarantees to produce a \0 byte.
* PyFile_WriteString(): change prototype so that the string arg isTim Peters2001-11-281-1/+1
| | | | | | const char* instead of char*. The change is conceptually correct, and indirectly fixes a compiler wng introduced when somebody else innocently passed a const char* to this function.
* Removed preprocessor gimmick trying to force use of snprintf emulationTim Peters2001-11-281-8/+6
| | | | before 2.2b1.
* Fix SF bug [ #476852 ] Some bad macros in abstract.hJeremy Hylton2001-11-281-2/+2
| | | | Change macros as requested by Guido
* Bumping version number.Barry Warsaw2001-11-161-2/+2
|
* Add PyObject_CheckReadBuffer(), which returns true if its argumentJeremy Hylton2001-11-091-0/+9
| | | | | | supports the single-segment readable buffer interface. Add documentation for this and other PyObject_XXXBuffer() calls.
* Make the CoreFoundation object _New and _Convert routines available to other ↵Jack Jansen2001-11-051-0/+24
| | | | modules. Idea by Donovan Preston, implementaion by me.
* PyObject_CallFunctionObArgs() ---> PyObject_CallFunctionObjArgs()Fred Drake2001-10-281-4/+4
| | | | PyObject_CallMethodObArgs() ---> PyObject_CallMethodObjArgs()
* SF patch #475657 (Dietmar Schwertberger)Guido van Rossum2001-10-271-3/+4
| | | | | | | | | | | | RISCOS/Makefile: include structseq and weakrefobject; changes to keep command line length below 2048 RISCOS/Modules/riscosmodule.c: typos from the stat structseq patch Include/pyport.h: don't re-#define __attribute__(__x) on RISC OS as it is already defined in c library
* SF bug #475327: type() produces incorrect error msgTim Peters2001-10-271-0/+1
| | | | | | | | | | | | | object.h: Added PyType_CheckExact macro. typeobject.c, type_new(): + Use the new macro. + Assert that the arguments have the right types rather than do incomplete runtime checks "sometimes". + If this isn't the 1-argument flavor() of type, and there aren't 3 args total, produce a "types() takes 1 or 3 args" msg before PyArg_ParseTupleAndKeywords produces a "takes exactly 3" msg.
* Added two new functions to conveniently call functions/methods from C.Fred Drake2001-10-261-5/+23
| | | | | | | PyObject_CallFunctionObArgs() and PyObject_CallMethodObArgs() have the advantage that no format strings need to be parsed. The CallMethod variant also avoids creating a new string object in order to retrieve a method from an object as well.
* Generalize dictionary() to accept a sequence of 2-sequences. At theTim Peters2001-10-261-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | outer level, the iterator protocol is used for memory-efficiency (the outer sequence may be very large if fully materialized); at the inner level, PySequence_Fast() is used for time-efficiency (these should always be sequences of length 2). dictobject.c, new functions PyDict_{Merge,Update}FromSeq2. These are wholly analogous to PyDict_{Merge,Update}, but process a sequence-of-2- sequences argument instead of a mapping object. For now, I left these functions file static, so no corresponding doc changes. It's tempting to change dict.update() to allow a sequence-of-2-seqs argument too. Also changed the name of dictionary's keyword argument from "mapping" to "x". Got a better name? "mapping_or_sequence_of_pairs" isn't attractive, although more so than "mosop" <wink>. abstract.h, abstract.tex: Added new PySequence_Fast_GET_SIZE function, much faster than going thru the all-purpose PySequence_Size. libfuncs.tex: - Document dictionary(). - Fiddle tuple() and list() to admit that their argument is optional. - The long-winded repetitions of "a sequence, a container that supports iteration, or an iterator object" is getting to be a PITA. Many months ago I suggested factoring this out into "iterable object", where the definition of that could include being explicit about generators too (as is, I'm not sure a reader outside of PythonLabs could guess that "an iterator object" includes a generator call). - Please check my curly braces -- I'm going blind <0.9 wink>. abstract.c, PySequence_Tuple(): When PyObject_GetIter() fails, leave its error msg alone now (the msg it produces has improved since PySequence_Tuple was generalized to accept iterable objects, and PySequence_Tuple was also stomping on the msg in cases it shouldn't have even before PyObject_GetIter grew a better msg).
* SF patch #474590 -- RISC OS supportGuido van Rossum2001-10-241-0/+4
|
* Check for HP/UX curses problems. Define _XOPEN_SOURCE_EXTENDED andMartin v. Löwis2001-10-241-0/+11
| | | | | | STRICT_SYSV_CURSES when compiling curses module on HP/UX. Generalize access to _flags on systems where WINDOW is opaque. Fixes bugs #432497, #422265, and the curses parts of #467145 and #473150.
* Oops, undo previous change, which wasn't supposed to escape from myJack Jansen2001-10-241-1/+1
| | | | | machine. Luckily everyone is asleep, so I didn't have to use the time machine.
* Tweaks for MacPython 2.2b1Jack Jansen2001-10-231-1/+1
|
* PyArg_UnpackTuple(): New argument unpacking function suggested by JimFred Drake2001-10-231-0/+1
| | | | Fulton, based on code Jim supplied.
* Add function attributes that allow GCC to check the arguments of printf-likeNeil Schemenauer2001-10-234-9/+18
| | | | functions.
* Hide GCC attributes fom compilers that don't support them.Neil Schemenauer2001-10-231-0/+9
|
* Methods of built-in types now properly check for keyword argumentsGuido van Rossum2001-10-221-0/+7
| | | | | (formerly these were silently ignored). The only built-in methods that take keyword arguments are __call__, __init__ and __new__.
* Big internal change that should have no external effects: unify theGuido van Rossum2001-10-211-0/+3
| | | | | | | | | 'slotdef' structure typedef and 'struct wrapperbase'. By adding the wrapper docstrings to the slotdef structure, the slotdefs array can serve as the data structure that drives add_operators(); the wrapper descriptor contains a pointer to slotdef structure. This replaces lots of custom code from add_operators() by a loop over the slotdefs array, and does away with all the tab_xxx tables.
* Updated version numbers for post 2.2b1 development.Barry Warsaw2001-10-191-3/+3
|
* SF patch #470578: Fixes to synchronize unicode() and str()Guido van Rossum2001-10-191-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements what we have discussed on python-dev late in September: str(obj) and unicode(obj) should behave similar, while the old behaviour is retained for unicode(obj, encoding, errors). The patch also adds a new feature with which objects can provide unicode(obj) with input data: the __unicode__ method. Currently no new tp_unicode slot is implemented; this is left as option for the future. Note that PyUnicode_FromEncodedObject() no longer accepts Unicode objects as input. The API name already suggests that Unicode objects do not belong in the list of acceptable objects and the functionality was only needed because PyUnicode_FromEncodedObject() was being used directly by unicode(). The latter was changed in the discussed way: * unicode(obj) calls PyObject_Unicode() * unicode(obj, encoding, errors) calls PyUnicode_FromEncodedObject() One thing left open to discussion is whether to leave the PyUnicode_FromObject() API as a thin API extension on top of PyUnicode_FromEncodedObject() or to turn it into a (macro) alias for PyObject_Unicode() and deprecate it. Doing so would have some surprising consequences though, e.g. u"abc" + 123 would turn out as u"abc123"... [Marc-Andre didn't have time to check this in before the deadline. I hope this is OK, Marc-Andre! You can still make changes and commit them on the trunk after the branch has been made, but then please mail Barry a context diff if you want the change to be merged into the 2.2b1 release branch. GvR]
* SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.Guido van Rossum2001-10-181-0/+39
| | | | | | | | | | | | | | | | | This is a big one, touching lots of files. Some of the platforms aren't tested yet. Briefly, this changes the return value of the os/posix functions stat(), fstat(), statvfs(), fstatvfs(), and the time functions localtime(), gmtime(), and strptime() from tuples into pseudo-sequences. When accessed as a sequence, they behave exactly as before. But they also have attributes like st_mtime or tm_year. The stat return value, moreover, has a few platform-specific attributes that are not available through the sequence interface (because everybody expects the sequence to have a fixed length, these couldn't be added there). If your platform's struct stat doesn't define st_blksize, st_blocks or st_rdev, they won't be accessible from Python either. (Still missing is a documentation update.)
* Partial patch from SF #452266, by Jason Petrone.Guido van Rossum2001-10-161-1/+1
| | | | | | This changes Pythread_start_thread() to return the thread ID, or -1 for an error. (It's technically an incompatible API change, but I doubt anyone calls it.)
* Get rid of __defined__ and tp_defined -- there's no need toGuido van Rossum2001-10-151-1/+1
| | | | | distinguish __dict__ and __defined__ any more. In the C structure, tp_cache takes its place -- but this hasn't been implemented yet.
* Completely get rid of __dynamic__ and the correspondingGuido van Rossum2001-10-151-3/+0
| | | | | Py_TPFLAGS_DYNAMICTYPE bit. There is no longer a performance benefit, and I don't really see the use case any more.
* Use an assert() for the REQ() macro instead of making up our ownGuido van Rossum2001-10-151-10/+1
| | | | assertion.
* Very subtle syntax change: in a list comprehension, the testlist inGuido van Rossum2001-10-151-7/+8
| | | | | | | | | | | | | | | "for <var> in <testlist> may no longer be a single test followed by a comma. This solves SF bug #431886. Note that if the testlist contains more than one test, a trailing comma is still allowed, for maximum backward compatibility; but this example is not: [(x, y) for x in range(10), for y in range(10)] ^ The fix involved creating a new nonterminal 'testlist_safe' whose definition doesn't allow the trailing comma if there's only one test: testlist_safe: test [(',' test)+ [',']]
* Check for term.h and include it on non-ncurses system to get a declarationMartin v. Löwis2001-10-131-0/+4
| | | | for tigetstr.
* SF bug [#467145] Python 2.2a4 build problem on HPUX 11.0.Tim Peters2001-10-111-12/+15
| | | | | | | | | | | | | | The platform requires 8-byte alignment for doubles, but the GC header was 12 bytes and that threw off the natural alignment of the double members of a subtype of complex. The fix puts the GC header into a union with a double as the other member, to force no-looser-than double alignment of GC headers. On boxes that require 8-byte alignment for doubles, this may add pad bytes to the GC header accordingly; ditto for platforms that *prefer* 8-byte alignment for doubles. On platforms that don't care, it shouldn't change the memory layout (because the size of the old GC header is certainly greater than the size of a double on all platforms, so unioning with a double shouldn't change size or alignment on such boxes).
* Keep track of a type's subclasses (subtypes), in tp_subclasses, whichGuido van Rossum2001-10-081-0/+2
| | | | | | | | | | | | | | | | is a list of weak references to types (new-style classes). Make this accessible to Python as the function __subclasses__ which returns a list of types -- we don't want Python programmers to be able to manipulate the raw list. In order to make this possible, I also had to add weak reference support to type objects. This will eventually be used together with a trap on attribute assignment for dynamic classes for a major speed-up without losing the dynamic properties of types: when a __foo__ method is added to a class, the class and all its subclasses will get an appropriate tp_foo slot function.
* Guido suggests, and I agree, to insist that SIZEOF_VOID_P be a power of 2.Tim Peters2001-10-071-28/+24
| | | | | | This simplifies the rounding in _PyObject_VAR_SIZE, allows to restore the pre-rounding calling sequence, and allows some nice little simplifications in its callers. I'm still making it return a size_t, though.
* _PyObject_VAR_SIZE: always round up to a multiple-of-pointer-size value.Tim Peters2001-10-061-11/+35
| | | | | | | | | | | | | | | | | As Guido suggested, this makes the new subclassing code substantially simpler. But the mechanics of doing it w/ C macro semantics are a mess, and _PyObject_VAR_SIZE has a new calling sequence now. Question: The PyObject_NEW_VAR macro appears to be part of the public API. Regardless of what it expands to, the notion that it has to round up the memory it allocates is new, and extensions containing the old PyObject_NEW_VAR macro expansion (which was embedded in the PyObject_NEW_VAR expansion) won't do this rounding. But the rounding isn't actually *needed* except for new-style instances with dict pointers after a variable-length blob of embedded data. So my guess is that we do not need to bump the API version for this (as the rounding isn't needed for anything an extension can do unless it's recompiled anyway). What's your guess?
* Repaired the debug Windows deaths in test_descr, by allocating enoughTim Peters2001-10-061-1/+2
| | | | | | | | | | | | | | pad memory to properly align the __dict__ pointer in all cases. gcmodule.c/objimpl.h, _PyObject_GC_Malloc: + Added a "padding" argument so that this flavor of malloc can allocate enough bytes for alignment padding (it can't know this is needed, but its callers do). typeobject.c, PyType_GenericAlloc: + Allocated enough bytes to align the __dict__ pointer. + Sped and simplified the round-up-to-PTRSIZE logic. + Added blank lines so I could parse the if/else blocks <0.7 wink>.
* Remove bogus declaration.Fred Drake2001-10-051-2/+0
|
* PyObject_ClearWeakRefs() is now a real function instead of a function pointer;Fred Drake2001-10-051-1/+1
| | | | the implementation is in Objects/weakrefobject.c.
* Include the weakref object interface.Fred Drake2001-10-051-0/+1
|
* The weak reference implementation, separated from the weakref module.Fred Drake2001-10-051-0/+50
|
* weakref.ReferenceError becomes a built-in exception now that weak ref objectsFred Drake2001-10-051-0/+1
| | | | | are moving into the core; with these changes, it will be possible for the exception to be raised without the weakref module ever being imported.
* Introduced the oddly-missing PyList_CheckExact(), and used it to replaceTim Peters2001-10-051-0/+1
| | | | a hard-coded type check.
* *EXPERIMENTAL* speedup of slot_sq_item. This sped up the followingGuido van Rossum2001-10-031-0/+34
| | | | | | | | | | | | | | | | | | | | | | | test dramatically: class T(tuple): __dynamic__ = 1 t = T(range(1000)) for i in range(1000): tt = tuple(t) The speedup was about 5x compared to the previous state of CVS (1.7 vs. 8.8, in arbitrary time units). But it's still more than twice as slow as as the same test with __dynamic__ = 0 (0.8). I'm not sure that I really want to go through the trouble of this kind of speedup for every slot. Even doing it just for the most popular slots will be a major effort (the new slot_sq_item is 40+ lines, while the old one was one line with a powerful macro -- unfortunately the speedup comes from expanding the macro and doing things in a way specific to the slot signature). An alternative that I'm currently considering is sketched in PLAN.txt: trap setattr on type objects. But this will require keeping track of all derived types using weak references.
* Add Garbage Collection support to new-style classes (not yet to theirGuido van Rossum2001-10-022-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | instances). Also added GC support to various auxiliary types: super, property, descriptors, wrappers, dictproxy. (Only type objects have a tp_clear field; the other types are.) One change was necessary to the GC infrastructure. We have statically allocated type objects that don't have a GC header (and can't easily be given one) and heap-allocated type objects that do have a GC header. Giving these different metatypes would be really ugly: I tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new invent a new name for the new metatype and make it a built-in, change affected tests... In short, a mess. So instead, we add a new type slot tp_is_gc, which is a simple Boolean function that determines whether a particular instance has GC headers or not. This slot is only relevant for types that have the (new) GC flag bit set. If the tp_is_gc slot is NULL (by far the most common case), all instances of the type are deemed to have GC headers. This slot is called by the PyObject_IS_GC() macro (which is only used twice, both times in gcmodule.c). I also changed the extern declarations for a bunch of GC-related functions (_PyObject_GC_Del etc.): these always exist but objimpl.h only declared them when WITH_CYCLE_GC was defined, but I needed to be able to reference them without #ifdefs. (When WITH_CYCLE_GC is not defined, they do the same as their non-GC counterparts anyway.)
* SF patch [#466353] Py_HUGE_VAL on BeOS for Intel.Tim Peters2001-10-011-1/+5
| | | | | | The patch repaired internal gcc compiler errors on BeOS. This checkin repairs them in a simpler way, by explicitly casting the platform INFINITY to double.
* PY_RELEASE_SERIAL => 4Barry Warsaw2001-09-281-2/+2
| | | | PY_VERSION => "2.2a4+"
* Add optional docstrings to getset descriptors. Fortunately, there'sGuido van Rossum2001-09-202-5/+6
| | | | | | | | | | no backwards compatibility to worry about, so I just pushed the 'closure' struct member to the back -- it's never used in the current code base (I may eliminate it, but that's more work because the getter and setter signatures would have to change.) As examples, I added actual docstrings to the getset attributes of a few types: file.closed, xxsubtype.spamdict.state.
* Add optional docstrings to member descriptors. For backwardsGuido van Rossum2001-09-203-2/+18
| | | | | | | | | | | | | | | compatibility, this required all places where an array of "struct memberlist" structures was declared that is referenced from a type's tp_members slot to change the type of the structure to PyMemberDef; "struct memberlist" is now only used by old code that still calls PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef argument. As examples, I added actual docstrings to the attributes of a few types: file, complex, instance method, super, and xxsubtype.spamlist. Also converted the symtable to new style getattr.
* Patch #435971: UTF-7 codec by Brian Quinlan.Marc-André Lemburg2001-09-201-0/+18
|
* Fix for bug #462737.Marc-André Lemburg2001-09-191-3/+3
|
* Hopefully fix 3-way comparisons. This unfortunately adds yet anotherGuido van Rossum2001-09-181-0/+4
| | | | | | | | hack, and it's even more disgusting than a PyInstance_Check() call. If the tp_compare slot is the slot used for overrides in Python, it's always called. Add some tests that show what should work too.