Commit Graph

195 Commits

Author SHA1 Message Date
Marc-André Lemburg 6f77667a64 Backed out the unistr() builtin. 2001-01-19 21:36:19 +00:00
Jeremy Hylton c862cf400f clearer error messages for apply() and "no locals" 2001-01-19 03:25:05 +00:00
Guido van Rossum 8dabbf149e Fix for the bug in complex() just reported by Ping. 2001-01-19 02:11:59 +00:00
Marc-André Lemburg ad7c98e264 This patch adds a new builtin unistr() which behaves like str()
except that it always returns Unicode objects.

A new C API PyObject_Unicode() is also provided.

This closes patch #101664.

Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-17 17:09:53 +00:00
Guido van Rossum 53451b3fd1 Use rich comparisons in min and max. 2001-01-17 15:47:24 +00:00
Fred Drake f1fbc62a8c Update the docstring for apply() so that "args" is marked as optional
(since it is).
2001-01-12 17:05:05 +00:00
Guido van Rossum ad991775ab (Modified) patch by Ping - SF Patch #102681.
- Make error messages from issubclass() and isinstance() a bit more
  descriptive (Ping, modified by Guido)

- Couple of tiny fixes to other docstrings (Ping)

- Get rid of trailing whitespace (Guido)
2001-01-12 16:03:05 +00:00
Neil Schemenauer 23ab199bfd Add NotImplemented to the builtin module. 2001-01-04 01:48:42 +00:00
Andrew M. Kuchling f07aad171a CHange error messages for ord(), using "string" instead of "string or Unicode" 2000-12-23 14:11:28 +00:00
Andrew M. Kuchling 9bcc68c183 Whoops! Two stray characters crept in to my last check-in 2000-12-20 15:07:34 +00:00
Andrew M. Kuchling 34c20cf705 Patch #102955, fixing one of the warnings in bug #121479:
Simplifies ord()'s logic at the cost of some code duplication, removing a
    " `ord' might be used uninitialized in this function" warning
2000-12-20 14:36:56 +00:00
Neil Schemenauer cc343caf41 Make isinstance() more permissive in what types of arguments it
accepts. Clarify exception messages for isinstance() and
issubclass().  Closes bug #124106.
2000-12-04 15:42:11 +00:00
Fred Drake 661ea26b3d Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity.

This (mostly) closes SourceForge patch #101839.
2000-10-24 19:57:45 +00:00
Fred Drake d5fadf75e4 Rationalize use of limits.h, moving the inclusion to Python.h.
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.
2000-09-26 05:46:01 +00:00
Marc-André Lemburg d1ba443206 This patch adds a new Python C API called PyString_AsStringAndSize()
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.
2000-09-19 21:04:18 +00:00
Marc-André Lemburg 691270feee Deferred the attribute name object type checking to the underlying
PyObject_Set/GetAttr() calls.

This patch fixes bug #113829.
2000-09-18 16:22:27 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Guido van Rossum 0df002c45b Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),
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)
2000-08-27 19:21:52 +00:00
Barry Warsaw 5ca1ef9238 comples_from_string(): Move s_buffer[] up to the top-level function
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.
2000-08-18 05:02:16 +00:00
Trent Mick 29b83810bd Clean up a couple of warnings on Win64. The downcast of the strlen size_t
return value to int is safe here because in each case it previouls checked that
there will be no overflow.
2000-08-12 21:35:36 +00:00
Barry Warsaw bd599b5928 Both PEP 201 Lockstep Iteration and SF patch #101030 have been
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()
2000-08-03 15:45:29 +00:00
Peter Schneider-Kamp 7e01890986 merge Include/my*.h into Include/pyport.h
marked my*.h as obsolete
2000-07-31 15:28:04 +00:00
Thomas Wouters e28c296f0f Another missed ansification. 2000-07-23 22:21:32 +00:00
Thomas Wouters f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Jeremy Hylton 03657cfdb0 replace PyXXX_Length calls with PyXXX_Size calls 2000-07-12 13:05:33 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Tim Peters 4be47c0f76 Get rid of unused vars in builtin_unicode (they were causing
legit warnings).
2000-07-09 02:11:18 +00:00
Marc-André Lemburg 1b1bcc9935 Fixed unicode() to use the new API PyUnicode_FromEncodedObject().
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).
2000-07-07 13:48:25 +00:00
Jack Jansen 41aa8e523d Include limits.h if we have it. 2000-07-03 21:39:47 +00:00
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
Guido van Rossum 106f2dae86 Trent Mick:
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.
2000-06-28 21:12:25 +00:00
Fred Drake 5550de3084 Christopher Fandrich <cfandrich@8cs.com>:
Fix memory leak in initializing __debug__.
2000-06-20 04:54:19 +00:00
Barry Warsaw 78e6c671db All the exception building related stuff has been moved out of this
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().
2000-05-25 23:15:05 +00:00
Barry Warsaw 1226588e57 bltin_exc: Removed the leaf_exc flag in the structure, which was only
used to build the fallback string-based exception.
2000-05-25 03:18:53 +00:00
Fred Drake c640b18d96 M.-A. Lemburg <mal@lemburg.com>:
Fixed docs according to the new behaviour (the Unicode
encoding is no longer fixed to UTF-8).
2000-05-09 19:55:16 +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 a7cfca23e1 A bit of cleanup:
- 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.
2000-05-03 22:03:46 +00:00
Barry Warsaw 48719d3d1f _PyBuiltin_Init_2(): Remove the misleading comment. 2000-05-02 19:24:39 +00:00
Barry Warsaw 47eeb9bdad initerrors(): Remove this function. String-based standard exceptions
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.
2000-05-02 19:24:06 +00:00
Fred Drake 078b24f000 When refering to Unicode characters in exception messages and
docstrings, the documentation guidelines call for "Unicode", not
"unicode".  Comply.
2000-04-13 02:42:50 +00:00
Jeremy Hylton 394b54d01a ord: provide better error messages 2000-04-12 21:19:47 +00:00
Guido van Rossum 3afba7644b Marc-Andre Lemburg:
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.
2000-04-11 15:38:23 +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 09095f3f61 Marc-Andre Lemburg: added new builtin functions unicode() and
unichr(); changed ord() to support Unicode strings; added new
exception UnicodeError; fixed a typo in doc string for buffer().
2000-03-10 23:00:52 +00:00
Guido van Rossum 43713e5a28 Massive patch by Skip Montanaro to add ":name" to as many
PyArg_ParseTuple() format string arguments as possible.
2000-02-29 13:59:29 +00:00
Guido van Rossum 65a75b0d52 Changes by Mark Hammond related to the new WindowsError exception. 2000-02-17 15:18:10 +00:00
Fred Drake 7b912120ca Adjusted apply() docstring based on comments from Gerrit Holl
<gerrit.holl@pobox.com>.
1999-12-23 14:16:55 +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
Fred Drake 3d587442f9 Fixed order of parameters in slice() docstring. The Library Reference
had it right!  Reported by Tim Hochberg <tim.hochberg@ieee.org>.
1999-07-19 15:21:16 +00:00