Commit Graph

4066 Commits

Author SHA1 Message Date
Anthony Baxter d6495b5944 remove forward declarations. No constructors to move for these files. Makes
code work with C++ compilers.
2006-04-12 04:29:01 +00:00
Anthony Baxter aefd8ca701 Move constructors, add some casts to make C++ compiler happy. Still a problem
with the getstring() results in pattern_subx. Will come back to that.
2006-04-12 04:26:11 +00:00
Anthony Baxter 5576b54bec remove forward declarations, move constructor functions. makes code C++ safe. 2006-04-12 04:08:46 +00:00
Anthony Baxter 64182fe0b3 Some more changes to make code compile under a C++ compiler. 2006-04-11 12:14:09 +00:00
Georg Brandl 05e89b86d6 Clear errno before calling opendir() and readdir(). 2006-04-11 07:04:06 +00:00
Georg Brandl bbfe4fad36 Bug #1467952: os.listdir() now correctly raises an error if readdir()
fails with an error condition.
2006-04-11 06:47:43 +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 84a98e07f5 Fix warning about ptsname not being a prototype on Solaris. Is this prototype even necessary anymore? 2006-04-10 07:44:23 +00:00
Neal Norwitz 65c05b20e9 Get rid of warnings about using chars as subscripts
on Alpha (and possibly other platforms) by using Py_CHARMASK().
2006-04-10 02:17:47 +00:00
Neal Norwitz b183a25c29 Fix some warnings on HP-UX when using cc/aCC 2006-04-10 01:03:32 +00:00
Neal Norwitz 4c842a4db0 Fix problem (not checking return result) reported by Coverity 2006-04-09 04:07:39 +00:00
Gregory P. Smith 7f5b6f4b33 Fix bsddb.db.DBError derived exceptions so they can be unpickled.
Also adds some backwards compatibility when compiling _bsddb.c on earlier
python versions (needed for pybsddb).
2006-04-08 07:10:51 +00:00
Martin v. Löwis 5fe60e7a4c Patch #1462080: Conditionalize some NETLINK defines. 2006-04-06 22:29:33 +00:00
Thomas Heller fff61ea025 Expose RTLD_LOCAL and RTLD_GLOBAL always from the _ctypes extension module.
If RTLD_LOCAL is not #defined in any header file (Windows), set it to 0.
If RTLD_GLOBAL is not #defined, set it equal to RTLD_LOCAL.

