Commit Graph

4342 Commits

Author SHA1 Message Date
Walter Dörwald 0ac60611fe Backport checkin:
Fix a segfault when b"" was passed to b2a_qp() -- it was using strchr()
instead of memchr().
2007-05-09 18:13:53 +00:00
Neal Norwitz 6ca6f1472c Backport r55070: Stop using PyMem_FREE while the GIL is not held. 2007-05-09 06:45:53 +00:00
Kristján Valur Jónsson a1392d5ace Merge change 54982 from the trunk. This fixes the test_subprocess test in the testsuite for VisualStudio2005 builds, by "sanitizing" the "mode" that is used in the posixmodule's fdopen(). In particular the non-standard "U" mode character is removed. 2007-05-07 19:25:38 +00:00
Kristján Valur Jónsson f4601d874f Fix two problems that emerged when the testsuite was run with an x64 build: PyLong_FromSSize_t incorrectly assumed an unsigned object, and itertools.count() had the wrong upper limit for the iterator. 2007-05-07 18:30:48 +00:00
Thomas Heller 412b20bd31 Merged revisions 55027 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Modules/_ctypes

........
  r55027 | thomas.heller | 2007-04-30 18:04:57 +0200 (Mo, 30 Apr 2007) | 8 lines

  When accessing the .value attribute of a c_wchar_p instance, and the
  instance does not point to a valid wchar_t zero-terminated string,
  raise a ValueError.  c_char_p does this already.

  The ValueError message now contains the correct pointer address.

  Will backport to release25-maint.
........
2007-05-02 19:41:16 +00:00
Kristján Valur Jónsson 55d53f0367 Merging of change 55024 from the truk to release25-maint branch.
Complete revamp of PCBuild8 directory.  Use subdirectories for each project under the main pcbuild solution.  Now make extensive use of property sheets to simplify project configuration. x64 build fully supported, and the process for building PGO version (Profiler Guided Optimization) simplified. All projects are now present, except _ssl, which needs to be reimplemented.  Also, some of the projects that require external libraries need extra work to fully compile on x64.
2007-05-02 15:55:14 +00:00
Thomas Heller f69fa1756f Merged revisions 55025 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Modules/_ctypes

........
  r55025 | thomas.heller | 2007-04-30 17:44:17 +0200 (Mo, 30 Apr 2007) | 4 lines

  Make sure to call PyErr_NoMemory() in several places where
  PyMem_Malloc() could potentially fail.

  Will backport to the release25-maint branch.
........
2007-04-30 15:58:51 +00:00
Kristján Valur Jónsson b9d39916ac Properly implement Georg Brandl's Patch #1185447 to the 2.5 maintainance branch 2007-04-22 10:18:46 +00:00
Kristján Valur Jónsson 5e4e31f76a Fix various minor issues discovered with static analysis using Visual Studio 2005 Team System.
Removed obsolete comment, since .dll modules are no longer supported on windows, only .pyd.
2007-04-21 12:46:49 +00:00
Neal Norwitz ef4364f3b8 Fix unpack so it works on 64-bit platforms. 2007-04-05 05:06:49 +00:00
Raymond Hettinger b2064d7280 Fix-up error-exits on struct_unpack(). 2007-04-04 21:57:12 +00:00
Raymond Hettinger 3608f0570e Bug #1563759: struct.unpack doens't support buffer protocol objects 2007-04-04 20:32:03 +00:00
Martin v. Löwis 8863544522 Bug #1686475: Support stat'ing open files on Windows again. 2007-04-04 18:30:56 +00:00
Matthias Klose 5d2d2ef1f5 - Fix an off-by-one bug in locale.strxfrm().
Patch taken from http://bugs.debian.org/416934.
2007-04-03 04:39:34 +00:00
Raymond Hettinger d6030acd7f Array module's buffer interface can now handle empty arrays. 2007-04-02 22:39:08 +00:00
Raymond Hettinger 4bbcb64d5d SF #1693079 Array module cannot pickle empty arrays 2007-04-02 17:03:46 +00:00
Neal Norwitz 65407fb734 Backport 54594:
Fix SF #1688393, sock.recvfrom(-24) crashes

