summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* Make isinstance() more permissive in what types of arguments itNeil Schemenauer2000-12-041-17/+9
| | | | | accepts. Clarify exception messages for isinstance() and issubclass(). Closes bug #124106.
* Ka-Ping Yee <ping@lfw.org>:Fred Drake2000-10-241-26/+26
| | | | | | Changes to error messages to increase consistency & clarity. This (mostly) closes SourceForge patch #101839.
* Rationalize use of limits.h, moving the inclusion to Python.h.Fred Drake2000-09-261-3/+0
| | | | | | | | Add definitions of INT_MAX and LONG_MAX to pyport.h. Remove includes of limits.h and conditional definitions of INT_MAX and LONG_MAX elsewhere. This closes SourceForge patch #101659 and bug #115323.
* This patch adds a new Python C API called PyString_AsStringAndSize()Marc-André Lemburg2000-09-191-6/+3
| | | | | | | | | | | | | which implements the automatic conversion from Unicode to a string object using the default encoding. The new API is then put to use to have eval() and exec accept Unicode objects as code parameter. This closes bugs #110924 and #113890. As side-effect, the traditional C APIs PyString_Size() and PyString_AsString() will also accept Unicode objects as parameters.
* Deferred the attribute name object type checking to the underlyingMarc-André Lemburg2000-09-181-4/+4
| | | | | | PyObject_Set/GetAttr() calls. This patch fixes bug #113829.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),Guido van Rossum2000-08-271-4/+1
| | | | | | | | | | | | | | PyRun_FileEx(). These are the same as their non-Ex counterparts but have an extra argument, a flag telling them to close the file when done. Then this is used by Py_Main() and execfile() to close the file after it is parsed but before it is executed. Adding APIs seems strange given the feature freeze but it's the only way I see to close the bug report without incompatible changes. [ Bug #110616 ] source file stays open after parsing is done (PR#209)
* comples_from_string(): Move s_buffer[] up to the top-level functionBarry Warsaw2000-08-181-2/+1
| | | | | | scope. Previously, s_buffer[] was defined inside the PyUnicode_Check() scope, but referred to in the outer scope via assignment to s. This quiets an Insure portability warning.
* Clean up a couple of warnings on Win64. The downcast of the strlen size_tTrent Mick2000-08-121-1/+1
| | | | | return value to int is safe here because in each case it previouls checked that there will be no overflow.
* Both PEP 201 Lockstep Iteration and SF patch #101030 have beenBarry Warsaw2000-08-031-0/+56
| | | | | | | | | | | accepted by the BDFL. builtin_zip(): New function to implement the zip() function described in the above proposal. zip_doc[]: Docstring for zip(). builtin_methods[]: added entry for zip()
* merge Include/my*.h into Include/pyport.hPeter Schneider-Kamp2000-07-311-2/+0
| | | | marked my*.h as obsolete
* Another missed ansification.Thomas Wouters2000-07-231-4/+1
|
* Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters2000-07-221-179/+60
| | | | declarations yet, those come later.
* replace PyXXX_Length calls with PyXXX_Size callsJeremy Hylton2000-07-121-1/+1
|
* Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters2000-07-091-4/+4
|
* Get rid of unused vars in builtin_unicode (they were causingTim Peters2000-07-091-2/+0
| | | | legit warnings).
* Fixed unicode() to use the new API PyUnicode_FromEncodedObject().Marc-André Lemburg2000-07-071-14/+1
| | | | | | | This adds support for instance to the constructor (instances have to define __str__ and can return Unicode objects via that hook; string return values are decoded into Unicode using the current default encoding).
* Include limits.h if we have it.Jack Jansen2000-07-031-0/+3
|
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Trent Mick:Guido van Rossum2000-06-281-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | Various small fixes to the builtin module to ensure no buffer overflows. - chunk #1: Proper casting to ensure no truncation, and hence no surprises, in the comparison. - chunk #2: The id() function guarantees a unique return value for different objects. It does this by returning the pointer to the object. By returning a PyInt, on Win64 (sizeof(long) < sizeof(void*)) the pointer is truncated and the guarantee may be proven false. The appropriate return function is PyLong_FromVoidPtr, this returns a PyLong if that is necessary to return the pointer without truncation. [GvR: note that this means that id() can now return a long on Win32 platforms. This *might* break some code...] - chunk #3: Ensure no overflow in raw_input(). Granted the user would have to pass in >2GB of data but it *is* a possible buffer overflow condition.
* Christopher Fandrich <cfandrich@8cs.com>:Fred Drake2000-06-201-3/+6
| | | | Fix memory leak in initializing __debug__.
* All the exception building related stuff has been moved out of thisBarry Warsaw2000-05-251-190/+1
| | | | | | | | | | | | module and into _exceptions.c. This includes all the PyExc_* globals, the bltin_exc table, init_class_exc(), fini_instances(), finierrors(). Renamed _PyBuiltin_Init_1() to _PyBuiltin_Init() since the two phase initializations are necessary any more. Removed as obsolete _PyBuiltin_Init_2(), _PyBuiltin_Fini_1() and _PyBuiltin_Fini_2().
* bltin_exc: Removed the leaf_exc flag in the structure, which was onlyBarry Warsaw2000-05-251-35/+29
| | | | used to build the fallback string-based exception.
* M.-A. Lemburg <mal@lemburg.com>:Fred Drake2000-05-091-2/+2
| | | | | Fixed docs according to the new behaviour (the Unicode encoding is no longer fixed to UTF-8).
* Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum2000-05-031-1/+1
| | | | | | | | | | 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.)
* A bit of cleanup:Guido van Rossum2000-05-031-34/+5
| | | | | | | | | - When 'import exceptions' fails, don't suggest to use -v to print the traceback; this doesn't actually work. - Remove comment about fallback to string exceptions. - Remove a PyErr_Occurred() check after all is said and done that can never trigger. - Remove static function newstdexception() which is no longer called.
* _PyBuiltin_Init_2(): Remove the misleading comment.Barry Warsaw2000-05-021-1/+0
|
* initerrors(): Remove this function. String-based standard exceptionsBarry Warsaw2000-05-021-96/+4
| | | | | | | | | | | | | are no longer supported (i.e. -X option is removed). _PyBuiltin_Init_1(): Don't call initerrors(). This does mean that it is possible to raise an ImportError before that exception has been initialized, say because exceptions.py can't be found, or contains bogosity. See changes to errors.c for how this is handled. _PyBuiltin_Init_2(): Don't test Py_UseClassExceptionsFlag, just go ahead and initialize the class-based standard exceptions. If this fails, we throw a Py_FatalError.
* When refering to Unicode characters in exception messages andFred Drake2000-04-131-5/+5
| | | | | docstrings, the documentation guidelines call for "Unicode", not "unicode". Comply.
* ord: provide better error messagesJeremy Hylton2000-04-121-8/+19
|
* Marc-Andre Lemburg:Guido van Rossum2000-04-111-4/+17
| | | | | | | Added special case to unicode(): when being passed a Unicode object as first argument, return the object as-is. Raises an exception when given a Unicode object *and* an encoding name.
* Marc-Andre's third try at this bulk patch seems to work (except thatGuido van Rossum2000-04-051-8/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Marc-Andre Lemburg: added new builtin functions unicode() andGuido van Rossum2000-03-101-5/+78
| | | | | unichr(); changed ord() to support Unicode strings; added new exception UnicodeError; fixed a typo in doc string for buffer().
* Massive patch by Skip Montanaro to add ":name" to as manyGuido van Rossum2000-02-291-5/+5
| | | | PyArg_ParseTuple() format string arguments as possible.
* Changes by Mark Hammond related to the new WindowsError exception.Guido van Rossum2000-02-171-0/+6
|
* Adjusted apply() docstring based on comments from Gerrit HollFred Drake1999-12-231-3/+4
| | | | <gerrit.holl@pobox.com>.
* Mainlining the string_methods branch. See branch revision logBarry Warsaw1999-10-121-42/+67
| | | | messages for specific changes.
* Fixed order of parameters in slice() docstring. The Library ReferenceFred Drake1999-07-191-1/+1
| | | | had it right! Reported by Tim Hochberg <tim.hochberg@ieee.org>.
* Patch by Tim Peters:Guido van Rossum1999-06-221-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new builtin exception, UnboundLocalError, raised when ceval.c tries to retrieve or delete a local name that isn't bound to a value. Currently raises NameError, which makes this behavior a FAQ since the same error is raised for "missing" global names too: when the user has a global of the same name as the unbound local, NameError makes no sense to them. Even in the absence of shadowing, knowing whether a bogus name is local or global is a real aid to quick understanding. Example: D:\src\PCbuild>type local.py x = 42 def f(): print x x = 13 return x f() D:\src\PCbuild>python local.py Traceback (innermost last): File "local.py", line 8, in ? f() File "local.py", line 4, in f print x UnboundLocalError: x D:\src\PCbuild> Note that UnboundLocalError is a subclass of NameError, for compatibility with existing class-exception code that may be trying to catch this as a NameError. Unfortunately, I see no way to make this wholly compatible with -X (see comments in bltinmodule.c): under -X, [UnboundLocalError is an alias for NameError --GvR]. [The ceval.c patch differs slightly from the second version that Tim submitted; I decided not to raise UnboundLocalError for DELETE_NAME, only for DELETE_LOCAL. DELETE_NAME is only generated at the module level, and since at that level a NameError is raised for referencing an undefined name, it should also be raised for deleting one.]
* # Darn! Local variable l declared but not used in abstract_issubclass().Guido van Rossum1999-06-171-1/+1
|
* Patch by Jim Fulton (code style tweaked a bit) to supportGuido van Rossum1999-06-161-17/+94
| | | | | | | | | | | | | | | | ExtensionClasses in isinstance() and issubclass(). - abstract instance and class protocols are used *only* in those cases that would generate errors before the patch. That is, there's no penalty for the normal case. - instance protocol: an object smells like an instance if it has a __class__ attribute that smells like a class. - class protocol: an object smells like a class if it has a __bases__ attribute that is a tuple with elements that smell like classes (although not all elements may actually get sniffed ;).
* Remove unused variable from complex_from_string() code.Guido van Rossum1999-04-071-1/+1
|
* Patch by Nick and Stephanie Lockwood to implement complex() with a stringGuido van Rossum1999-03-251-4/+133
| | | | argument. This closes TODO item 2.19.
* New builtin buffer() creates a derived read-only buffer from anyGuido van Rossum1999-03-191-0/+24
| | | | object that supports the buffer interface (e.g. strings, arrays).
* (initerrors): Make sure that the exception tuples ("base-classes" whenBarry Warsaw1999-02-241-8/+18
| | | | | string-based exceptions are used) reflect the real class hierarchy, i.e. that SystemExit derives from Exception not StandardError.
* Patch by Tim Peters to improve the range checks for range() andGuido van Rossum1999-02-231-30/+48
| | | | | | | xrange(), especially for platforms where int and long are different sizes (so sys.maxint isn't actually the theoretical limit for the length of a list, but the largest C int is -- sys.maxint is the largest Python int, which is actually a C long).
* bltin_exc[]: EnvironmentError is not a "leaf exception", so set it'sBarry Warsaw1999-01-291-1/+1
| | | | leaf_exc flag to zero otherwise the name leaks memory.
* builtin_map(): A better fix for the previous leak plug (rememberBarry Warsaw1999-01-281-3/+6
| | | | | | PyList_Append steals a reference even if it fails). builtin_filter(): Had the same leak problem as builtin_map().
* builtin_map(): Nailed memory leak. PyList_Append() borrows aBarry Warsaw1999-01-281-0/+1
| | | | | reference, so you have to DECREF the appended value. This was a fun one!