This should fix ctypes on cygwin.
2006-04-06 15:23:16 +00:00
Thomas Heller 430947ac66 Replace a few more 'char' types with 'signed char', to fix test failures
on platforms (ppc debian) where 'char' is unsigned.
2006-04-06 09:02:58 +00:00
Neal Norwitz b43199822b This change shouldn't have any functional effect. Coverity was
complaining because it seemed like parameters_iter could be NULL.
2006-04-06 08:43:16 +00:00
Neal Norwitz d126200aeb Fix unchecked return result from Coverity. 2006-04-06 08:41:59 +00:00
Neal Norwitz ffb0d90a6e Handle ssize_t 2006-04-06 08:07:25 +00:00
Neal Norwitz 915ae41b3a Handle error conditions from PyString_ConcatAndDel(). 2006-04-06 08:06:52 +00:00
Neal Norwitz b038333d4b Handle ssize_t
No need to INCREF then let PyString_ConcatAndDel() DECREF.  Just
use PyString_Concat().
Handle error condition if we can't concat.
2006-04-06 08:05:53 +00:00
Thomas Heller 3c423a04ba Explicitely use 'signed char', to avoid problems on platforms with unsigned char type. 2006-04-05 20:34:18 +00:00
Thomas Heller 0890de3be0 Explicitely use 'signed char', to avoid problems on platforms with unsigned char type. 2006-04-05 19:51:19 +00:00
Anthony Baxter 8e7b490890 upgrade to final version of pysqlite 2.2.0 2006-04-05 18:25:33 +00:00
Fredrik Lundh 4aaaa49bac docstring tweak 2006-04-04 16:51:13 +00:00
Anthony Baxter 3b8ff31055 SF Bug #1448488 - make collectionsmodule build on Cygwin, using the same
techniques as in Modules/xxsubtype.c
2006-04-04 15:05:23 +00:00
Neal Norwitz c410d6ce28 Fix a couple of memory issues 2006-04-04 07:25:25 +00:00
Anthony Baxter 72289a616c Update to pysqlite 2.2.0 2006-04-04 06:29:05 +00:00
Martin v. Löwis 5fe715f049 Properly support empty woperation in win32_startfile;
correct arguments to ShellExecuteW.
2006-04-03 23:01:24 +00:00
Thomas Heller cdab455f9a Try to fix the build on Mac OS X 10.3. The 'live_support' segment
attribute is not supported in this version.
2006-04-03 20:12:41 +00:00
Matthias Klose 739281148d - add missing chunk for patch #1117961 2006-04-03 16:59:32 +00:00
Matthias Klose 8e39ec78bc - Patch #360466: Replace the MD5 implementation from RSA Data Security Inc
with the implementation from http://sourceforge.net/projects/libmd5-rfc/.
2006-04-03 16:27:50 +00:00
Thomas Heller db5483be64 Try to fix the tests on OpenBSD. Apparently OpenBSD passes
structure parameters differently than other posix-like systems.
2006-04-03 16:19:45 +00:00
Georg Brandl ad89dc8794 Bug #1451503: allow unicode filenames in os.startfile(). 2006-04-03 12:26:26 +00:00
Neal Norwitz 92a6be4318 Whitespace: break long line 2006-04-03 04:46:28 +00:00
Neal Norwitz 95f0e4c401 Make ssize_t clean 2006-04-01 09:08:06 +00:00
Anthony Baxter 07f5b35e19 backport r243 from the pysqlite2 svn repository - lowers the required version
of SQLite3 from 3.2.2 to 3.0.8, by providing an alternative to
sqlite3_transfer_bindings. setup.py also handles the common (in debian
and ubuntu, at least) case of a buggy sqlite3.h SQLITE_VERSION_NUMBER.
2006-04-01 08:36:27 +00:00
Georg Brandl 22a9dc889d Patch #1459631: documnent zlib.Decompress.flush() length parameter. 2006-04-01 07:39:41 +00:00
Georg Brandl dcfdae7d72 Bug #1460564: document that socket.fromfd() duplicates the given
file descriptor.
2006-04-01 07:33:08 +00:00
Anthony Baxter c51ee69b27 merged the sqlite-integration branch.
This is based on pysqlite2.1.3, and provides a DB-API interface in
the standard library. You'll need sqlite 3.2.2 or later to build
this - if you have an earlier version, the C extension module will
not be built.
2006-04-01 00:57:31 +00:00
Thomas Wouters 2a9a6b0e86 In the fdopen(fd, 'a') case on UNIX, don't try to set fd's flags to -1 if
fcntl() and fdopen() both fail. Will backport.
2006-03-31 22:38:19 +00:00
Georg Brandl 644b1e7aac Add guards against fcntl() not being available on Windows. 2006-03-31 20:27:22 +00:00
Georg Brandl 54a188aed8 bug #1461855: make os.fdopen() add the O_APPEND flag if using "a" mode.
glibc, for example, does this already on its own, but it seems that
the solaris libc doesn't. This leads to Python code being able to over-
write file contents even though having specified "a" mode.
2006-03-31 20:00:11 +00:00
Georg Brandl 43f08a85e4 Patch #1380952: fix SSL objects timing out on consecutive read()s 2006-03-31 18:01:16 +00:00
Georg Brandl d37ac69ee5 Remove unnecessary casts from type object initializers. 2006-03-30 11:58:57 +00:00
Thomas Heller 3987df5adf Try to build _ctypes on x86 openbsd. 2006-03-30 11:51:58 +00:00
Tim Peters 62e97f023b In format strings slinging Py_ssize_t, unconditionally
interpolate PY_FORMAT_SIZE_T instead of #if'ing on
MS_WIN64.
2006-03-28 21:44:32 +00:00
Neal Norwitz 7491d2a23a Try to get rid of a Coverity warning by consistently using origpending. 2006-03-28 06:19:28 +00:00
Thomas Wouters 19bf33bc7a Make itertools.tee and its internal teedataobject participate in GC. This
alone does not solve the leak in test_generators, unfortunately, but it is
part of test_generators' problem and it does solve other cycles.
2006-03-27 21:02:13 +00:00
Hye-Shik Chang b9c03e999f Fix reference leaks introduced by the recent incremental codec
changes.
2006-03-27 08:24:54 +00:00
Tim Peters c9d78aa470 Years in the making.
objimpl.h, pymem.h:  Stop mapping PyMem_{Del, DEL} and PyMem_{Free, FREE}
to PyObject_{Free, FREE} in a release build.  They're aliases for the
system free() now.

_subprocess.c/sp_handle_dealloc():  Since the memory was originally
obtained via PyObject_NEW, it must be released via PyObject_FREE (or
_DEL).

pythonrun.c, tokenizer.c, parsermodule.c:  I lost count of the number of
PyObject vs PyMem mismatches in these -- it's like the specific
function called at each site was picked at random, sometimes even with
memory obtained via PyMem getting released via PyObject.  Changed most
to use PyObject uniformly, since the blobs allocated are predictably
small in most cases, and obmalloc is generally faster than system
mallocs then.

