Commit Graph

4734 Commits

Author SHA1 Message Date
Gregory P. Smith 99a3dce92d More reverting of r63675 per the mailing list discussions. This restores
occurances of PyBytes_ in the code to their original PyString_ names.  The
bytesobject.c file will be renamed back to stringobject.c in a future checkin.
2008-06-10 17:42:36 +00:00
Thomas Heller dcea9a91c6 Add an optional 'offset' parameter to byref, defaultingto zero. 2008-06-10 14:02:46 +00:00
Georg Brandl 8550d69a84 #2536: fix itertools.permutations and itertools.combinations docstrings. 2008-06-10 12:46:39 +00:00
Raymond Hettinger d623414141 Unhappy buildbots. Revert 64052. Long doubles have unexpected effects on some builds. 2008-06-09 11:24:47 +00:00
Raymond Hettinger 7b1ed66372 Address double-rounding scenarios by setting all variables to long doubles. 2008-06-09 09:29:17 +00:00
Raymond Hettinger ecbdd2e9b0 Issue #2138: Add math.factorial(). 2008-06-09 06:54:45 +00:00
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html

Python 2.6 should stick with PyString_* in its codebase.  The PyBytes_* names
in the spirit of 3.0 are available via a #define only.  See the email thread.
2008-06-09 04:58:54 +00:00
Travis E. Oliphant 0144f27602 Remove locking part of new buffer protocol. 2008-06-06 22:39:47 +00:00
Raymond Hettinger ec2fe78d47 Issue 3501: Make heapq support both __le__ and __lt__. 2008-06-06 21:47:51 +00:00
Thomas Heller f89b04c164 Performance improvement: Use PyDict_Get/SetItem instead of
PyDict_Get/SetItemString.
2008-06-06 18:37:55 +00:00
Thomas Heller fbb9c0bf3c Issue #1798: Add ctypes calling convention that allows safe access of errno.
ctypes maintains thread-local storage that has space for two error
numbers: private copies of the system 'errno' value and, on Windows,
the system error code accessed by the GetLastError() and
SetLastError() api functions.

Foreign functions created with CDLL(..., use_errno=True), when called,
swap the system 'errno' value with the private copy just before the
actual function call, and swapped again immediately afterwards.  The
'use_errno' parameter defaults to False, in this case 'ctypes_errno'
is not touched.

On Windows, foreign functions created with CDLL(...,
use_last_error=True) or WinDLL(..., use_last_error=True) swap the
system LastError value with the ctypes private copy.

The values are also swapped immeditately before and after ctypes
callback functions are called, if the callbacks are constructed using
the new optional use_errno parameter set to True: CFUNCTYPE(...,
use_errno=TRUE) or WINFUNCTYPE(..., use_errno=True).

New ctypes functions are provided to access the ctypes private copies
from Python:

- ctypes.set_errno(value) and ctypes.set_last_error(value) store
  'value' in the private copy and returns the previous value.

- ctypes.get_errno() and ctypes.get_last_error() returns the current
  ctypes private copies value.
2008-06-06 08:33:46 +00:00
Thomas Heller 2e75c450d2 Backport from py3k: Implement the new buffer interface from pep3118
for ctypes instances.  Closes issue #2404.
2008-06-05 17:51:15 +00:00
Ronald Oussoren 5640ce2f1e MacOS X: Enable 4-way universal builds
This patch adds a new configure argument on OSX:
        --with-universal-archs=[32-bit|64-bit|all]

When used with the --enable-universalsdk option this controls which
CPU architectures are includes in the framework. The default is 32-bit,
meaning i386 and ppc. The most useful alternative is 'all', which includes
all 4 CPU architectures supported by MacOS X (i386, ppc, x86_64 and ppc64).

This includes limited support for the Carbon bindings in 64-bit mode as well,
limited because (a) I haven't done extensive testing and (b) a large portion
of the Carbon API's aren't available in 64-bit mode anyway.

I've also duplicated a feature of Apple's build of python: setting the
environment variable 'ARCHFLAGS' controls the '-arch' flags used for building
extensions using distutils.
2008-06-05 12:58:24 +00:00
Thomas Heller d5bb9215c9 Revert revisions 63943 and 63942 (Issue #1798: Add ctypes calling
convention that allows safe access to errno)

