Commit Graph

4325 Commits

Author SHA1 Message Date
Thomas Heller 4378215474 Fix for #1643874: When calling SysAllocString, create a PyCObject
which will eventually call SysFreeString to free the BSTR resource.
2007-01-25 18:34:14 +00:00
Georg Brandl b84c13792d Bug #1486663: don't reject keyword arguments for subclasses of builtin
types.
2007-01-21 10:28:43 +00:00
Martin v. Löwis aef4c6bc00 Patch #1610575: Add support for _Bool to struct. 2007-01-21 09:33:07 +00:00
Thomas Heller 2e07810ef0 Replace C++ comments with C comments. 2007-01-17 09:40:34 +00:00
Guido van Rossum bb2cc698c1 Patch #1635058 by Mark Roberts: ensure that htonl and friends never accept or
return negative numbers, per the underlying C implementation.
2007-01-14 17:03:32 +00:00
Gerhard Häring 0741a60ca7 Merged changes from standalone version 2.3.3. This should probably all be
merged into the 2.5 maintenance branch:

- self->statement was not checked while fetching data, which could
  lead to crashes if you used the pysqlite API in unusual ways.
  Closing the cursor and continuing to fetch data was enough.

- Converters are stored in a converters dictionary. The converter name
  is uppercased first. The old upper-casing algorithm was wrong and
  was replaced by a simple call to the Python string's upper() method
  instead.

-Applied patch by Glyph Lefkowitz that fixes the problem with
 subsequent SQLITE_SCHEMA errors.

- Improvement to the row type: rows can now be iterated over and have a keys()
  method. This improves compatibility with both tuple and dict a lot.

- A bugfix for the subsecond resolution in timestamps.

- Corrected the way the flags PARSE_DECLTYPES and PARSE_COLNAMES are
  checked for. Now they work as documented.

- gcc on Linux sucks. It exports all symbols by default in shared
  libraries, so if symbols are not unique it can lead to problems with
  symbol lookup.  pysqlite used to crash under Apache when mod_cache
  was enabled because both modules had the symbol cache_init. I fixed
  this by applying the prefix pysqlite_ almost everywhere. Sigh.