If extension modules in real life prove as sloppy as Python's front
end, we'll have to revert the objimpl.h + pymem.h part of this patch.
Note that no problems will show up in a debug build (all calls still go
thru obmalloc then). Problems will show up only in a release build, most
likely segfaults.
2006-03-26 23:27:58 +00:00
Hye-Shik Chang 04904faac5 Utilize %zd for Py_ssize_t formatting instead of casting to long. 2006-03-26 06:53:37 +00:00
Hye-Shik Chang 9f4b632212 Allow long objects as a position value of error callbacks returned. 2006-03-26 06:21:34 +00:00
Hye-Shik Chang e2ac4abd01 Patch #1443155: Add the incremental codecs support for CJK codecs.
(reviewed by Walter Dörwald)
2006-03-26 02:34:59 +00:00
Neal Norwitz 1818ed705b Try to fix broken compile on openbsd. 2006-03-26 00:29:48 +00:00
Thomas Heller bcfcccaf6e Fix some int/Py_ssize_t issues which led to compiler warnings
on 64-bit platforms.
2006-03-22 13:21:16 +00:00
Thomas Heller 59feb6f5cc Include <malloc.h> on windows, to avoid warnings when compiling with mingw.
Don't use SEH when compiling wth mingw.
Use IS_INTRESOURCE to determine function name from function ordinal.

Rewrite the code that allocates and frees callback functions, hopefully
this avoids the coverty warnings: Remove the THUNK typedef, and move the
definition of struct ffi_info into the header file.
2006-03-22 12:59:53 +00:00
Tim Peters 59b96c1029 Try to repair at least one segfault on the Mac buildbot,
as diagnosed by Nick Coghlan.

test_capi.py:  A test module should never spawn a thread as
a side effect of being imported.  Because this one did, the
segfault one of its thread tests caused didn't occur until
a few tests after test_regrtest.py thought test_capi was
finished.  Repair that.  Also join() the thread spawned
at the end, so that test_capi is truly finished when
regrtest reports that it's done.