This code does not yet work on OS X (__thread storage specifier not
available), so i needs a configure check plus a more portable
solution.
2008-06-04 20:22:05 +00:00
Thomas Heller 8f22b88e28 Fix ctypes.set_errno for gcc. 2008-06-04 19:19:00 +00:00
Thomas Heller e70c3378c0 Issue #1798: Add ctypes calling convention that allows safe access to
errno (and LastError, on Windows).

ctypes maintains a module-global, but thread-local, variable that
contains an error number; called 'ctypes_errno' for this discussion.
This variable is a private copy of the systems 'errno' value; the copy
is swapped with the 'errno' variable on several occasions.

Foreign functions created with CDLL(..., use_errno=True), when called,
swap the values just before the actual function call, and swapped
again immediately afterwards.  The 'use_errno' parameter defaults to
False, in this case 'ctypes_errno' is not touched.

The values are also swapped immeditately before and after ctypes
callback functions are called, if the callbacks are constructed using
the new optional use_errno parameter set to True: CFUNCTYPE(..., use_errno=TRUE)
or WINFUNCTYPE(..., use_errno=True).

Two new ctypes functions are provided to access the 'ctypes_errno'
value from Python:

- ctypes.set_errno(value) sets ctypes_errno to 'value', the previous
  ctypes_errno value is returned.

- ctypes.get_errno() returns the current ctypes_errno value.

---

On Windows, the same scheme is implemented for the error value which
is managed by the GetLastError() and SetLastError() windows api calls.

The ctypes functions are 'ctypes.set_last_error(value)' and
'ctypes.get_last_error()', the CDLL and WinDLL optional parameter is
named 'use_last_error', defaults to False.

---

On Windows, TlsSetValue and TlsGetValue calls are used to provide
thread local storage for the variables; ctypes compiled with __GNUC__
uses __thread variables.
2008-06-04 18:59:03 +00:00
Walter Dörwald a2a89a8712 Change all functions that expect one unicode character to accept a pair of
surrogates in narrow builds. Fixes issue #1706460.
2008-06-02 20:36:03 +00:00
Thomas Heller de2d78a153 Fix misspelled sys.platform name and misspelled filename. 2008-06-02 18:41:30 +00:00
Gregory P. Smith 137d824148 Fix issue 2782: be less strict about the format string type in strftime.
Accept unicode and anything else ParseTuple "s#" can deal with.  This
matches the time.strftime behavior.
2008-06-02 04:05:52 +00:00
Martin v. Löwis 99815892f6 New environment variable PYTHONIOENCODING. 2008-06-01 07:20:46 +00:00
Gerhard Häring 7f7ca35f5b Fixed rowcount for SELECT statements. They're -1 now (again), for better DB-API 2.0 compliance. 2008-05-31 21:33:27 +00:00
Raymond Hettinger 6d7702ecd1 Implement heapq in terms of less-than (to match list.sort()). 2008-05-31 03:24:31 +00:00
Raymond Hettinger ef712d6fd3 * Mark intermedidate computes values (hi, lo, yr) as volatile.
* Expand comments.
* Swap variable names in the sum_exact code so that x and y
  are consistently chosen as the larger and smaller magnitude
  values respectively.
2008-05-30 18:20:50 +00:00
Thomas Heller 9287acf83d ctypes NULL function pointers have a boolean False value now. 2008-05-29 19:42:34 +00:00
Thomas Heller a52b244cc1 Fix compiler warning. 2008-05-29 19:18:12 +00:00
Raymond Hettinger 2a9179ac73 Fix two typos. 2008-05-29 08:38:23 +00:00
Gregory P. Smith 572226cad8 Define macros so that this still compiles on Python prior to r63675. 2008-05-26 19:03:35 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Martin v. Löwis 8c255e4173 Patch #1722225: Support QNX 6. 2008-05-23 15:06:50 +00:00
Raymond Hettinger 778d5cc4fb Tweak the comments and formatting. 2008-05-23 04:32:43 +00:00
Mark Dickinson 99dfe92759 Issue #2819: Add math.sum, a function that sums a sequence of floats
efficiently but with no intermediate loss of precision.  Based on
Raymond Hettinger's ASPN recipe.  Thanks Jean Brouwers for the patch.
2008-05-23 01:35:30 +00:00
Jesus Cea ca3939cd52 bsddb module updated to version 4.7.0 2008-05-22 15:27:38 +00:00
Thomas Heller 03b75ddf7c On HPUX, -fPIC must be used for linking. _ctypes now builds on HP-UX
IA64 and PA machines.