2007-01-14 01:43:50 +00:00
Thomas Heller 8138c26a83 Fixes for 64-bit Windows: In ctypes.wintypes, correct the definitions
of HANDLE, WPARAM, LPARAM data types.  Make parameterless foreign
function calls work.
2007-01-11 21:18:56 +00:00
Thomas Heller 9ae562efb1 Must change the version number in the _ctypes extension as well. 2007-01-10 20:51:19 +00:00
Raymond Hettinger 51c2f6cd18 Fix zero-length corner case for iterating over a mutating deque. 2007-01-08 18:09:20 +00:00
Brett Cannon d14ef77ae1 Silence a warning from gcc 4.0.1 by specifying a function's parameter list is
'void' instead of just a set of empty parentheses.
2007-01-05 21:45:09 +00:00
Gregory P. Smith 11a70c3c96 bump module version to match supported berkeleydb version 2007-01-05 02:06:17 +00:00
Gregory P. Smith 8b96a35d14 Support linking of the bsddb module against BerkeleyDB 4.5.x
(will backport to 2.5)
2007-01-05 01:59:42 +00:00
Martin v. Löwis 7b7c9d4208 Bug #1566280: Explicitly invoke threading._shutdown from Py_Main,
to avoid relying on atexit.
Will backport to 2.5.
2007-01-04 21:06:12 +00:00
Walter Dörwald fd7e162eb9 Fix typo. 2006-12-21 18:06:30 +00:00
Andrew M. Kuchling 8d0baae7cd Comment typo 2006-12-19 14:29:04 +00:00
Andrew M. Kuchling 44b054b84a [Patch #1615868 by Lars Gustaebel] Use Py_off_t to fix BZ2File.seek() for offsets > 2Gb 2006-12-18 19:22:24 +00:00
Martin v. Löwis 046c4d13be Patch #1544279: Improve thread-safety of the socket module by moving
the sock_addr_t storage out of the socket object.
Will backport to 2.5.
2006-12-03 11:23:45 +00:00
Thomas Heller ef583a4992 Fix #1563807: _ctypes built on AIX fails with ld ffi error.
The contents of ffi_darwin.c must be compiled unless __APPLE__ is
defined and __ppc__ is not.

Will backport.
2006-11-28 20:21:54 +00:00
Thomas Heller 25d208bd46 Fix bug #1598620: A ctypes structure cannot contain itself. 2006-11-24 18:45:39 +00:00
Neal Norwitz 4fe442383d Bug #1599782: Fix segfault on bsddb.db.DB().type().
The problem is that _DB_get_type() can't be called without the GIL
because it calls a bunch of PyErr_* APIs when an error occurs.
There were no other cases in this file that it was called without the GIL.
Removing the BEGIN/END THREAD around _DB_get_type() made everything work.

Will backport.
2006-11-21 05:26:22 +00:00
Neal Norwitz 45e230a8e1 Speed up function calls into the math module by using METH_O.
There should be no functional changes. However, the error msgs are
slightly different.  Also verified that the module dict is not NULL on init.
2006-11-19 21:26:53 +00:00
Martin v. Löwis cffcc8b195 Make cStringIO.truncate raise IOError for negative
arguments (even for -1). Fixes the last bit of
#1359365.
2006-11-19 10:41:41 +00:00
Georg Brandl 25aabf4cbb Bug #1588217: don't parse "= " as a soft line break in binascii's
a2b_qp() function, instead leave it in the string as quopri.decode()
does.
2006-11-16 17:08:45 +00:00
Walter Dörwald 6fc2382883 Replace C++ comment with C comment (fixes SF bug #1593525). 2006-11-09 16:23:26 +00:00
Neal Norwitz 97a57220e8 Fix crash in test on HP-UX. Apparently, it's not possible to delete a lock if
it's held (even by the current thread).

Will backport.
2006-10-28 21:17:51 +00:00
Neal Norwitz 837ce9389e Add some asserts. In sysmodule, I think these were to try to silence
some warnings from Klokwork.  They verify the assumptions of the format
of svn version output.

The assert in the thread module helped debug a problem on HP-UX.
2006-10-28 21:15:30 +00:00
Martin v. Löwis 0347a9a491 Get DBL_MAX from float.h not values.h. Will backport. 2006-10-27 07:06:52 +00:00
Martin v. Löwis 443ccc73f3 Check for values.h. Will backport. 2006-10-27 06:42:27 +00:00
Martin v. Löwis b5bc537c5e Patch #1549049: Rewrite type conversion in structmember.
Fixes #1545696 and #1566140. Will backport to 2.5.
2006-10-27 06:16:31 +00:00
Martin v. Löwis 1b2f627f96 - Patch #1560695: Add .note.GNU-stack to ctypes' sysv.S so that
ctypes isn't considered as requiring executable stacks.
Will backport to 2.5.
2006-10-22 10:55:15 +00:00
Ronald Oussoren 10168f25ad Patch #1580674: with this patch os.readlink uses the filesystem encoding to
decode unicode objects and returns an unicode object when the argument is one.
2006-10-22 10:45:18 +00:00
Martin v. Löwis a811c38d8e Fix various minor errors in passing arguments to
PyArg_ParseTuple.
2006-10-19 11:00:37 +00:00
Tim Peters 79665b1403 newIobject(): repaired incorrect cast to quiet MSVC warning. 2006-10-18 05:06:06 +00:00
Thomas Heller d2ea4a2584 ctypes callback functions only support 'fundamental' result types.
Check this and raise an error when something else is used - before
this change ctypes would hang or crash when such a callback was
called.  This is a partial fix for #1574584.

Will backport to release25-maint.
2006-10-17 19:30:48 +00:00
Martin v. Löwis 012bc7253b Bug #1567666: Emulate GetFileAttributesExA for Win95.
Will backport to 2.5.
2006-10-15 09:43:39 +00:00
Martin v. Löwis 18aaa568fd Patch #1576166: Support os.utime for directories on Windows NT+. 2006-10-15 08:43:33 +00:00
Georg Brandl 5597e261b2 Bug #1548891: The cStringIO.StringIO() constructor now encodes unicode
arguments with the system default encoding just like the write()
method does, instead of converting it to a raw buffer.
2006-10-12 09:47:12 +00:00
Martin v. Löwis f43893a878 Bug #1565150: Fix subsecond processing for os.utime on Windows. 2006-10-09 20:44:25 +00:00
Barry Warsaw e5ec613c4b List gc.get_count() in the module docstring. 2006-10-09 19:43:24 +00:00
Hye-Shik Chang b788346573 Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault
when encoding non-BMP unicode characters.  (Submitted by Ray Chason)
2006-10-08 13:48:34 +00:00
Andrew M. Kuchling 36126c424a Cause a PyObject_Malloc() failure to trigger a MemoryError, and then
add 'if (PyErr_Occurred())' checks to various places so that NULL is
returned properly.

2.4 backport candidate.
2006-10-04 13:42:43 +00:00
Armin Rigo 7ccbca93a2 Forward-port of r52136,52138: a review of overflow-detecting code.
* unified the way intobject, longobject and mystrtoul handle
  values around -sys.maxint-1.

* in general, trying to entierely avoid overflows in any computation
  involving signed ints or longs is extremely involved.  Fixed a few
  simple cases where a compiler might be too clever (but that's all
  guesswork).

* more overflow checks against bad data in marshal.c.

* 2.5 specific: fixed a number of places that were still confusing int
  and Py_ssize_t.  Some of them could potentially have caused
  "real-world" breakage.

* list.pop(x): fixing overflow issues on x was messy.  I just reverted
  to PyArg_ParseTuple("n"), which does the right thing.  (An obscure
  test was trying to give a Decimal to list.pop()... doesn't make
  sense any more IMHO)

* trying to write a few tests...
2006-10-04 12:17:45 +00:00
Armin Rigo 0d2f498a4c Compilation problem caused by conflicting typedefs for uint32_t
(unsigned long vs. unsigned int).
2006-10-04 10:23:57 +00:00
Georg Brandl 4ddfcd3b60 Bug #1556784: allow format strings longer than 127 characters in
datetime's strftime function.
2006-09-30 11:17:34 +00:00
Neal Norwitz d3f91908dd Remove extra semi-colons reported by Johnny Lee on python-dev. Backport if anyone cares. 2006-09-23 04:11:38 +00:00
Jack Diederich 36234e8f66 * regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_t
which breaks negative counts
* added test for negative numbers
will backport to 2.5.1
2006-09-21 17:50:26 +00:00
Gregory P. Smith 2fa067982c Fixes a bug with bsddb.DB.stat where the flags and txn keyword
arguments are transposed.  (reported by Louis Zechtzer)
..already committed to release24-maint
..needs committing to release25-maint
2006-09-19 17:35:04 +00:00
Martin v. Löwis 43fd99c8f8 Patch #1557515: Add RLIMIT_SBSIZE. 2006-09-16 17:36:37 +00:00
Andrew M. Kuchling e2782bb379 Rewrite help message to remove some of the parentheticals. (There were a lot of them.) 2006-09-14 11:28:50 +00:00
Andrew M. Kuchling 8964688274 Make --help mention that -v can be supplied multiple times 2006-09-14 11:22:18 +00:00
Thomas Heller 2244af596a The cast function did not accept c_char_p or c_wchar_p instances
as first argument, and failed with a 'bad argument to internal function'
error message.
2006-09-07 19:09:54 +00:00
Thomas Heller fdb62f0e5f Anonymous structure fields that have a bit-width specified did not work,
and they gave a strange error message from PyArg_ParseTuple:
    function takes exactly 2 arguments (3 given).

With tests.
2006-09-07 18:56:28 +00:00
Andrew M. Kuchling 62e475b84f [Bug #1552726] Avoid repeatedly polling in interactive mode -- only put a timeout on the select()
if an input hook has been defined.  Patch by Richard Boulton.

This select() code is only executed with readline 2.1, or if
READLINE_CALLBACKS is defined.

Backport candidate for 2.5, 2.4, probably earlier versions too.
2006-09-07 13:59:38 +00:00
Georg Brandl 74bb783c2f Bug #1551427: fix a wrong NULL pointer check in the win32 version
of os.urandom().
2006-09-06 06:03:59 +00:00
Hye-Shik Chang 199f1db1fa Fix a few bugs on cjkcodecs found by Oren Tirosh:
- gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly.
- iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312
  codepoints to conform the standard.
- iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2
  codepoints now.
2006-09-05 12:07:09 +00:00
Neal Norwitz 69e8897505 Bug #1550714: fix SystemError from itertools.tee on negative value for n.
Needs backport to 2.5.1 and earlier.
2006-09-02 02:58:13 +00:00
Neal Norwitz 6aefa916a9 Bug #1548092: fix curses.tparm seg fault on invalid input. Needs backport to 2.5.1 and earlier. 2006-09-02 02:50:35 +00:00
Thomas Heller b1a7d758e2 Add missing file for _ctypes.pyd port to win64 on AMD64. 2006-08-25 07:34:51 +00:00
Thomas Heller 98619f267c Port _ctypes.pyd to win64 on AMD64. 2006-08-25 07:27:33 +00:00
Thomas Wouters 9e398cac94 Fix SF bug #1545837: array.array borks on deepcopy.
array.__deepcopy__() needs to take an argument, even if it doesn't actually
use it. Will backport to 2.5 and 2.4 (if applicable.)
2006-08-24 18:40:20 +00:00
Jeremy Hylton 60e96f666c Expose column offset information in parse trees. 2006-08-22 20:46:00 +00:00
Neal Norwitz 670f875a7c Alexander Belopolsky pointed out that pos is a size_t 2006-08-22 13:56:56 +00:00
Neal Norwitz 076d1e0c0b Fix a couple of ssize-t issues reported by Alexander Belopolsky on python-dev 2006-08-21 18:20:10 +00:00
Neal Norwitz 9b17eba8be Move assert to after NULL check, otherwise we deref NULL in the assert.
Klocwork #307
2006-08-19 04:23:04 +00:00
Thomas Heller 0b21b43d49 Add asserts to check for 'impossible' NULL values, with comments.
In one place where I'n not 1000% sure about the non-NULL, raise
a RuntimeError for safety.

This should fix the klocwork issues that Neal sent me.  If so,
it should be applied to the release25-maint branch also.
2006-08-18 14:38:46 +00:00
Fredrik Lundh dc075b9ddd SF#1534630
ignore data that arrives before the opening start tag
2006-08-16 16:47:07 +00:00
Thomas Heller b4a0cf17c4 Remove the special casing of Py_None when converting the return value
of the Python part of a callback function to C.  If it cannot be
converted, call PyErr_WriteUnraisable with the exception we got.
Before, arbitrary data has been passed to the calling C code in this
case.

(I'm not really sure the NEWS entry is understandable, but I cannot
find better words)
2006-08-16 15:10:12 +00:00
Thomas Heller b0aa98fd4f The __repr__ method of a NULL py_object does no longer raise an
exception.  Remove a stray '?' character from the exception text
when the value is retrieved of such an object.

Includes tests.
2006-08-16 14:07:44 +00:00
Thomas Heller d32e616722 Add commented assert statements to check that the result of
PyObject_stgdict() and PyType_stgdict() calls are non-NULL before
dereferencing the result.  Hopefully this fixes what klocwork is
complaining about.

Fix a few other nits as well.
2006-08-16 13:03:11 +00:00
Thomas Heller 4dc5dd1f3b Check for NULL return value from new_CArgObject calls. 2006-08-15 13:07:21 +00:00
Georg Brandl 9dc7b7ce82 Patch #1511317: don't crash on invalid hostname info 2006-08-14 22:10:24 +00:00
Georg Brandl 3335a7ad63 Patch #1535500: fix segfault in BZ2File.writelines and make sure it
raises the correct exceptions.
2006-08-14 21:42:55 +00:00
Thomas Heller ef8d513d62 Patch #1536908: Add support for AMD64 / OpenBSD.
Remove the -no-stack-protector compiler flag for OpenBSD
as it has been reported to be unneeded.
2006-08-14 16:17:41 +00:00
Thomas Heller 867200483b Apply the patch #1532975 plus ideas from the patch #1533481.
ctypes instances no longer have the internal and undocumented
'_as_parameter_' attribute which was used to adapt them to foreign
function calls; this mechanism is replaced by a function pointer in
the type's stgdict.

In the 'from_param' class methods, try the _as_parameter_ attribute if
other conversions are not possible.

This makes the documented _as_parameter_ mechanism work as intended.

Change the ctypes version number to 1.0.1.
2006-08-14 11:17:48 +00:00
Thomas Heller e6dd31c50b Revert the change that tries to zero out a closure's result storage
area because the size if unknown in source/callproc.c.
2006-08-14 10:02:24 +00:00
Thomas Heller dca703fbda Check for NULL return value of GenericCData_new().
Fixes klockwork issues #188, #189.
2006-08-14 07:50:14 +00:00
Thomas Heller efa2727334 Check for NULL return value from new_CArgObject().
Fixes klockwork issues #183, #184, #185.
2006-08-14 07:14:09 +00:00
Thomas Heller acdedfbf0a Remove unused, buggy test function.
Fixes klockwork issue #207.
2006-08-14 07:13:05 +00:00
Neal Norwitz 5ed4997e1f Get rid of compiler warning 2006-08-13 18:41:15 +00:00
Neal Norwitz 93bf902242 Handle alloca failures.
Klocwork 225-228
2006-08-13 18:40:39 +00:00
Neal Norwitz ccc56c7c96 Really address the issue of where to place the assert for leftblock.
(Followup of Klocwork 274)
2006-08-13 18:13:02 +00:00
Neal Norwitz 20745b1a70 Handle failure from PyModule_GetDict() (Klocwork 208).
Fix a bunch of refleaks in the init of the module.  This would only be found
when running python -v.
2006-08-13 18:12:45 +00:00
Neal Norwitz 26a8abf1f4 Handle failures from lookup.
Klocwork 341-342
2006-08-13 18:12:26 +00:00
Neal Norwitz ee7c8f9af8 It's very unlikely, though possible that source is not a string. Verify
that PyString_AsString() returns a valid pointer.  (The problem can
arise when zlib.decompress doesn't return a string.)

Klocwork 346
2006-08-13 18:12:03 +00:00
Neal Norwitz 5aa96895d8 Handle malloc and fopen failures more gracefully.
Klocwork 180-181
2006-08-13 18:11:43 +00:00
Neal Norwitz e9ac0bb169 Check return result of PyModule_GetDict().
Fix a bunch of refleaks in the init of the module.  This would only be found
when running python -v.
2006-08-13 18:11:27 +00:00
Neal Norwitz 8a87f5d37e Patch #1538606, Patch to fix __index__() clipping.
I modified this patch some by fixing style, some error checking, and adding
XXX comments.  This patch requires review and some changes are to be expected.
I'm checking in now to get the greatest possible review and establish a
baseline for moving forward.  I don't want this to hold up release if possible.
2006-08-12 17:03:09 +00:00
Neal Norwitz ebcf8759bb Verify verdat which is returned from malloc is not NULL.
Ensure we don't pass NULL to free.

Klocwork #306 (at least the first part, checking malloc)
2006-08-12 03:18:50 +00:00
Neal Norwitz 5f17d9a1df Don't deref v if it's NULL.
Klocwork #214
2006-08-12 02:33:36 +00:00
Neal Norwitz 6b4953fd3d Check returned pointer is valid.
Klocwork #233
2006-08-12 02:06:34 +00:00
Neal Norwitz b45f351832 I'm not sure why this code allocates this string for the error message.
I think it would be better to always use snprintf and have the format
limit the size of the name appropriately (like %.200s).

Klocwork #340
2006-08-12 01:57:47 +00:00
Neal Norwitz ef0de023db Try to handle a malloc failure. I'm not entirely sure this is correct.
There might be something else we need to do to handle the exception.

Klocwork # 212-213
2006-08-12 01:53:28 +00:00
Neal Norwitz 9cd3c34b6a Move the assert which checks for a NULL pointer first.
Klocwork #274.
2006-08-12 01:51:12 +00:00
Neal Norwitz e0a81afb10 If _stat_float_times is false, we will try to INCREF ival which could be NULL.
Return early in that case.  The caller checks for PyErr_Occurred so this
should be ok.

Klocwork #297
2006-08-12 01:50:38 +00:00
Neal Norwitz 6f5ff3f3eb Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context.

This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
2006-08-12 01:43:40 +00:00
Thomas Heller 2a899c8b76 When a ctypes C callback function is called, zero out the result
storage before converting the result to C data.  See the comment in
the code for details.

Provide a better context for errors when the conversion of a callback
function's result cannot be converted.
2006-08-11 19:55:35 +00:00
Martin v. Löwis 789c09d2cd Update dangling references to the 3.2 database to
mention that this is UCD 4.1 now.
2006-08-10 19:04:00 +00:00
Georg Brandl 534fe18e17 Bug #1535081: A leading underscore has been added to the names of
the md5 and sha modules, so add it in Modules/Setup.dist too.
2006-08-06 07:26:21 +00:00
Bob Ippolito e6c9f982a0 Fix #1530559, struct.pack raises TypeError where it used to convert.
Passing float arguments to struct.pack when integers are expected
now triggers a DeprecationWarning.
2006-08-04 23:59:21 +00:00
Georg Brandl e9462c72bd Change fix for segfaulting property(), add a NEWS entry and a test. 2006-08-04 18:03:37 +00:00