Also fix some method names that were copied incorrectly (trunk fixed).
2007-03-31 18:56:11 +00:00
Georg Brandl 7b1be36bb7 In Windows' time.clock(), when QueryPerformanceFrequency() fails,
the C lib's clock() is used, but it must be divided by CLOCKS_PER_SEC
as for the POSIX implementation (thanks to #pypy).
 (backport from rev. 54606)
2007-03-29 12:42:16 +00:00
Thomas Heller b151f721a9 Prevent creation (followed by a segfault) of array types when the size
overflows the valid Py_ssize_t range.  Check return values of
PyMem_Malloc.

Backported from trunk.
2007-03-23 19:56:45 +00:00
Thomas Heller 50d1d0bad5 Explain the purpose of the b_needsfree flag. This answers Neals
question (well, two months too late).
2007-03-22 20:33:04 +00:00
Thomas Heller 02b8feea9f Back out "Patch #1643874: memory leak in ctypes fixed."
The code in this patch leaves no way to give up the ownership of a
BSTR instance.
2007-03-22 19:43:37 +00:00
Georg Brandl d6e73c1785 Bug #1622896: fix a rare corner case where the bz2 module raised an
error in spite of a succesful compression.
 (backport from rev. 54336)
2007-03-13 12:34:35 +00:00
Thomas Heller 8bf469ddc1 Merged revisions 54248 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Lib/ctypes

........
  r54248 | thomas.heller | 2007-03-09 21:39:22 +0100 (Fr, 09 Mär 2007) | 7 lines

  Bug #1651235: When a tuple was passed to a ctypes function call,
  Python would crash instead of raising an error.

  The crash was caused by a section of code that should have been
  removed long ago, at that time ctypes had other ways to pass
  parameters to function calls.
........
2007-03-09 20:48:57 +00:00
Thomas Heller f7eed5e2d1 Merged revisions 54244 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Lib/ctypes

........
  r54244 | thomas.heller | 2007-03-09 20:21:28 +0100 (Fr, 09 Mär 2007) | 3 lines

  Fix bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0)
  returned string up to the first NUL character.
........
2007-03-09 20:21:16 +00:00
Walter Dörwald 05b5c7fe0e Backport checkin:
Patch for bug #1633621: if curses.resizeterm() or
curses.resize_term() is called, update _curses.LINES,
_curses.COLS, curses.LINES and curses.COLS.
2007-03-06 20:46:26 +00:00
Georg Brandl 62b1b001e6 Patch #1654417: make operator.{get,set,del}slice use the full range
of Py_ssize_t.
 (backport from rev. 54177)
2007-03-06 19:00:09 +00:00
Georg Brandl 02d7cffb8f Patch #1646728: datetime.fromtimestamp fails with negative
fractional times.  With unittest.
  (backport from rev. 54167 by Guido)
2007-03-06 17:46:17 +00:00
Georg Brandl 75e3c527f6 Fix another reincarnation of bug #1576657 in defaultdict.
(backport from rev. 54160)
2007-03-06 13:33:07 +00:00
Martin v. Löwis b8d661bd5e Revert r53672, just fix signature of time_isoformat instead. 2007-02-18 08:50:38 +00:00
Martin v. Löwis 1e335b2968 Patch #1657276: Make NETLINK_DNRTMSG conditional. 2007-02-13 12:14:29 +00:00
Martin v. Löwis 2e8b602ac1 Bug #1653736: Complain about keyword arguments to time.isoformat. 2007-02-08 09:13:51 +00:00
Raymond Hettinger 9f0e1ea964 Do not let overflows in enumerate() and count() pass silently. 2007-02-07 23:57:05 +00:00
Raymond Hettinger 113776c411 Check for a common user error with defaultdict(). 2007-02-07 21:40:49 +00:00
Georg Brandl 3d26ef1d10 Bug #1645944: os.access now returns bool but docstring is not updated
(backport from rev. 53579)
2007-01-27 19:38:56 +00:00
Thomas Heller 817b489422 Merged revisions 53556 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Modules/_ctypes