The ctypes unittests work fine on the IA64, but dump core in
test_qsort on the PA.
2008-05-20 19:53:47 +00:00
Georg Brandl dffbf5f542 Revert copy_reg -> copyreg rename. 2008-05-20 07:49:57 +00:00
Gregory P. Smith 664782e1c8 issue2858: Fix potential memory corruption when bsddb.db.DBEnv.lock_get
and other bsddb.db object constructors raised an exception.
Debugging & patch by Neal Norowitz.
2008-05-17 06:12:02 +00:00
Alexandre Vassalotti 3c4971c40e Added Python 3.0 warning to cPickle. 2008-05-16 19:14:31 +00:00
Georg Brandl 5049a858ba #2890: support os.O_ASYNC and fcntl.FASYNC. 2008-05-16 13:10:15 +00:00
Christian Heimes ca21c65a23 Following Amaury's advice 2008-05-16 11:28:56 +00:00
Christian Heimes 0bd23c0a98 Fixed #2870: cmathmodule.c compile error 2008-05-16 10:23:31 +00:00
Brett Cannon 2224817cdf Deprecate sunaudiodev/SUNAUDIODEV for removal in 3.0. 2008-05-16 00:10:24 +00:00
Brett Cannon 4652537ba4 Deprecate imgfile for removal in 3.0. 2008-05-15 03:32:11 +00:00
Brett Cannon 75ba465099 Deprecated 'fm' for removal in 3.0. 2008-05-15 03:23:17 +00:00
Brett Cannon 178582e2a4 FL, flp, and fl from IRIX have been deprecated for removal in 3.0. 2008-05-15 03:20:36 +00:00
Brett Cannon 044616aa24 Deprecate DEVICE, GL, gl, and the related modules cgen and cgensupport for removal in 3.0. 2008-05-15 02:33:55 +00:00
Brett Cannon 650f5161f4 Deprecate CL, CL_old, and cl for 3.0. 2008-05-14 21:12:12 +00:00
Brett Cannon ddf949f194 The CD and cd modules for IRIX are deprecated for 3.0. 2008-05-14 20:31:38 +00:00
Brett Cannon 34721d5683 Deprecate al/AL for removal in 3.0. 2008-05-14 01:08:21 +00:00
Jesus Cea ef9764f1a4 bsddb module updated to version 4.6.4 2008-05-13 18:45:46 +00:00
Brett Cannon bb141bb1f4 Deprecate the timing module for removal in Python 3.0. 2008-05-12 03:47:47 +00:00
Brett Cannon ac861b5a17 Deprecate the sv module as per PEP 4. 2008-05-12 03:45:59 +00:00
Brett Cannon 42bfa90f02 Depreate imageop for removal in 3.0. 2008-05-12 00:08:34 +00:00
Brett Cannon b61d801adb Put Lib/lib-old back on to sys.path for module renames. 2008-05-11 23:39:04 +00:00
Georg Brandl 6a57c08dc8 #1326: document and test zipimporter.archive and zipimporter.prefix. 2008-05-11 15:05:13 +00:00
Alexandre Vassalotti 9510e4a9f8 Added module stub for copy_reg renaming in 3.0.
Renamed copy_reg to copyreg in the standard library, to avoid
spurious warnings and ease later merging to py3k branch. Public
documentation remains intact.
2008-05-11 08:25:28 +00:00
Brett Cannon 7595c1a36b Flesh out the 3.0 deprecation to suggest using the ctypes module. 2008-05-11 01:09:32 +00:00
Brett Cannon df0a717037 The linuxaudidev module has been deprecated for removal in Python 3.0. 2008-05-11 00:50:51 +00:00
Brett Cannon 7f874fce63 Deprecate the dl module for removal in 3.0. 2008-05-10 21:20:19 +00:00
Brett Cannon 768d44f54d Deprecate the bsddb185 module for removal in 3.0. 2008-05-10 02:47:54 +00:00
Brett Cannon 9ac3974de8 Deprecate the pure module for 3.0. 2008-05-09 22:51:58 +00:00
Alexandre Vassalotti 1aed624f7c Backport fast alternate io.BytesIO implementation.
Merged r62778, r62779, r62802, r62806, r62807, r62808, r62809, r62844,
r62846, r62952, r62956.
2008-05-09 21:49:43 +00:00
Mark Dickinson f8476c1573 Issue #2487. math.ldexp(x, n) raised OverflowError when n was large and
negative; fix to return an (appropriately signed) zero instead.
2008-05-09 17:54:23 +00:00
Christian Heimes af748c3ab8 Implemented PEP 370 2008-05-06 22:41:46 +00:00
Christian Heimes c8a0d2f368 Intern static string
Use float constructors instead of magic code for float constants
2008-05-06 16:18:41 +00:00
Brett Cannon 4b964f9c90 Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Ippolito.