_testcapimodule.c test_thread_state():  this spawns a
couple of non-threading.py threads, passing them a PyObject*
argument, but did nothing to ensure that those threads
finished before returning.  As a result, the PyObject*
_could_ (although this was unlikely) get decref'ed out of
existence before the threads got around to using it.
Added explicit synchronization (via a Python mutex) so
that test_thread_state can reliably wait for its spawned
threads to finish.
2006-03-21 03:58:41 +00:00
Thomas Heller e502693ee9 Avoid a potential double-free bug. 2006-03-20 14:22:05 +00:00
Thomas Heller ba29e4c573 Apply patch from Martin v. Loewis: Avoid function pointer casts.
https://sourceforge.net/tracker/?func=detail&atid=532156&aid=1453037&group_id=71702
2006-03-20 10:22:42 +00:00
Neal Norwitz 9b00a56464 Damn Coverity. I can't even sneak in a leak any more. :-) 2006-03-20 08:47:12 +00:00
Thomas Heller 711e7f00ca Fix another bug found by Coverty. 2006-03-20 08:29:28 +00:00
Thomas Heller e2061dc48e Fix bug found by Coverty. 2006-03-20 08:28:19 +00:00
Thomas Heller d59ca8f335 Accessing unaligned structure fields works now on all architectures.
Including unittest.
2006-03-20 07:54:01 +00:00
Neal Norwitz 6c2f913805 The helper is only necessary for wait3/4. 2006-03-20 07:25:26 +00:00
Neal Norwitz d5a375496e Try to cleanup a lot of boilerplate #ifdef wrt wait types and make the code
more consistent (and smaller by 85 lines or so).
2006-03-20 06:48:34 +00:00
Neal Norwitz 49c65d022f Make some functions static, reformat function decl to be consistent and check for error from PyModule_GetDict() 2006-03-20 06:34:06 +00:00
Neal Norwitz 05a45599d7 Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
This was a fair amount of rework of the patch.  Refactored test_fork1 so it
could be reused by the new tests for wait3/4.  Also made them into new style
unittests (derive from unittest.TestCase).
2006-03-20 06:30:08 +00:00
Anthony Baxter 17471432ec replace use of int16_t with a (typedef'd) short, to fix Windows buildbots.
expand tabs.
2006-03-20 05:58:21 +00:00
Anthony Baxter fa86907aae SF [ 1231053 ] audioop - alaw encoding/decoding added, code updated
This patch adds a-LAW encoding to audioop and replaces the old
u-LAW encoding/decoding code with the current code from sox.

Possible issues: the code from sox uses int16_t.

Code by Lars Immisch
2006-03-20 05:21:58 +00:00
Neal Norwitz d1e0ef68fb SF #1445431, fix some leaks in error conditions. 2006-03-20 04:08:12 +00:00
Neal Norwitz d5b0c9b87e Fix problem spotted by Coverity that occurs if tzinfo.tzname().replace()
returns a non-string when converting %Z.

Will backport.
2006-03-20 01:58:39 +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
Walter Dörwald 9ae019bf5b Add tests for the C APIs PyCodec_IncrementalEncoder() and
PyCodec_IncrementalDecoder().
2006-03-18 14:22:26 +00:00
Thomas Heller f4063ca8bc Fix compiler warning. 2006-03-18 12:52:54 +00:00
Georg Brandl bc45a3f821 RFE #567972: Socket objects' family, type and proto properties are
now exposed via new get...() methods.
2006-03-17 19:17:34 +00:00
Georg Brandl 5c170fd4a9 Fix some missing checks after PyTuple_New, PyList_New, PyDict_New 2006-03-17 19:03:25 +00:00
Thomas Heller b03cb602e8 Merge changes from the upstream version:
- cast is implemented as a foreign function now
- On Windows, it is now possible to access functions exported by ordinal only
2006-03-17 15:52:58 +00:00
Thomas Heller 0c6b0e9d05 Fix a leak that would happen under error conditions (found by Coverty). 2006-03-16 20:02:36 +00:00
Thomas Heller aa47570bdf Use int 0 as default defval for LCID if nothing has been supplied. 2006-03-16 19:56:24 +00:00
Thomas Heller b2167614f8 Fix compiler warning. 2006-03-16 19:34:56 +00:00
Thomas Heller 4c9dfc86f3 Fixes from Neal Norwitz, plus other small fixes. 2006-03-16 19:26:21 +00:00
Thomas Heller 127551637b Rewrite the AllocFunctionCallback function for better error handling.
Hope that fixes one or two Coverty warnings.
2006-03-16 19:24:27 +00:00
Neal Norwitz 10be10cbe7 Remove regsub, reconvert, regex, regex_syntax and everything under lib-old. 2006-03-16 06:50:13 +00:00
Neal Norwitz 94a9c09e10 Rename sre.py -> re.py 2006-03-16 06:30:02 +00:00
Walter Dörwald 197e8321c6 SF patch #1359365: cStringIO.StringIO.isatty() will raise a ValueError
now if close() has been called before (like file and StringIO.StringIO do)
2006-03-15 22:13:13 +00:00
Thomas Heller 9998f78d6d Backport from upstream version: compatibility with older Python
versions.
2006-03-15 21:49:52 +00:00
Nick Coghlan e2ebb2d7f7 Implement PEP 338 which has been marked as accepted by GvR 2006-03-15 11:00:26 +00:00
Tim Peters 8ea61f1a83 Revert rev 43041, which introduced the "z" format qualifier
unique to Python 2.5.
2006-03-15 09:17:20 +00:00
Tim Peters ab8aeba517 CField_repr(): PyString_FromFormat() understands the
C99 "z" qualifier on all platforms.
2006-03-15 08:41:15 +00:00
Neal Norwitz 4a53dadc3e Move test code out of xxmodule and into _testcapimodule.c where it belongs.
Will backport.
2006-03-15 05:43:10 +00:00
Thomas Heller 915d7773e2 Try to avoid many of the compiler warnings when compiling libffi by
using a proper function prototype.
2006-03-14 20:52:24 +00:00
Thomas Heller ab906a562b Cast an Py_ssize_t to int, to avoid a compiler warning. 2006-03-14 20:39:27 +00:00
Thomas Heller fe8f862cda Integrate patch from Neal Norwitz. He writes:
"""
The attached patch fixes all the ctypes tests so they pass on amd64.
It also fixes several warnings.  I'm not sure what else to do with the
patch.  Let me know how you want to handle these in the future.

I'm not sure the patch is 100% correct.  You will need to decide what
can be 64 bits and what can't.  I believe
sq_{item,slice,ass_item,ass_slice} all need to use Py_ssize_t.  The
types in ctypes.h may not require all the changes I made.  I don't
know how you want to support older version, so I unconditionally
changed the types to Py_ssize_t.
"""

The patch is also in the ctypes SVN repository now, after small
changes to add compatibility with older Python versions.
2006-03-14 19:53:09 +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
Hye-Shik Chang abb903fd54 Bug #1448490: Fix a bug that ISO-2022 codecs could not handle
SS2 (single-shift 2) escape sequences correctly.
2006-03-13 10:20:08 +00:00
Fredrik Lundh 44ed4db955 merged with cElementTree development trunk (1.0.6 snapshot):
Fixed a number of potential null-pointer-reference-under-pressure
glitches, based on input from the Coverity analysis tool and Simo
Salminen.
2006-03-12 21:06:35 +00:00
Thomas Wouters b2820ae355 Fix another leak in bsddb, and avoid use of uninitialized value -- funny how
gcc 4.0.x wasn't complaining about *that* one ;)
2006-03-12 00:01:38 +00:00
Martin v. Löwis c350912990 Adjust CJK Ideograph range to Unicode 4.1. 2006-03-11 12:16:23 +00:00
Martin v. Löwis 0e2f9b2dfb Fix refcounting bug. 2006-03-10 11:29:32 +00:00
Martin v. Löwis 5bd7c02298 Avoid forward-declaring the methods array.
Rename unicodedata.db* to unicodedata.ucd*
2006-03-10 11:20:04 +00:00
Guido van Rossum f669436189 Um, I thought I'd already checked this in.
Anyway, this is the changes to the with-statement
so that __exit__ must return a true value in order
for a pending exception to be ignored.
The PEP (343) is already updated.
2006-03-10 02:28:35 +00:00
Martin v. Löwis 480f1bb67b Update Unicode database to Unicode 4.1. 2006-03-09 23:38:20 +00:00
Neal Norwitz 72c2c062d7 Try to be a bit more consistent on all platforms:
python .
  python < .

both print a message, return non-zero and do not core dump.
2006-03-09 05:58:11 +00:00
Thomas Heller d4c9320412 Copy ctypes-0.9.9.4 sources from external into the trunk. 2006-03-08 19:35:11 +00:00
Georg Brandl f3c4ad1410 typo 2006-03-08 12:24:33 +00:00
Neal Norwitz 2f5e9903a0 Fix logic error and DECREF reported by Coverity. 2006-03-08 06:36:45 +00:00
Thomas Wouters b3153832c2 Clean up _bsddb.c: add a couple dozen missing Py_DECREF()'s, a handful of
missing PyObject_Del()'s, simplify some code by using Py_BuildValue()
instead of creating a tuple with items manually, stop clobbering builtin
exceptions in a few places, and guard against NULL-returning functions some
more.

This fixes 117 of the 780 (!?!#%@#$!!) reference leaks in test_bsddb3. I
ain't not done yet, although this review of 5kloc was just the easy part.
2006-03-08 01:47:19 +00:00
Martin v. Löwis e920f0d340 Reformulate 42903 using an if statement. 2006-03-07 23:59:33 +00:00
Tim Peters df44ab7b1c _hotshot hotshot_profiler(): If write_header() returned
an error code, this let `self` leak.  This is a disaster
on Windows, since `self` already points to a newly-opened
file object, and it was impossible for Python code to
close the thing since the only reference to it was in a
blob of leaked C memory.

test_hotshot test_bad_sys_path():  This new test provoked
the C bug above.  This test passed, but left an open
"@test" file behind, which caused a massive cascade of
bogus test failures in later, unrelated tests on Windows.
Changed the test code to remove the @test file it leaves
behind, which relies on the change above to close that
file first.
2006-03-07 23:53:32 +00:00
Georg Brandl 516999e6e2 Fix bug introduced in rev. 42884. 2006-03-07 20:56:02 +00:00
Guido van Rossum 38fff8c4e4 Checking in the code for PEP 357.
This was mostly written by Travis Oliphant.
I've inspected it all; Neal Norwitz and MvL have also looked at it
(in an earlier incarnation).
2006-03-07 18:50:55 +00:00
Hye-Shik Chang 4af5c8cee4 SF #1444030: Fix several potential defects found by Coverity.
(reviewed by Neal Norwitz)
2006-03-07 15:39:21 +00:00
Georg Brandl ef1701f7d3 Add additional missing checks for return vals of PyTuple_New().
Normalize coding style.
2006-03-07 14:57:48 +00:00
Thomas Wouters 89ba38152d Fix gcc 4.0.x warning about use of uninitialized value. 2006-03-07 14:14:51 +00:00
Thomas Wouters 098f6943c0 Coverity found bug: test result of PyTuple_New() against NULL before use.
Will backport.
2006-03-07 14:13:17 +00:00
Thomas Wouters a74a84d4cb Coverity found refleak: need to free 'v' after calling Tkinter_Error().
Will backport to release24.
2006-03-07 14:04:31 +00:00
Thomas Wouters 47f003d326 Coverity-found bug: don't use temp->next *before* checking it for NULL. Also
return rather than use it again.
2006-03-07 13:38:14 +00:00
Georg Brandl 622927b850 Bug #1432525: os.listdir now releases the GIL while calling
readdir().
2006-03-07 12:48:03 +00:00
Martin v. Löwis 725507b52e Change int to Py_ssize_t in several places.
Add (int) casts to silence compiler warnings.
Raise Python exceptions for overflows.
2006-03-07 12:08:51 +00:00
Thomas Wouters 8eb8a829c1 Don't DECREF a borrowed reference. 2006-03-07 11:58:50 +00:00
Barry Warsaw d3c38ff7f8 SF patch #1443865; gc.get_count() added and optional argument 'generation'
added to gc.collect().  Updated docs, unit test, and NEWS entry.

(Also, fixed a typo in NEWS.)
2006-03-07 09:46:03 +00:00
Neal Norwitz 60da31660c Thanks to Coverity, these were all reported by their Prevent tool.
All of these (except _lsprof.c) should be backported.  Particularly
the hotshot change which validates sys.path.  Can someone backport?
2006-03-07 04:48:24 +00:00
Neal Norwitz e22373d690 Fix warnings on x86 (32-bit) and support Win64. 2006-03-06 23:31:56 +00:00
Hye-Shik Chang 32feb8592f Check NULL if Py_InitModule fails. 2006-03-06 07:51:19 +00:00
Neal Norwitz 7b216c52e4 Make PyGC_Collect() use Py_ssize_t. 2006-03-04 20:01:53 +00:00
Hye-Shik Chang 4b96c1384e - Modernize code to use Py_ssize_t more intensively.
- Do some minor code clean-ups.
2006-03-04 16:08:19 +00:00
Thomas Wouters 857b300b2e Explain why we use the unsigned int format for a signed int variable.
(Should 'code' be cast to the right pointer type?)
2006-03-02 17:58:27 +00:00
Thomas Wouters 83d1266cbd Properly fix Py_SAFE_DOWNCAST-triggerd bugs. 2006-03-02 05:05:17 +00:00
Thomas Wouters 369092be43 Py_SAFE_DOWNCAST isn't quite doing the right thing for going from Py_ssize_t
to an unsigned int (and back again) on 64-bit machines, even though the
actual value of the Py_ssize_t variable is way below 31 bits. I suspect
compiler-error.
2006-03-02 04:48:27 +00:00
Thomas Wouters 26cc63f867 Make Py_ssize_t-clean 2006-03-02 00:21:10 +00:00
Martin v. Löwis 5df2e614e6 Remove UNLESS. 2006-03-01 23:10:49 +00:00
Thomas Wouters 7087f78dbe Use Py_ssize_t for arithmetic on Py_ssize_t's, instead of unsigned ints. 2006-03-01 23:10:05 +00:00
Thomas Wouters a5fa2a8a13 Fix gcc (4.0.x) warning about use of uninitialized variable. 2006-03-01 22:54:36 +00:00
Martin v. Löwis 49c5da1d88 Patch #1440601: Add col_offset attribute to AST nodes. 2006-03-01 22:49:05 +00:00
Thomas Wouters 3ffa59b137 Rework channelnumber/samplesize detetion code's output variables a bit to
convince gcc (4.0.x) the variables are never used uninitialized (and raising
a proper exception if they ever are.)
2006-03-01 22:45:36 +00:00
Thomas Wouters f86d1e810d Silence gcc (4.0.x) warning about use of uninitialized value. 2006-03-01 22:15:15 +00:00
Thomas Wouters 9c54448715 Fix brainfart. 2006-03-01 21:59:44 +00:00
Thomas Wouters 1e365b265a Remove gcc (4.0.x) warning about uninitialized value by explicitly setting
the sentinel value in the main function, rather than the helper. This
function could possibly do with an early-out if any of the helper calls ends
up with a len of 0, but I doubt it really matters (how common are malformed
hangul syllables, really?)
2006-03-01 21:58:30 +00:00
Thomas Wouters 9bc844e7be Make Py_ssize_t-clean. 2006-03-01 21:50:07 +00:00
Thomas Wouters f98db65e52 Make Py_ssize_t-clean. 2006-03-01 21:37:32 +00:00
Martin v. Löwis 6db0e00d57 Change GC refcount to Py_ssize_t. 2006-03-01 16:56:25 +00:00
Tim Peters 67d70eb957 Repair mangled code in the Windows flavor of
posix__getfullpathname().

In partial answer to the now-deleted XXX comment:

	/* XXX(twouters) Why use 'et#' here at all? insize isn't used */

`insize` is an input parameter too, and it was left uninitialized,
leading to seemingly random failures.
2006-03-01 04:35:45 +00:00
Thomas Wouters 68bc4f9ae5 Py_ssize_t-ify. 2006-03-01 01:05:10 +00:00
Thomas Wouters 9d63ccae90 Fix DBEnv's set_tx_timestamp wrapper to be slightly more correct on
non-32bit platforms. Will still only allow 32 bits in a timestamp on Win64,
but at least it won't crash, and it'll work right on platforms where longs
are big enough to contain time_t's.

(A better-working, although conceptually less-right fix would have been to
use Py_ssize_t here, but Martin and Tim won't let me.)
2006-03-01 01:01:55 +00:00
Guido van Rossum 1a5e21e033 Updates to the with-statement:
- New semantics for __exit__() -- it must re-raise the exception
  if type is not None; the with-statement itself doesn't do this.
  (See the updated PEP for motivation.)

- Added context managers to:
  - file
  - thread.LockType
  - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore}
  - decimal.Context

- Added contextlib.py, which defines @contextmanager, nested(), closing().

- Unit tests all around; bot no docs yet.
2006-02-28 21:57:43 +00:00
Tim Peters 85b1052efe Another bit of unconstification. 2006-02-28 18:33:35 +00:00
Thomas Wouters f7f438ba3b SF patch #1438387, PEP 328: relative and absolute imports.
- IMPORT_NAME takes an extra argument from the stack: the relativeness of
   the import. Only passed to __import__ when it's not -1.

 - __import__() takes an optional 5th argument for the same thing; it
   __defaults to -1 (old semantics: try relative, then absolute)

 - 'from . import name' imports name (be it module or regular attribute)
   from the current module's *package*. Likewise, 'from .module import name'
   will import name from a sibling to the current module.

 - Importing from outside a package is not allowed; 'from . import sys' in a
   toplevel module will not work, nor will 'from .. import sys' in a
   (single-level) package.

 - 'from __future__ import absolute_import' will turn on the new semantics
   for import and from-import: imports will be absolute, except for
   from-import with dots.

Includes tests for regular imports and importhooks, parser changes and a
NEWS item, but no compiler-package changes or documentation changes.
2006-02-28 16:09:29 +00:00
Martin v. Löwis 1d519e4625 unconst. 2006-02-27 23:10:11 +00:00
Thomas Wouters b9eb5510e6 Convert array.array.insert to use Py_ssize_t (like the rest already does.) 2006-02-27 19:44:56 +00:00
Martin v. Löwis 02cbf4ae4b More unconsting. 2006-02-27 17:20:04 +00:00
Martin v. Löwis b79afb6e3a unconst. 2006-02-27 17:01:22 +00:00
Martin v. Löwis 15e62742fa Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
Thomas Wouters e2dd78c760 Update for PEP 308 patch. 2006-02-27 16:25:11 +00:00
Martin v. Löwis 577b5b960d Create _ast module.
Cleanup Python-ast.c generation.
2006-02-27 15:23:19 +00:00
Guido van Rossum 1968ad32cd - Patch 1433928:
- The copy module now "copies" function objects (as atomic objects).
  - dict.__getitem__ now looks for a __missing__ hook before raising
    KeyError.
  - Added a new type, defaultdict, to the collections module.
    This uses the new __missing__ hook behavior added to dict (see above).
2006-02-25 22:38:04 +00:00
Georg Brandl c2fb6c74c6 Fix typo in functional module 2006-02-21 17:49:57 +00:00
Guido van Rossum 668a94a34f NETLINK_TCPDIAG and NETLINK_NFLOG aren't defined on older Linux
systems; define these conditionally.
2006-02-21 01:07:27 +00:00
Georg Brandl e393bf6fe3 Patch #931938: prevent setting sys.prefix to "" 2006-02-20 17:37:36 +00:00
Georg Brandl dbd8339a01 Bug #854823: socketmodule now builds on Sun platforms even when
INET_ADDRSTRLEN is not defined.
2006-02-20 09:42:33 +00:00
Hye-Shik Chang d69e034571 Fix a build problem introduced by r42230. 2006-02-19 16:22:22 +00:00
Georg Brandl e810fe2ca4 Remove two instances of trailing commas. Resolves patch #1209781. 2006-02-19 15:28:47 +00:00
Georg Brandl e9b1949f70 Patch #1352711: make zipimport raise a complete IOError 2006-02-19 09:38:58 +00:00
Neal Norwitz 093ab1aa03 Remove unused variable 2006-02-18 23:26:27 +00:00
Georg Brandl f4f4415a18 Patch #1393157: os.startfile() now has an optional argument to specify
a "command verb" to invoke on the file.
2006-02-18 22:29:33 +00:00
Georg Brandl 47fab92542 Bug #1366000: cleanup BZ2File.seek() logic. Fixes the case of whence=2, offset>=0. 2006-02-18 21:57:25 +00:00
Martin v. Löwis 5bb8a15593 Fix typo. 2006-02-18 12:49:49 +00:00
Martin v. Löwis 151860752f Fix size computation on Win64. 2006-02-18 12:38:35 +00:00
Martin v. Löwis 5c97c798d2 Make ssize_t-clean. 2006-02-17 15:49:09 +00:00
Georg Brandl b86a54f395 Add deprecation warning to modules deprecated since 2000. 2006-02-17 11:29:04 +00:00
Thomas Wouters 2c98a7bbc6 Fix typo. 2006-02-17 09:59:00 +00:00
Georg Brandl 1b6726732c Bug #1432350: arrayobject should use PyObject_VAR_HEAD 2006-02-17 08:56:33 +00:00
Martin v. Löwis cfe7e0912c Remove size restrictions. 2006-02-17 06:59:14 +00:00
Tim Peters f28829577d mmap_flush_method(): Squash compiler warning about
mixing signed and unsigned types in comparison.
2006-02-17 01:07:39 +00:00
Tim Peters 8f9cc29e74 Remove space between function name and left paren
in function calls.
2006-02-17 00:00:20 +00:00
Tim Peters 23721ee96c Removed pointless parens around `return` expressions;
deleted some curlies around one-line blocks.
2006-02-16 23:50:16 +00:00
Tim Peters ec0a5f0add Trimmed trailing whitespace. 2006-02-16 23:47:20 +00:00
Tim Peters e564e7f939 new_mmap_object(), Windows flavor.
On a box where sizeof(size_t) == 4, C doesn't define
what happens when a size_t value is shifted right by
32 bits, and this caused test_mmap to fail on Windows
in a debug build.  So use different code to break
the size apart depending on how large size_t actually
is.

This looks like an illusion, since lots of code in this
module still appears to assume sizes can't be more
than 32 bits (e.g., the internal _GetMapSize() still
returns an int), but at least test_mmap passes again.
2006-02-16 23:46:01 +00:00
Thomas Wouters dde176593d More Py_ssize_t format characters. 2006-02-16 21:10:52 +00:00
Tim Peters 2ad8c56e6c struct_pack(): Repair new assert-fail crash in
debug-build test_struct on a box where plain "char"
is signed.
2006-02-16 20:19:46 +00:00
Thomas Wouters 13870b18f2 Also make _heapq.nlargest() use Py_ssize_t instead of ints, to iter over
lists and call Py_ssize_t-using helpers. All other code in this module was
already adapted to Py_ssize_t.
2006-02-16 19:21:53 +00:00
Thomas Wouters ed6254acf2 Use 'n' format for Py_ssize_t variables to PyArg_ParseTuple(). Py_ssize_t
has been applied fairly arbitrarily in this module (nsmallest uses
Py_ssize_t, nlargest does not) and it probably deserves a more complete
review. Fixes heapq.nsmallest() always returning the empty list (on
platforms with 64-bit ssize_t/long)
2006-02-16 17:32:54 +00:00
Thomas Wouters 7a2f83b706 Use correct format specifier for Py_ssize_t variable to PyArg_ParseTuple(). 2006-02-16 17:07:41 +00:00
Martin v. Löwis 41290685f9 Change _PyObject_GC_Resize to expect Py_ssize_t. 2006-02-16 14:56:14 +00:00
Martin v. Löwis ad0a4629be Use Py_ssize_t for counts and sizes. 2006-02-16 14:30:23 +00:00
Neal Norwitz 3eaf2b5044 Update comment and make accurate. 2006-02-16 08:08:54 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Tim Peters 219c164a47 randombits(): Stop compiler warning about mixing
signed with unsigned types in comparison.
2006-02-15 03:01:30 +00:00
Neal Norwitz 389cea8efc Try to improve name based on discussion on python-checkins with Jim Jewett 2006-02-13 00:35:21 +00:00
Armin Rigo f5b3e36493 Renamed _length_cue() to __length_hint__(). See:
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2006-02-11 21:32:43 +00:00
Martin v. Löwis f84d1b9375 Introduce Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE.
Proposed by Tim Peters.
2006-02-11 09:27:05 +00:00
Armin Rigo 2bc23f512d The default timer unit was incorrectly measured in milliseconds instead
of seconds, producing numbers 1000 times too large.  It would be nice to
write a test for this, but how...  (thanks mwh)
2006-02-10 13:19:53 +00:00
Armin Rigo a871ef2b3e Added the cProfile module.
Based on lsprof (patch #1212837) by Brett Rosen and Ted Czotter.
With further editing by Michael Hudson and myself.
History in svn repo: http://codespeak.net/svn/user/arigo/hack/misc/lsprof

* Module/_lsprof.c is the internal C module, Lib/cProfile.py a wrapper.
* pstats.py updated to display cProfile's caller/callee timings if available.
* setup.py and NEWS updated.
* documentation updates in the profiler section:
   - explain the differences between the three profilers that we have now
   - profile and cProfile can use a unified documentation, like (c)Pickle
   - mention that hotshot is "for specialized usage" now
   - removed references to the "old profiler" that no longer exists
* test updates:
   - extended test_profile to cover delicate cases like recursion
   - added tests for the caller/callee displays
   - added test_cProfile, performing the same tests for cProfile
* TO-DO:
   - cProfile gives a nicer name to built-in, particularly built-in methods,
     which could be backported to profile.
   - not tested on Windows recently!
2006-02-08 12:53:56 +00:00
Neal Norwitz 082b2df33f Bug #876637, prevent stack corruption when socket descriptor
is larger than FD_SETSIZE.

This can only be acheived with ulimit -n SOME_NUMBER_BIGGER_THAN_FD_SETSIZE
which is typically only available to root.  Since this wouldn't normally
be run in a test (ie, run as root), it doesn't seem too worthwhile to
add a normal test.  The bug report has one version of a test.  I've
written another.  Not sure what the best thing to do is.

Do the check before calling internal_select() because we can't set
an error in between Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS.
This seemed the clearest solution, ie handle before calling internal_select()
rather than inside.  Plus there is at least one place outside
of internal_select() that needed to be handled.

Will backport.
2006-02-07 07:04:46 +00:00
Neal Norwitz 19cbcad20e Fix indentation (whitespace only). 2006-02-07 06:59:20 +00:00
Neal Norwitz 02876df9de Check return results for errors 2006-02-07 06:58:52 +00:00
Neal Norwitz 0e6bc8c260 Patch #1407135, bug #1424041, make mmap.mmap(-1, length) work the same
on both Unix (SVR4 and BSD) and Windows.  Restores behaviour of passing -1
for anonymous memory on Unix.  Use MAP_ANONYMOUS instead of _ANON since
the latter is deprecated according to Linux (gentoo) man pages.

Should we continue to allow mmap.mmap(0, length) to work on Windows?
0 is a valid fd.

Will backport bugfix portions.
2006-02-05 05:45:43 +00:00
Neal Norwitz d1cfc8ade1 Whitespace normalization 2006-02-05 03:36:57 +00:00
Martin v. Löwis 57a34e8026 Patch #1422385: Changes to nis module to support multiple NIS domains 2006-02-04 19:12:37 +00:00
Martin v. Löwis 14694662d5 Drop C library for stat/fstat on Windows. 2006-02-03 12:54:16 +00:00
Gregory P. Smith fd049a696d maintain support for older python versions in this module so that it
is ok for a standalone pybsddb source dist for use with <= 2.3.
2006-01-30 00:22:08 +00:00