summaryrefslogtreecommitdiff
path: root/Python/bltinmodule.c
AgeCommit message (Collapse)AuthorLines
2002-04-08Add bool(), True, False (as ints) for backwards compatibility.Guido van Rossum-0/+23
2002-03-11backport tim_one's checkin ofMichael W. Hudson-5/+5
revision 2.248 of bltinmodule.c Docstring for filter(): Someone on the Tutor list reasonably complained that it didn't tell enough of the truth. Bugfix candidate (I guess -- it helps and it's harmless).
2002-01-12Include <unistd.h> in Python.h. Fixes #500924.Martin v. Löwis-4/+0
2001-12-13Fix for SF bug [ #492403 ] exec() segfaults on closure's func_codeJeremy Hylton-1/+1
Based on the patch from Danny Yoo. The fix is in exec_statement() in ceval.c. There are also changes to introduce use of PyCode_GetNumFree() in several places.
2001-11-28Use PyOS_snprintf instead of sprintf.Jeremy Hylton-1/+1
2001-11-05SF patch 473749 compile under OS/2 VA C++, from Michael Muller.Tim Peters-0/+4
Changes enabling Python to compile under OS/2 Visual Age C++.
2001-10-29Rename "dictionary" (type and constructor) to "dict".Tim Peters-1/+1
2001-10-24SF patch #474590 -- RISC OS supportGuido van Rossum-0/+15
2001-10-16SF patch #471852 (anonymous) notes that getattr(obj, name, default)Guido van Rossum-1/+3
masks any exception, not just AttributeError. Fix this.
2001-10-07Implement isinstance(x, (A, B, ...)). Note that we only allow tuples,Guido van Rossum-2/+4
not other sequences (then we'd have to except strings, and we'd still be susceptible to recursive attacks).
2001-09-13Get rid of builtin_open() entirely (the C code and docstring, not theTim Peters-20/+3
builtin function); Guido pointed out that it could be just another name in the __builtin__ dict for the file constructor now.
2001-09-13_PyBuiltin_Init(): For clarity, macroize this purely repetitive code.Tim Peters-49/+25
2001-09-13SF bug [#460467] file objects should be subclassable.Tim Peters-22/+13
Preliminary support. What's here works, but needs fine-tuning.
2001-09-06Rename 'getset' to 'property'.Guido van Rossum-2/+2
2001-09-05builtin_execfile(): initialize another local that the GCC on leroyGuido van Rossum-1/+1
found it necessary to warn about.
2001-09-04At Guido's suggestion, here's a new C API function, PyObject_Dir(), likeTim Peters-137/+1
__builtin__.dir(). Moved the guts from bltinmodule.c to object.c.
2001-09-04builtin_dir(): Treat classic classes like types. Use PyDict_Keys insteadTim Peters-17/+20
of PyMapping_Keys because we know we have a real dict. Tolerate that objects may have an attr named "__dict__" that's not a dict (Py_None popped up during testing). test_descr.py, test_dir(): Test the new classic-class behavior; beef up the new-style class test similarly. test_pyclbr.py, checkModule(): dir(C) is no longer a synonym for C.__dict__.keys() when C is a classic class (looks like the same thing that burned distutils! -- should it be *made* a synoym again? Then it would be inconsistent with new-style class behavior.).
2001-09-03Make dir() wordier (see the new docstring). The new behavior is a mixedTim Peters-53/+134
bag. It's clearly wrong for classic classes, at heart because a classic class doesn't have a __class__ attribute, and I'm unclear on whether that's feature or bug. I'll repair this once I find out (in the meantime, dir() applied to classic classes won't find the base classes, while dir() applied to a classic-class instance *will* find the base classes but not *their* base classes). Please give the new dir() a try and see whether you love it or hate it. The new dir([]) behavior is something I could come to love. Here's something to hate: >>> class C: ... pass ... >>> c = C() >>> dir(c) ['__doc__', '__module__'] >>> The idea that an instance has a __doc__ attribute is jarring (of course it's really c.__class__.__doc__ == C.__doc__; likewise for __module__). OTOH, the code already has too many special cases, and dir(x) doesn't have a compelling or clear purpose when x isn't a module.
2001-08-24Add 'super' builtin type.Guido van Rossum-0/+3
2001-08-23Add new built-in type 'getset' (PyGetSet_Type).Guido van Rossum-0/+3
This implements the 'getset' class from test_binop.py.
2001-08-17Fix for bug [#452230] future division isn't propagated.Tim Peters-1/+8
builtin_eval wasn't merging in the compiler flags from the current frame; I suppose we never noticed this before because future division is the first future-feature that can affect expressions (nested_scopes and generators had only statement-level effects).
2001-08-17A fiddled version of the rest of Michael Hudson's SF patchTim Peters-8/+26
#449043 supporting __future__ in simulated shells which implements PEP 264.
2001-08-17Patch #445762: Support --disable-unicodeMartin v. Löwis-0/+12
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
2001-08-16Patch #427190: Implement and use METH_NOARGS and METH_O.Martin v. Löwis-100/+59
2001-08-08Put conditional S_ISDIR definition(s) into pyport.h.Martin v. Löwis-1/+1
2001-08-08Repair the Windows build (S_ISDIR() macro doesn't exist).Tim Peters-1/+1
Somebody else should feel free to repair this a different way; see Python- Dev for discussion.
2001-08-08Patch #448227: Raise an exception when a directory is passed to execfile.Martin v. Löwis-4/+23
2001-08-02Merge of descr-branch back into trunk.Tim Peters-437/+38
2001-07-30Do for hasattr() what was done for getattr()Jeremy Hylton-0/+11
Namely, an exception is raised if the second arg to hasattr() is not a string or Unicode.
2001-07-30Fix for SF byg [ #420304 ] getattr function w/ defaultJeremy Hylton-0/+11
Fix suggested by Michael Hudson: Raise TypeError if attribute name passed to getattr() is not a string or Unicode. There is some unfortunate duplication of code between builtin_getattr() and PyObject_GetAttr(), but it appears to be unavoidable.
2001-07-30Fix for SF bug [ #443866 ] Evaluating func_code causing core dumpJeremy Hylton-1/+7
If the code object has free variables, raise TypeError.
2001-07-26Undoing the UCS-4 patch addition which caused unichr() to returnMarc-André Lemburg-1/+11
surrogates for Unicode code points outside range(0x10000) on narrow Python builds.
2001-07-16Part way to allowing "from __future__ import generators" to communicateTim Peters-8/+8
that info to code dynamically compiled *by* code compiled with generators enabled. Doesn't yet work because there's still no way to tell the parser that "yield" is OK (unlike nested_scopes, the parser has its fingers in this too). Replaced PyEval_GetNestedScopes by a more-general PyEval_MergeCompilerFlags. Perhaps I should not have? I doubted it was *intended* to be part of the public API, so just did.
2001-07-09Re-add 'advanced' xrange features, adding DeprecationWarnings as discussedThomas Wouters-1/+1
on python-dev. The features will still vanish, however, just one release later.
2001-07-05Complete the xrange-simplification checkins: call PyRange_New() withGuido van Rossum-1/+1
fewer arguments.
2001-06-27use Py_UNICODE_WIDE instead of USE_UCS4_STORAGE and Py_UNICODE_SIZEFredrik Lundh-1/+1
tests.
2001-06-26Cosmetic changes to MvL's change to unichr():Guido van Rossum-4/+6
- the correct range for the error message is range(0x110000); - put the 4-byte Unicode-size code inside the same else branch as the 2-byte code, rather generating unreachable code in the 2-byte case. - Don't hide the 'else' behine the '}'. (I would prefer that in 4-byte mode, any value should be accepted, but reasonable people can argue about that, so I'll put that off.)
2001-06-26Support using UCS-4 as the Py_UNICODE type:Martin v. Löwis-0/+4
Add configure option --enable-unicode. Add config.h macros Py_USING_UNICODE, PY_UNICODE_TYPE, Py_UNICODE_SIZE, SIZEOF_WCHAR_T. Define Py_UCS2. Encode and decode large UTF-8 characters into single Py_UNICODE values for wide Unicode types; likewise for UTF-16. Remove test whether sizeof Py_UNICODE is two.
2001-06-26more unicode tweaks: make unichr(0xdddddddd) behave like u"\Udddddddd"Fredrik Lundh-6/+17
wrt surrogates. (this extends the valid range from 65535 to 1114111)
2001-06-26experimental UCS-4 support: don't assume that MS_WIN32 impliesFredrik Lundh-1/+1
HAVE_USABLE_WCHAR_T
2001-05-28Cruft cleanup: Removed the unused last_is_sticky argument from the internalTim Peters-1/+1
_PyTuple_Resize().
2001-05-21SF bug #425836: Reference leak in filter().Tim Peters-0/+1
Mark Hammond claimed that the iterized filter() forgot to decref the iterator upon return. He was right!
2001-05-14Fix the Py_FileSystemDefaultEncoding checkin - declare the variable in a ↵Mark Hammond-1/+8
fileobject.h, and initialize it in bltinmodule.
2001-05-13Add support for Windows using "mbcs" as the default Unicode encoding when ↵Mark Hammond-2/+6
dealing with the file system. As discussed on python-dev and in patch 410465.
2001-05-06Generalize zip() to work with iterators.Tim Peters-18/+44
NEEDS DOC CHANGES. More AttributeErrors transmuted into TypeErrors, in test_b2.py, and, again, this strikes me as a good thing. This checkin completes the iterator generalization work that obviously needed to be done. Can anyone think of others that should be changed?
2001-05-05Make PyIter_Next() a little smarter (wrt its knowledge of iteratorTim Peters-47/+14
internals) so clients can be a lot dumber (wrt their knowledge).
2001-05-04Generalize reduce() to work with iterators.Tim Peters-12/+19
NEEDS DOC CHANGES.
2001-05-03Generalize map() to work with iterators.Tim Peters-66/+68
NEEDS DOC CHANGES. Possibly contentious: The first time s.next() yields StopIteration (for a given map argument s) is the last time map() *tries* s.next(). That is, if other sequence args are longer, s will never again contribute anything but None values to the result, even if trying s.next() again could yield another result. This is the same behavior map() used to have wrt IndexError, so it's the only way to be wholly backward-compatible. I'm not a fan of letting StopIteration mean "try again later" anyway.
2001-05-03Generalize max(seq) and min(seq) to work with iterators.Tim Peters-15/+24
NEEDS DOC CHANGES.
2001-05-02Generalize filter(f, seq) to work with iterators. This also generalizesTim Peters-40/+54
filter() to no longer insist that len(seq) be defined. NEEDS DOC CHANGES.