Commit Graph

771 Commits

Author SHA1 Message Date
Marc-André Lemburg 53f3d4ac74 [ Bug #116174 ] using %% in cstrings sometimes fails with unicode paramsFix for the bug reported in Bug #116174: "%% %s" % u"abc" failed due
to the way string formatting delegated work to the Unicode formatting
function.
2000-10-07 08:54:09 +00:00
Fred Drake db810ac2b8 Donn Cave <donn@oz.net>:
Fix large file support for BeOS.

This closes SourceForge patch #101773.  Refer to the patch discussion for
information on possible alternate fixes.
2000-10-06 20:42:33 +00:00
Tim Peters c54d19043a SF bug 115831 and Ping's SF patch 101751, 0.0**-2.0 returns inf rather than
raise ValueError.  Checked in the patch as far as it went, but also changed
all of ints, longs and floats to raise ZeroDivisionError instead when raising
0 to a negative number.  This is what 754-inspired stds require, as the "true
result" is an infinity obtained from finite operands, i.e. it's a singularity.
Also changed float pow to not be so timid about using its square-and-multiply
algorithm.  Note that what math.pow does is unrelated to what builtin pow
does, and will still vary by platform.
2000-10-06 00:36:09 +00:00
Neil Schemenauer 08b53e6a2a Simplify _PyTuple_Resize by not using the tuple free list and dropping
support for the last_is_sticky flag.  A few hard to find bugs may be
fixed by this patch since the old code was buggy.
2000-10-05 19:36:49 +00:00
Thomas Wouters dc9100f57d Fix for SF bug #115987: PyInstance_HalfBinOp does not initialize the
result-object-pointer that is passed in, when an exception occurs during
coercion. The pointer has to be explicitly initialized in the caller to avoid
putting trash on the Python stack.
2000-10-05 12:43:25 +00:00
Tim Peters d57731f74b Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
#define'd to an unreasonable value (several recent gcc systems have
misdefined it, causing bogus overflows in integer multiplication).  Nuke
CHAR_BIT entirely.
2000-10-05 01:42:25 +00:00
Neil Schemenauer e3550a65eb - fix a GC bug caused by malloc() failing 2000-10-04 16:20:41 +00:00
Barry Warsaw 5b4c22806f _PyUnicode_Fini(): Initialize the local freelist walking variable `u'
after unicode_empty has been freed, otherwise it might not point to
the real start of the unicode_freelist.  Final closure for SF bug
#110681, Jitterbug PR#398.
2000-10-03 20:45:26 +00:00
Guido van Rossum 4ae8ef84da In _PyUnicode_Fini(), decref unicode_empty before tearng down the free
list.  Discovered by Barry, fix approved by MAL.
2000-10-03 18:09:04 +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
Fredrik Lundh 375732cd41 - don't set the titlecase flag for uppercase letters (sorry, tim) 2000-09-25 23:03:34 +00:00
Fredrik Lundh 9e7dd4c185 unicode database compression, step 3:
- use unidb compression for the unicodectype module.  smaller, faster,
  and slightly more portable...
2000-09-25 21:48:13 +00:00
Fredrik Lundh 69b58e2772 unicode database compression, step 3:
- use unidb compression for the unicodectype module.  smaller, faster,
  and slightly more portable...

(note: this commit doesn't include the unicodectype.c file itself; I'm
still waiting for the reviewers...)
2000-09-25 21:12:34 +00:00
Tim Peters 858346e484 Replace SIGFPE paranoia around strtod and atof. I don't believe these
fncs are allowed to raise SIGFPE (see the C std), but OK by me if
people using --with-fpectl want to pay for checking anyway.
2000-09-25 21:01:28 +00:00
Tim Peters ef14d73b7a Fix for SF bug 110624: float literals behave inconsistently.
I fixed the specific complaint but left the (many) large issues untouched.
See the (very long) bug report discussion for why:
    http://sourceforge.net/bugs/?func=detailbug&group_id=5470&bug_id=110624
Note that while I left the interface to the undocumented public API function
PyFloat_FromString alone, its 2nd argument is useless.  From a comment block
in the code:

RED_FLAG 22-Sep-2000 tim
PyFloat_FromString's pend argument is braindead.  Prior to this RED_FLAG,

1.  If v was a regular string, *pend was set to point to its terminating
    null byte.  That's useless (the caller can find that without any
    help from this function!).

2.  If v was a Unicode string, or an object convertible to a character
    buffer, *pend was set to point into stack trash (the auto temp
    vector holding the character buffer).  That was downright dangerous.

Since we can't change the interface of a public API function, pend is
still supported but now *officially* useless:  if pend is not NULL,
*pend is set to NULL.
2000-09-23 03:39:17 +00:00
Guido van Rossum 1a5e5830a7 Untested patch by Ty Sarna to make TELL64 work on older NetBSD systems.
According to Justin Pettit, this also works on OpenBSD, so I've added
that symbol as well.
2000-09-21 22:15:29 +00:00
Guido van Rossum 1e3c8ccb9b As suggested by Toby Dickenson, setting ob_type to NULL in
_Py_Dealloc(), is a bad idea (and always was!).  So let's drop it.
2000-09-21 16:25:33 +00:00
Tim Peters 38fd5b6413 Derived from Martin's SF patch 110609: support unbounded ints in %d,i,u,x,X,o formats.
Note a curious extension to the std C rules:  x, X and o formatting can never produce
a sign character in C, so the '+' and ' ' flags are meaningless for them.  But
unbounded ints *can* produce a sign character under these conversions (no fixed-
width bitstring is wide enough to hold all negative values in 2's-comp form).  So
these flags become meaningful in Python when formatting a Python long which is too
big to fit in a C long.  This required shuffling around existing code, which hacked
x and X conversions to death when both the '#' and '0' flags were specified:  the
hacks weren't strong enough to deal with the simultaneous possibility of the ' ' or
'+' flags too, since signs were always meaningless before for x and X conversions.
Isomorphic shuffling was required in unicodeobject.c.
Also added dozens of non-trivial new unbounded-int test cases to test_format.py.
2000-09-21 05:43:11 +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 e44e507b0e PyObject_SetAttr() and PyObject_GetAttr() now also accept Unicode
objects for the attribute name. Unicode objects are converted to
a string using the default encoding before trying the lookup.

Note that previously it was allowed to pass arbitrary objects as
attribute name in case the tp_getattro/setattro slots were defined.
This patch fixes this by applying an explicit string check first:
all uses of these slots expect string objects and do not check
for the type resulting in a core dump. The tp_getattro/setattro
are still useful as optimization for lookups using interned
string objects though.

This patch fixes bug #113829.
2000-09-18 16:20:57 +00:00
Tim Peters 6b184918f6 Fix for SF bug 110688: Instance deallocation neglected to account for
that Py_INCREF boosts global _Py_RefTotal when Py_REF_DEBUG is defined
but Py_TRACE_REFS isn't.

There are, IMO, way too many preprocessor gimmicks in use for refcount
debugging (at least 3 distinct true/false symbols, but not all 8 combos
are supported by the code, etc etc), and no coherent documentation of
this stuff -- 'twas too painful to track this one down.
2000-09-17 14:40:17 +00:00
Tim Peters 78fc0b57df Fixed legit gripe from c.l.py that math.fmod docs aren't confusing enough.
FRED, please check my monkey-see-monkey-do Tex fiddling!
2000-09-16 03:54:24 +00:00
Neil Schemenauer ce20967c2c Don't remove instance objects from the GC container set until we are
they are dead.  Fixes bug #113812.
2000-09-15 18:57:21 +00:00
Martin v. Löwis 3cd760425f Correctly cast the return value of realloc. 2000-09-15 07:32:39 +00:00
Martin v. Löwis c58dbebf4b Correctly use realloc return value. Fixes bug #114424. 2000-09-15 07:07:46 +00:00
Tim Peters 8f422461b4 Fix for bug 113934. string*n and unicode*n did no overflow checking at
all, either to see whether the # of chars fit in an int, or that the
amount of memory needed fit in a size_t.  Checking these is expensive, but
the alternative is silently wrong answers (as in the bug report) or
core dumps (which were easy to provoke using Unicode strings).
2000-09-09 06:13:41 +00:00
Fredrik Lundh df84675f93 changed \x to consume exactly two hex digits, also for unicode
strings.  closes PEP-223.

also added \U escape (eight hex digits).
2000-09-03 11:29:49 +00:00
Thomas Wouters f2b332dc7e Cosmetic cleanup by Vladimir. 2000-09-02 08:34:40 +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 bb8be93a50 Rewritten some pieces of PyNumber_InPlaceAdd() for clarity. 2000-09-01 23:27:32 +00:00
Thomas Wouters cadd5b6b58 Fix grouping, again. This time properly :-) Sorry, guys. 2000-09-01 07:53:25 +00:00
Jeremy Hylton b709df3810 refactor __del__ exception handler into PyErr_WriteUnraisable
add sanity check to gc: if an exception occurs during GC, call
PyErr_WriteUnraisable and then call Py_FatalEror.
2000-09-01 02:47:25 +00:00
Guido van Rossum 04127de434 Add parens suggested by gcc -Wall. 2000-09-01 02:39:00 +00:00
Fred Drake 1bff34ab96 Slight performance hack that also avoids requiring the existence of thread
state for dictionaries that have only been indexed by string keys.

See the comments in SourceForge for more.

This closes SourceForge patch #101309.
2000-08-31 19:31:38 +00:00
Fred Drake c88b99ce06 Clear errors raised by PyObject_Compare() without losing any existing
exception context.  This avoids improperly propogating errors raised by
a user-defined __cmp__() by a subsequent lookup operation.

This patch does *not* include the performance enhancement patch for
dictionaries with string keys only; that will be checked in separately.

This closes SourceForge patch #101277 and bug #112558.
2000-08-31 19:04:07 +00:00
Thomas Wouters 6b958f7d7b Fix grouping: this is how I intended it, misguided as I was in boolean
operator associativity.
2000-08-31 07:02:19 +00:00
Fred Drake 8ce159aef5 Peter Schneider-Kamp <nowonder@nowonder.de>:
Remove some of GCC's warning in -Wstrict-prototypes mode.

This closes SourceForge patch #101342.
2000-08-31 05:18:54 +00:00
Fred Drake 562f62aa9b Removed compiler warning about wanting explicit grouping around &&
expression next to a || expression; this is a readability-inspired
warning from GCC.
2000-08-31 05:15:44 +00:00
Guido van Rossum 9c0a99ec1a PyOS_CheckStack() returns 1 when failing, not -1. 2000-08-30 15:53:50 +00:00
Marc-André Lemburg f5e96fa6b7 Fixed a serious typo. 2000-08-25 22:49:05 +00:00
Marc-André Lemburg 6ef68b5b01 Fix to bug [ Bug #111860 ] file.writelines() crashes.
file.writelines() now tries to emulate the behaviour of file.write()
as closely as possible. Due to the problems with releasing the
interpreter lock the solution isn't exactly optimal, but still better
than not supporting the file.write() semantics at all.
2000-08-25 22:39:50 +00:00
Thomas Wouters 1de2a79a48 Call PyErr_Clear() to clear the AttributeError raised by GetAttr. 2000-08-25 10:47:46 +00:00
Thomas Wouters e289e0bd0c Support for the in-place operations introduced by augmented assignment. Only
the list object supports this currently, but other candidates are
gladly accepted (like arraymodule and such.)
2000-08-24 20:08:19 +00:00
Thomas Wouters e266e42c9c Addendum to previous change: now that 'f' is not unconditionally
initialized in the 'if (..)', do so manually.
2000-08-23 23:31:34 +00:00
Thomas Wouters bf6cfa5f8e Add extra check on whether 'tp_as_number' is still non-NULL after coercion,
in the PyNumber_* functions. Also, remove unnecessary tests from
PyNumber_Multiply: after BINOP(), neither argument can be an instance.
2000-08-23 23:16:10 +00:00
Jack Jansen d49cbe1060 Added PyOS_CheckStack call to PyObject_Compare
Lowered the recursion limit on compares to 60 (one recursion depth can
take a whopping 2K of stack space when running test_b1!)
2000-08-22 21:52:51 +00:00
Jack Jansen e979160f5e Added include for limits.h 2000-08-22 21:51:22 +00:00
Barry Warsaw ce4dc41b1a PyUnicode_AsUTF8String(): /F picks up what I missed: the local var
`str' is no longer necessary.  Gotta turn on -Wall!
2000-08-18 19:30:40 +00:00
Barry Warsaw 2dd4abf277 PyUnicode_AsUTF8String(): Don't need to explicitly incref str since
PyUnicode_EncodeUTF8() already returns the created object with the
proper reference count.  This fixes an Insure reported memory leak.
2000-08-18 06:58:15 +00:00
Barry Warsaw 9d23a4eb03 make_pair(): When comparing the pointers, they must be cast to integer
types (i.e. Py_uintptr_t, our spelling of C9X's uintptr_t).  ANSI
specifies that pointer compares other than == and != to non-related
structures are undefined.  This quiets an Insure portability warning.
2000-08-18 05:01:19 +00:00