Closes issue #2750.
2008-05-05 20:21:38 +00:00
Gerhard Häring e11c9b3dfd Implemented feature request 2157: Converter names are cut off at '('
characters. This avoids the common case of something like 'NUMBER(10)' not
being parsed as 'NUMBER', like expected. Also corrected the docs about
converter names being case-sensitive. They aren't any longer.
2008-05-04 13:42:44 +00:00
Gerhard Häring 5a366c3b8b Applied sqliterow-richcmp.diff patch from Thomas Heller in Issue2152. The
sqlite3.Row type is now correctly hashable.
2008-05-04 13:15:12 +00:00
Gerhard Häring ffa3357d52 SQLite requires 64-bit integers in order to build. So the whole HAVE_LONG_LONG
#ifdefing was useless.
2008-05-04 12:59:57 +00:00
Brett Cannon 8dc4303297 Rename the test_traceback_print() function to traceback_print() to prevent
test_capi from automatically calling the function.
2008-04-28 04:50:06 +00:00
Brett Cannon 141534e56f Fix a bug introduced by the warnings rewrite where tracebacks were being
improperly indented.

Closes issue #2699.
2008-04-28 03:23:50 +00:00
Benjamin Peterson f19a7b90bd A little reformating of Py3k warnings 2008-04-27 18:40:21 +00:00
Benjamin Peterson 9f4f48114f Use PyErr_WarnPy3k throughout 2008-04-27 03:01:45 +00:00
Georg Brandl a6b79f3b11 Add missing return type to dealloc. 2008-04-26 18:32:17 +00:00
Thomas Heller 6ad5fbb7ea Add from_buffer and from_buffer_copy class methods to ctypes types. 2008-04-25 15:44:16 +00:00
Thomas Heller bf027c48c8 Remove cyclic reference in CFuncPtr instances; see issue #2682.
Backport candidate for the release25-maint branch.
2008-04-24 18:14:19 +00:00
Martin v. Löwis 83c9201465 Fix typo. 2008-04-24 13:17:24 +00:00
Mark Dickinson 0da94c8a34 Silence 'r may be used uninitialized' compiler warning. 2008-04-21 01:55:50 +00:00
Mark Dickinson 92483cd8da math.atan2 is misbehaving on Windows; this patch
should fix the problem in the same way that
the cmath.phase problems were fixed.
2008-04-20 21:39:04 +00:00
Mark Dickinson c632301bd4 Even more fixes for alpha Tru64, this time for
the phase and polar methods.
2008-04-20 18:30:05 +00:00
Mark Dickinson 98c317a34d Issue 2662: Initialize special value tables dynamically (i.e. when
cmath module is loaded) instead of statically. This fixes compile-time
problems on platforms where HUGE_VAL is an extern variable rather than
a constant.

