Commit Graph

4374 Commits

Author SHA1 Message Date
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
Martin v. Löwis 961b91bd3c Correction of patch #1455898: In the mbcs decoder, set final=False
for stream decoder, but final=True for the decode function.
2006-08-02 13:53:55 +00:00
Neal Norwitz 9b0ca79213 Patch #1519025 and bug #926423: If a KeyboardInterrupt occurs during
a socket operation on a socket with a timeout, the exception will be
caught correctly.  Previously, the exception was not caught.
2006-08-02 06:46:21 +00:00
Neal Norwitz c0328d17a5 v is already checked for NULL, so just DECREF it 2006-08-02 06:15:10 +00:00
Neal Norwitz c5e060dee6 _PyWeakref_GetWeakrefCount() now returns a Py_ssize_t instead of long. 2006-08-02 06:14:22 +00:00
Neal Norwitz 99dfe3c411 Prevent memory leak on error.
Reported by Klocwork #36
2006-08-02 04:27:11 +00:00
Thomas Heller d61d0733cb Speed up PyType_stgdict and PyObject_stgdict. 2006-08-01 19:14:15 +00:00
Thomas Heller 11d68a6ac4 Minimal useful docstring for CopyComPointer. 2006-08-01 17:46:10 +00:00
Thomas Heller 3de83e9b61 Fix a potential segfault and various potentail refcount leaks
in the cast() function.
2006-08-01 16:54:43 +00:00
Neal Norwitz 07aadb14f3 Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().
This provides the proper warning for struct.pack().
PyErr_Warn() is now deprecated in favor of PyErr_WarnEx().
As mentioned by Tim Peters on python-dev.
2006-07-30 06:55:48 +00:00
Andrew M. Kuchling 8d9a01a1f2 Tweak wording 2006-07-29 15:43:13 +00:00
Thomas Heller 1393d6a4ca Patch #1529514: More openbsd platforms for ctypes.
Regenerated Modules/_ctypes/libffi/configure with autoconf 2.59.

Approved by Neal.
2006-07-28 21:43:20 +00:00
Thomas Heller 944f3b6ecb Remove a useless XXX comment.
Cosmetic changes to the code so that the #ifdef _UNICODE block
doesn't mess emacs code formatting.
2006-07-28 19:42:40 +00:00
Georg Brandl cddabbf98a Fix spelling. 2006-07-28 18:36:01 +00:00
Matt Fleming ec9265094a Allow socketmodule to compile on NetBSD -current, whose bluetooth API
differs from both Linux and FreeBSD. Accepted by Neal Norwitz.
2006-07-28 11:27:27 +00:00
Gregory P. Smith 641cddf0fa - pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
methods now allow their database parameter to be None as the
  sleepycat API allows.

Also adds an appropriate test case for DBEnv.dbrename and dbremove.
2006-07-28 01:35:25 +00:00
Tim Peters 5566e96830 defdict_reduce(): Plug leaks.
We didn't notice these before because test_defaultdict didn't
actually do anything before Georg fixed that earlier today.
Neal's next refleak run then showed test_defaultdict leaking
9 references on each run.  That's repaired by this checkin.
2006-07-28 00:23:15 +00:00
Barry Warsaw 00decd7835 Patch #1520294: Support for getset and member descriptors in types.py,
inspect.py, and pydoc.py.  Specifically, this allows for querying the type of
an object against these built-in C types and more importantly, for getting
their docstrings printed in the interactive interpreter's help() function.

This patch includes a new built-in module called _types which provides
definitions of getset and member descriptors for use by the types.py module.
These types are exposed as types.GetSetDescriptorType and
types.MemberDescriptorType.  Query functions are provided as
inspect.isgetsetdescriptor() and inspect.ismemberdescriptor().  The
implementations of these are robust enough to work with Python implementations
other than CPython, which may not have these fundamental types.

The patch also includes documentation and test suite updates.

I commit these changes now under these guiding principles:

