Commit Graph

2431 Commits

Author SHA1 Message Date
Martin v. Löwis 83687c98dc Change more occurrences of maxsplit to Py_ssize_t. 2006-04-13 08:52:56 +00:00
Martin v. Löwis 9c83076b7b Change maxsplit types to Py_ssize_t. 2006-04-13 08:37:17 +00:00
Martin v. Löwis b1ed7fac12 Replace INT_MAX with PY_SSIZE_T_MAX. 2006-04-13 07:52:27 +00:00
Martin v. Löwis 2a19074a9c Replace INT_MAX with PY_SSIZE_T_MAX where string length
are concerned.
2006-04-13 07:37:25 +00:00
Martin v. Löwis f15da6995b Remove another INT_MAX limitation 2006-04-13 07:24:50 +00:00
Martin v. Löwis 8ce358f5fe Replace most INT_MAX with PY_SSIZE_T_MAX. 2006-04-13 07:22:51 +00:00
Martin v. Löwis 412fb67368 Change more ints to Py_ssize_t. 2006-04-13 06:34:32 +00:00
Martin v. Löwis 80d2e591d5 Revert 34153: Py_UNICODE should not be signed. 2006-04-13 06:06:08 +00:00
Anthony Baxter ac6bd46d5c spread the extern "C" { } magic pixie dust around. Python itself builds now
using a C++ compiler. Still lots and lots of errors in the modules built by
setup.py, and a bunch of warnings from g++ in the core.
2006-04-13 02:06:09 +00:00
Anthony Baxter 3109d62da6 Add a cast to make code compile with a C++ compiler. 2006-04-13 01:07:27 +00:00
Phillip J. Eby 8920bf24f8 Don't set gi_frame to Py_None, use NULL instead, eliminating some insane
pointer dereferences.
2006-04-12 19:07:15 +00:00
Armin Rigo e170937af6 Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
2006-04-12 17:06:05 +00:00
Neal Norwitz 017749c33d wrap docstrings so they are less than 80 columns. add spaces after commas. 2006-04-12 06:56:56 +00:00
Tim Peters a5a80cb4a4 gen_throw(): The caller doesn't own PyArg_ParseTuple()
"O" arguments, so must not decref them.  This accounts
for why running test_contextlib.test_main() in a loop
eventually tried to deallocate Py_None.
2006-04-12 06:44:36 +00:00
Thomas Wouters 9cb28bea04 Fix int() and long() to repr() their argument when formatting the exception,
to avoid confusing situations like:

>>> int("")
ValueError: invalid literal for int():
>>> int("2\n\n2")
ValueError: invalid literal for int(): 2

2

Also report the base used, to avoid:

ValueError: invalid literal for int(): 2

They now report:

>>> int("")
ValueError: invalid literal for int() with base 10: ''
>>> int("2\n\n2")
ValueError: invalid literal for int() with base 10: '2\n\n2'
>>> int("2", 2)
ValueError: invalid literal for int() with base 2: '2'

(Reporting the base could be avoided when base is 10, which is the default,
but hrm.) Another effect of these changes is that the errormessage can be
longer; before, it was cut off at about 250 characters. Now, it can be up to
four times as long, as the unrepr'ed string is cut off at 200 characters,
instead.

No tests were added or changed, since testing for exact errormsgs is (pardon
the pun) somewhat errorprone, and I consider not testing the exact text
preferable. The actually changed code is tested frequent enough in the
test_builtin test as it is (120 runs for each of ints and longs.)
2006-04-11 23:50:33 +00:00
Tim Peters cbd6f1896d _Py_PrintReferenceAddresses,_Py_PrintReferences:
interpolate PY_FORMAT_SIZE_T for refcount display
instead of casting refcounts to long.

I understand that gcc on some boxes delivers
nuisance warnings about this, but if any new ones
appear because of this they'll get fixed by magic
when the others get fixed.
2006-04-11 19:12:33 +00:00
Martin v. Löwis ee36d650bb Correct casts to char*. 2006-04-11 09:08:02 +00:00
Martin v. Löwis 72d206776d Remove "static forward" declaration. Move constructors
after the type objects.
2006-04-11 09:04:12 +00:00
Neal Norwitz 9b26122ec0 Get compiling again 2006-04-11 07:58:54 +00:00
Anthony Baxter a62862120d More low-hanging fruit. Still need to re-arrange some code (or find a better
solution) in the same way as listobject.c got changed. Hoping for a better
solution.
2006-04-11 07:42:36 +00:00
Anthony Baxter 377be11ee1 More C++-compliance. Note especially listobject.c - to get C++ to accept the
PyTypeObject structures, I had to make prototypes for the functions, and
move the structure definition ahead of the functions. I'd dearly like a better
way to do this - to change this would make for a massive set of changes to
the codebase.

There's still some warnings - this is purely to get rid of errors first.
2006-04-11 06:54:30 +00:00
Martin v. Löwis 0bc2ab9a20 Patch #837242: id() for large ptr should return a long. 2006-04-10 20:28:17 +00:00
Phillip J. Eby 2ba96610bf SF Patch #1463867: Improved generator finalization to allow generators
that are suspended outside of any try/except/finally blocks to be
garbage collected even if they are part of a cycle.  Generators that
suspend inside of an active try/except or try/finally block (including
those created by a ``with`` statement) are still not GC-able if they
are part of a cycle, however.
2006-04-10 17:51:05 +00:00
Neal Norwitz 7e957d38b7 Remove dead code (reported by HP compiler).
Can probably be backported if anyone cares.
2006-04-06 08:17:41 +00:00
Martin v. Löwis c48c8db110 Add PY_SSIZE_T_MIN, as suggested by Ralf W. Grosse-Kunstleve. 2006-04-05 18:21:17 +00:00
Thomas Wouters f4d8f39053 Make xrange more Py_ssize_t aware, by assuming a Py_ssize_t is always at
least as big as a long. I believe this to be a safe assumption that is being
made in many parts of CPython, but a check could be added.