........
  r53556 | thomas.heller | 2007-01-25 19:34:14 +0100 (Do, 25 Jan 2007) | 3 lines

  Fix for #1643874: When calling SysAllocString, create a PyCObject
  which will eventually call SysFreeString to free the BSTR resource.
........
2007-01-25 19:19:35 +00:00
Andrew M. Kuchling b8c6e1f33f [Bug #1552726] Avoid unnecessary polling at the interpreter prompt when certain versions of readline are being used 2007-01-22 16:10:27 +00:00
Georg Brandl 8e932e7d68 Bug #1486663: don't reject keyword arguments for subclasses of builtin
types.
 (backport from rev. 53509)
2007-01-21 10:28:56 +00:00
Neal Norwitz e962300d0c Add a comment for some code I don't understand. Why would needsfree
be true if we didn't malloc the code?  Seems like the code is wrong
or could use comments.

Also verify if the buildbots are working properly for the 2.5 branch.
2007-01-18 07:16:31 +00:00
Thomas Heller 2a98c56c13 Merged revisions 53466 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Modules/_ctypes

........
  r53466 | thomas.heller | 2007-01-17 10:40:34 +0100 (Mi, 17 Jan 2007) | 2 lines

  Replace C++ comments with C comments.
........
2007-01-17 09:53:03 +00:00
Thomas Heller 3193763bdf Must update the version number on the extension module as well. 2007-01-10 20:44:21 +00:00
Raymond Hettinger 5b44cbe6d8 Fix zero-length corner case for iterating over a mutating deque. 2007-01-08 18:05:53 +00:00
Gregory P. Smith 1a050f5f52 support linking the _bsddb extension module against BerkeleyDB 4.5
[backport of r53252]
2007-01-05 02:09:06 +00:00
Martin v. Löwis bea1c70144 Bug #1566280: Explicitly invoke threading._shutdown from Py_Main,
to avoid relying on atexit.
2007-01-04 21:06:57 +00:00
Thomas Wouters 04e820443b Backport trunk checkin r51565:
Fix SF bug #1545837: array.array borks on deepcopy. array.__deepcopy__()
needs to take an argument, even if it doesn't actually use it.
2006-12-29 14:42:17 +00:00
Andrew M. Kuchling 9333ce189f [Patch #1615868 by Lars Gustaebel] Use Py_off_t to fix BZ2File.seek() for offsets > 2Gb 2006-12-18 19:26:13 +00:00
Martin v. Löwis 95b744cea9 Patch #1544279: Improve thread-safety of the socket module by moving
the sock_addr_t storage out of the socket object.
2006-12-03 11:24:00 +00:00
Thomas Heller 84a90cade5 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.

Backport from trunk.
2006-11-28 20:43:11 +00:00
Thomas Heller 558e56d599 Fix bug #1598620: A ctypes structure cannot contain itself.
Backport from trunk.
2006-11-24 19:00:39 +00:00
Neal Norwitz 5890a6a8a6 Backport of 52811:
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.
2006-11-21 05:29:34 +00:00
Georg Brandl dd3bffb679 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.
 (backport from rev. 52765)
2006-11-16 17:08:48 +00:00
Walter Dörwald f2d5c6d117 Backport checkin:
Replace C++ comment with C comment (fixes SF bug #1593525).
2006-11-09 16:30:39 +00:00
Neal Norwitz c975b9477b Backport 52503:
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).
2006-10-28 21:37:42 +00:00
Neal Norwitz b5fdf0da21 Backport 52501:
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:36:37 +00:00
Martin v. Löwis 64cd9efd80 Get DBL_MAX from float.h not values.h. 2006-10-27 07:06:59 +00:00
Martin v. Löwis 2ec1df2785 Check for values.h. 2006-10-27 06:43:00 +00:00
Martin v. Löwis 62e58040c1 [Backport of r52452]
Patch #1549049: Rewrite type conversion in structmember.
Fixes #1545696 and #1566140.

The new warnings have been omitted in the backport.
2006-10-27 06:17:21 +00:00
Martin v. Löwis 63a9b8b067 - Patch #1560695: Add .note.GNU-stack to ctypes' sysv.S so that
ctypes isn't considered as requiring executable stacks.
2006-10-22 10:55:25 +00:00
Tim Peters fbbfb4b976 C:\Code\python>type c.txt
Merge rev 52377 from trunk:

newIobject():  repaired incorrect cast to quiet MSVC warning.
2006-10-18 05:30:25 +00:00
Thomas Heller dcbf64d34d 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.

Backported from trunk.
2006-10-17 19:41:10 +00:00
Martin v. Löwis 2c7aa634cb Bug #1567666: Emulate GetFileAttributesExA for Win95. 2006-10-15 09:44:02 +00:00
Georg Brandl 3c48709e3a 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.
 (backport from rev. 52301)
2006-10-12 09:47:17 +00:00
Martin v. Löwis 463a42b5de Bug #1565150: Fix subsecond processing for os.utime on Windows. 2006-10-09 20:44:50 +00:00
Barry Warsaw 6bf550138d List gc.get_count() in the module docstring. 2006-10-09 19:42:33 +00:00
Hye-Shik Chang f4fe46d74b Backport from trunk r52223:
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 14:01:45 +00:00
Kristján Valur Jónsson 2c8851e614 Backport the .sln and .vcproj files for PCBuild8 from the python trunk to the 2.5 maintainance branch. This fixes build problems with visual studio 2005, and cleans up profile guided optimization. 2006-10-07 14:56:30 +00:00
Andrew M. Kuchling d79524a4cc [Backport to 2-5maint of r52147 | andrew.kuchling ; the buildbots seem OK
with this change.]

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.
2006-10-05 17:26:33 +00:00
Armin Rigo 4b63c21d6f Forward-port of r52136: 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 11:44:06 +00:00
Armin Rigo c6f2f884b4 Compilation problem caused by conflicting typedefs for uint32_t
(unsigned long vs. unsigned int).
2006-10-04 10:23:57 +00:00
Georg Brandl 6d7c36332f Bug #1556784: allow format strings longer than 127 characters in
datetime's strftime function.
 (backport from rev. 52072)
2006-09-30 11:17:43 +00:00
Gregory P. Smith 6fed7937c6 fix: DB.stat flags and txn keyword arguments were backwards. 2006-09-30 06:05:07 +00:00
Georg Brandl b14b59fcf9 Backport rev. 51987: superfluous semicola. 2006-09-25 06:53:42 +00:00
Jack Diederich 187e64806f backport of r51950
* 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
2006-09-21 18:32:11 +00:00
Neal Norwitz 5728c27c74 Backport rev 51820 from Thomas Heller
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-11 04:02:43 +00:00
Neal Norwitz 71e2aa0cc5 Backport rev 51819 from Thomas Heller
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).
2006-09-11 04:01:57 +00:00
Hye-Shik Chang 137ae0cf7c Backport from trunk r51737:
Fixed a few bugs on cjkcodecs:
- 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 0213:2
  codepoints now.
2006-09-07 12:50:38 +00:00
Thomas Heller 291a1b89c6 Backport of r51379 from trunk:
Add asserts to check for 'impossible' NULL values, with comments.
In one place where I'm 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-09-06 17:48:56 +00:00
Georg Brandl b20cb33f7f Bug #1551427: fix a wrong NULL pointer check in the win32 version
of os.urandom().
 (backport from rev. 51762)
2006-09-06 06:04:06 +00:00
Neal Norwitz 716692ff13 Backport fix from 51683. 2006-09-05 02:33:44 +00:00
Neal Norwitz 7ae5f29465 Backport fix for SF bug #1550714, itertools.tee raises SystemError 2006-09-05 02:30:10 +00:00
Neal Norwitz 7b3c031790 Alexander Belopolsky pointed out that pos is a size_t 2006-08-22 13:57:07 +00:00
Neal Norwitz 47f0ffa7ee Fix a couple of ssize-t issues reported by Alexander Belopolsky on python-dev 2006-08-21 18:44:09 +00:00
Neal Norwitz 03ee62c352 Move assert to after NULL check, otherwise we deref NULL in the assert.
Klocwork #307
2006-08-19 04:18:39 +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