1. Silence is assent.  The release manager has not said "no", and of the few
   people that cared enough to respond to the thread, the worst vote was "0".

2. It's easier to ask for forgiveness than permission.

3. It's so dang easy to revert stuff in svn, that you could view this as a
   forcing function. :)

Windows build patches will follow.
2006-07-27 23:43:15 +00:00
Neal Norwitz 37f694f21b No functional change. Add comment and assert to describe why there cannot be overflow which was reported by Klocwork. Discussed on python-dev 2006-07-27 04:04:50 +00:00
Andrew M. Kuchling a1da20472f Correct error message 2006-07-26 17:18:01 +00:00
Andrew M. Kuchling 55b0a0eb0d [Bug #1471938] Fix build problem on Solaris 8 by conditionalizing the use of mvwgetnstr(); it was conditionalized a few lines below. Fix from Paul Eggert. I also tried out the STRICT_SYSV_CURSES case and am therefore removing the 'untested' comment. 2006-07-26 17:16:52 +00:00
Georg Brandl 5f135787ec Part of bug #1523610: fix miscalculation of buffer length.
Also add a guard against NULL in converttuple and add a test case
(that previously would have crashed).
2006-07-26 08:03:10 +00:00
Martin v. Löwis 982e9fea0a Bug #1524310: Properly report errors from FindNextFile in os.listdir.
Will backport to 2.4.
2006-07-24 12:54:17 +00:00
Neal Norwitz dce937f32c Ensure we don't write beyond errText. I think I got this right, but
it definitely could use some review to ensure I'm not off by one
and there's no possible overflow/wrap-around of bytes_left.
Reported by Klocwork #1.

Fix a problem if there is a failure allocating self->db.
Found with failmalloc.
2006-07-23 08:01:43 +00:00
Neal Norwitz 9029b5f289 nextlink can be NULL if teedataobject_new fails, so use XINCREF.
Ensure that dataobj is never NULL.

Reported by Klocwork #102
2006-07-23 07:59:00 +00:00
Neal Norwitz 98a96004f9 Fix memory leaks spotted by Klocwork #37. 2006-07-23 07:57:11 +00:00
Neal Norwitz 93f2ca1f85 Check the allocation of b_objects and return if there was a failure.
Also fix a few memory leaks in other failure scenarios.

It seems that if b_objects == Py_None, we will have an extra ref to
b_objects.  Add XXX comment so hopefully someone documents why the
else isn't necessary or adds it in.

Reported by Klocwork #20
2006-07-23 07:55:55 +00:00
Neal Norwitz b59d08c2fb Fix more memory allocation issues found with failmalloc. 2006-07-22 16:20:49 +00:00
Brett Cannon 468e45edc1 Remove an XXX marker in a comment. 2006-07-21 22:44:07 +00:00
Thomas Heller 100a4e944b Make sure the _ctypes extension can be compiled when WITH_THREAD is
not defined on Windows, even if that configuration is probably not
supported at all.
2006-07-19 09:09:32 +00:00
Brett Cannon caebe22038 Fix bug #1520914. Starting in 2.4, time.strftime() began to check the bounds
of values in the time tuple passed in.  Unfortunately people came to rely on
undocumented behaviour of setting unneeded values to 0, regardless of if it was
within the valid range.  Now those values force the value internally to the
minimum value when 0 is passed in.
2006-07-18 04:41:36 +00:00
Neal Norwitz 5eaf772980 Fix memory leaks in some conditions.
Reported by Klocwork #152.
2006-07-16 02:15:27 +00:00
Neal Norwitz 109f91414f proto was dereffed above and is known to be good. No need for X.
Reported by Klocwork, #39.
2006-07-16 02:05:35 +00:00
Neal Norwitz ce5b3c3188 self is dereffed (and passed as first arg), so it's known to be good.
func is returned from PyArg_ParseTuple and also dereffed.

Reported by Klocwork, #30 (self one at least).
2006-07-16 02:02:57 +00:00
Thomas Heller ce049a0aef Patch #1521817: The index range checking on ctypes arrays containing
exactly one element is enabled again.
2006-07-14 17:51:14 +00:00
Thomas Heller 9f902470da Make the prototypes of our private PyUnicode_FromWideChar and
PyUnicode_AsWideChar replacement functions compatible to the official
functions by using Py_ssize_t instead of int.
2006-07-14 15:01:05 +00:00
Thomas Heller b4dc2ef5da A misspelled preprocessor symbol caused ctypes to be always compiled
without thread support.  Replaced WITH_THREADS with WITH_THREAD.
2006-07-13 09:53:47 +00:00
Georg Brandl 9dceedbb97 Accept long options "--help" and "--version". 2006-07-12 15:31:17 +00:00
Neal Norwitz 41efc14498 Fix function name in error msg 2006-07-12 05:26:35 +00:00
Thomas Heller 3b9be2ae6f Change the ctypes version number to 1.0.0. 2006-07-11 18:40:50 +00:00
Anthony Baxter 93ab5fa191 #1494314: Fix a regression with high-numbered sockets in 2.4.3. This
means that select() on sockets > FD_SETSIZE (typically 1024) work again.
The patch makes sockets use poll() internally where available.
2006-07-11 02:04:09 +00:00
Thomas Heller 7644262aa5 Assigning None to pointer type structure fields possible overwrote
wrong fields.
2006-07-10 11:11:10 +00:00
Thomas Heller 7b1da513fd Fixed a segfault when ctypes.wintypes were imported on
non-Windows machines.
2006-07-10 09:31:06 +00:00
Thomas Heller dda068dee1 Fix bug #1518190: accept any integer or long value in the
ctypes.c_void_p constructor.
2006-07-10 09:10:28 +00:00
Neal Norwitz 2a30cd0ef0 Patch #1516912: improve Modules support for OpenVMS. 2006-07-10 01:18:57 +00:00
Thomas Heller 5becdbee96 Patch #1517790: It is now possible to use custom objects in the ctypes
foreign function argtypes sequence as long as they provide a
from_param method, no longer is it required that the object is a
ctypes type.
2006-07-06 08:48:35 +00:00
Thomas Heller 43d9a58dfd Revert the change done in svn revision 47206:
Add a new function uses_seh() to the _ctypes extension module.  This
will return True if Windows Structured Exception handling (SEH) is
used when calling functions, False otherwise.
2006-07-06 07:50:18 +00:00
Fred Drake 24a0f41d83 - back out Expat change; the final fix to Expat will be different
- change the pyexpat wrapper to not be so sensitive to this detail of the
  Expat implementation (the ex-crasher test still passes)
2006-07-06 05:13:22 +00:00
Thomas Heller 9ba7ca8229 Fix the bitfield test when _ctypes is compiled with MingW. Structures
containing bitfields may have different layout on MSVC and MingW .
2006-07-05 09:13:56 +00:00
Ronald Oussoren b4a6a566ff Sync the darwin/x86 port libffi with the copy in PyObjC. This fixes a number
of bugs in that port. The most annoying ones were due to some subtle differences
between the document ABI and the actual implementation :-(

(there are no python unittests that fail without this patch, but without it
 some of libffi's unittests fail).
2006-07-04 12:30:22 +00:00
Kristján Valur Jónsson 74c3ea0a0f Fix build problems with the platform SDK on windows. It is not sufficient to test for the C compiler version when determining if we have the secure CRT from microsoft. Must test with an undocumented macro, __STDC_SECURE_LIB__ too. 2006-07-03 14:59:05 +00:00
Thomas Heller f780be4239 Add a new function uses_seh() to the _ctypes extension module. This
will return True if Windows Structured Exception handling (SEH) is
used when calling functions, False otherwise.

Currently, only MSVC supports SEH.

Fix the test so that it doesn't crash when run with MingW compiled
_ctypes.  Note that two tests are still failing when mingw is used, I
suspect structure layout differences and function calling conventions
between MSVC and MingW.
2006-07-03 08:08:14 +00:00