Thanks Hirokazu Yamamoto for the patch.
2008-04-20 16:13:17 +00:00
Mark Dickinson cec3f138d8 Yet more explicit special case handling to make
math.pow behave on alpha Tru64.  All IEEE 754
special values are now handled directly; only
the finite**finite case is handled by libm.
2008-04-20 04:13:13 +00:00
Mark Dickinson b2f7090239 FreeBSD doesn't follow C99 for modf(inf); so add explicit
special-value handling to math.modf code.
2008-04-20 01:39:24 +00:00
Mark Dickinson a1293eb65f Additional special-case handling for math.pow.
Windows/VS2008 doesn't like (-1)**(+-inf).
2008-04-19 19:41:52 +00:00
Mark Dickinson e941d97d12 Additional tests for math.pow, and extra special-case
handling code in math.pow, in the hope of making all
tests pass on the alpha Tru64 buildbot.
2008-04-19 18:51:48 +00:00
Christian Heimes 6f34109384 I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
The patch also adds acosh, asinh, atanh, log1p and copysign to all platforms. Finally it fixes differences between platforms like different results or exceptions for edge cases. Have fun :)
2008-04-18 23:13:07 +00:00
Thomas Heller 046e6a43ff Issue #2616: Implement ctypes.pointer() and ctypes.POINTER() in C for
better performance.
2008-04-14 16:10:07 +00:00
Georg Brandl 41a0a37c08 Improve -X error message. 2008-04-13 20:50:29 +00:00
Brett Cannon e974689038 Re-implement the 'warnings' module in C. This allows for usage of the
'warnings' code in places where it was previously not possible (e.g., the
parser). It could also potentially lead to a speed-up in interpreter start-up
if the C version of the code (_warnings) is imported over the use of the
Python version in key places.

Closes issue #1631171.
2008-04-12 23:44:07 +00:00
Gregory P. Smith 73bee444ab fix compiler warnings 2008-04-12 20:37:48 +00:00
Christian Heimes 7a98d2730c Applied patch #2617 from Frank Wierzbicki wit some extras from me
-J and -X are now reserved for Jython and non-standard arguments (e.g. IronPython). I've added some extra comments to make sure the reservation don't get missed in the future.
2008-04-12 13:03:03 +00:00
Thomas Heller d3ed492164 Performance improvements. 2008-04-11 14:20:26 +00:00
Thomas Heller 12c4e6478a Move backwards compatibility macro to the correct place;
PyIndex_Check() was introduced in Python 2.5.
2008-04-11 13:05:38 +00:00
Gregory P. Smith 79e42a0e08 Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory.  That fails.
2008-04-09 00:25:17 +00:00
Amaury Forgeot d'Arc 7adc776ea6 Issue 2408: remove the _types module
It was only used as a helper in types.py to access types (GetSetDescriptorType and MemberDescriptorType),
when they can easily be obtained with python code.
These expressions even work with Jython.

I don't know what the future of the types module is; (cf. discussion in http://bugs.python.org/issue1605 )
at least this change makes it simpler.
2008-04-08 22:07:05 +00:00
Gregory P. Smith c20adf8ef2 Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library.  These modules use PyFile_AsFile and later
release the GIL while operating on the previously returned FILE*.
2008-04-07 06:33:21 +00:00
Skip Montanaro 28112d0cb6 type 2008-04-06 17:05:57 +00:00
Skip Montanaro 9e0fa7a13e Declare inittimezone static. 2008-04-05 19:47:47 +00:00
Thomas Heller c4ef47611f More files from libffi 3.0.5.
Removed libffi.pc.in because it is not needed for ctypes.
2008-04-04 19:14:42 +00:00
Thomas Heller e1929d5133 Sync with files from the just released libffi 3.0.5 version. 2008-04-04 16:01:54 +00:00
Thomas Heller 8e8ba151dd Issue #2543: Make ctypes compatible (again) with Python 2.3, 2.4, and 2.5. 2008-04-04 08:35:44 +00:00
Guido van Rossum b1ba750226 Remove the advertising clause from the BSD license in timing.h.
I have the email trail to prove that George Neville-Neil approved this.
2008-04-01 23:57:36 +00:00