len(xrange(sys.maxint)) works now, so fix the testsuite's odd exception for
64-bit platforms too. It also fixes 'zip(xrange(sys.maxint), it)' as a
portable-ish (if expensive) alternative to enumerate(it); since zip() now
calls len(), this was breaking on (real) 64-bit platforms. No additional
test was added for that behaviour.
2006-04-04 17:28:12 +00:00
Martin v. Löwis 54b42f185e Allow long integers in PySlice_GetIndices. 2006-04-03 11:38:08 +00:00
Neal Norwitz d08eaf4d1b Use Py_ssize_t in slices 2006-04-03 04:46:04 +00:00
Georg Brandl ed02eb6aa9 Bug #1177964: make file iterator raise MemoryError on too big files 2006-03-31 20:31:02 +00:00
Barry Warsaw 176014ffad SF patch #1458476 with modifications based on discussions in python-dev. This
adds the following API calls: PySet_Clear(), _PySet_Next(), and
_PySet_Update().  The latter two are considered non-public.  Tests and
documentation (for the public API) are included.
2006-03-30 22:45:35 +00:00
Armin Rigo 314861c568 Minor bugs in the __index__ code (PEP 357), with tests. 2006-03-30 14:04:02 +00:00
Georg Brandl ecdc0a9f46 That one was a mistake. 2006-03-30 12:19:07 +00:00
Georg Brandl 347b30042b Remove unnecessary casts in type object initializers. 2006-03-30 11:57:00 +00:00
Anthony Baxter 262c00a21e Fixed bug #1459029 - unicode reprs were double-escaped.
Backed out an old patch from 2000.
2006-03-30 10:53:17 +00:00
Armin Rigo 12bec1b985 fix a comment. 2006-03-28 19:27:56 +00:00
Raymond Hettinger 334b5b20f2 Tighten an overbroad and misleading assertion.
(Reported by Jim Jewett.)
2006-03-26 03:11:29 +00:00
Neal Norwitz 7fbd6916b6 Get rid of warnings on some platforms by using %u for a size_t. 2006-03-25 23:55:39 +00:00
Phillip J. Eby bee0712214 Support throw() of string exceptions. 2006-03-25 00:05:50 +00:00
Neal Norwitz badc086543 Stop duplicating code and handle slice indices consistently and correctly
wrt to ssize_t.
2006-03-23 06:03:08 +00:00
Tim Peters 8af92d1f6c Heh -- used the right format for a refcount, but forgot
to stop truncating it.
2006-03-23 05:41:24 +00:00
Tim Peters 4d073bb9a1 _Py_NegativeRefcount(): print the full value of ob_refcnt. 2006-03-23 05:38:33 +00:00
Neal Norwitz 29892cc386 Update function name to reflect params and stop casting to long to avoid losing data 2006-03-20 01:55:26 +00:00
Neal Norwitz 2aa9a5dfdd Use macro versions instead of function versions when we already know the type.
This will hopefully get rid of some Coverity warnings, be a hint to
developers, and be marginally faster.

Some asserts were added when the type is currently known, but depends
on values from another function.
2006-03-20 01:53:23 +00:00
Georg Brandl abd1ff8f1f Previously, Python code had no easy way to access the contents of a
cell object. Now, a ``cell_contents`` attribute has been added
(closes patch #1170323).
2006-03-18 07:59:59 +00:00
Georg Brandl 5c170fd4a9 Fix some missing checks after PyTuple_New, PyList_New, PyDict_New 2006-03-17 19:03:25 +00:00
Tim Peters ae1d0c978d Introduced symbol PY_FORMAT_SIZE_T. See the new comments
in pyport.h.  Changed PyString_FromFormatV() to use it
instead of inlining its own maze of #if'ery.
2006-03-17 03:29:34 +00:00
Tim Peters cf79aace07 Merge the tim-obmalloc branch to the trunk.
This is a heavily altered derivative of SF patch 1123430, Evan
Jones's heroic effort to make obmalloc return unused arenas to
the system free(), with some heuristic strategies to make it
more likley that arenas eventually _can_ be freed.
2006-03-16 01:14:46 +00:00
Neal Norwitz 7580146b5c Fix and test (manually w/xx module) passing NULLs to PyObject_Str() and
PyObject_Unicode().  This problem was originally reported from Coverity
and addresses mail on python-dev "checkin r43015".

This inlines the conversion of the string to unicode and cleans
up/simplifies some code at the end of the PyObject_Unicode().

We really need a complete C API test module for all public APIs
and passing good and bad parameter values.

Will backport.
2006-03-14 06:02:16 +00:00
Georg Brandl 3daf75878d Fix bug found by Coverity: don't allow NULL argument to PyUnicode_CheckExact 2006-03-13 22:22:11 +00:00
Thomas Wouters a96affe1fc - Reindent a confusingly indented piece of code (no intended code changes
there)
 - Add missing DECREFs of inner-scope 'temp' variable
 - Add various missing DECREFs by changing 'return NULL' into 'goto onError'
 - Avoid double DECREF when last _PyUnicode_Resize() fails

Coverity found one of the missing DECREFs, but oddly enough not the others.
2006-03-12 00:29:36 +00:00