Commit Graph

95 Commits

Author SHA1 Message Date
Neal Norwitz 448654f1f8 Mostly reformat. Also set an error and return NULL if neither MS_WINDOWS
nor UNIX is defined.  This may have caused problems on cygwin.
2008-01-27 07:36:03 +00:00
Neal Norwitz 739a3c40e6 Cleanup the code a bit. test_rfind is failing on PPC and PPC64 buildbots,
this might fix the problem.
2008-01-26 20:24:36 +00:00
Christian Heimes 501dbbfb70 Use Py_TYPE() instead of ->ob_type 2008-01-23 14:00:25 +00:00
Georg Brandl d02fc48f67 Fix for #1087741 patch. 2008-01-22 19:56:03 +00:00
Georg Brandl 845c403c08 #1087741: make mmap.mmap the type of mmap objects, not a
factory function. Allow it to be subclassed.
2008-01-21 14:16:46 +00:00
Georg Brandl ef92802f73 Switch mmap from old Py_FindMethod to new PyObject_GenericGetAttr attribute access.
Fixes #1087735.
2008-01-20 14:50:05 +00:00
Andrew M. Kuchling 5c60bfcfbf Patch #976880: add mmap .rfind() method, and 'end' paramter to .find().
Contributed by John Lenton.
2008-01-19 18:18:41 +00:00
Andrew M. Kuchling 7c22ccc3dd Check for fd of -1 to save fsync() and fstat() call 2008-01-10 13:37:12 +00:00
Christian Heimes e93237dfcc #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available. 2007-12-19 02:37:44 +00:00
Neal Norwitz 9c4382f2a3 Fix some compiler warnings for signed comparisons on Unix and Windows. 2007-10-31 06:33:20 +00:00
Travis E. Oliphant 8feafab346 Add phuang patch from Issue 708374 which adds offset parameter to mmap module. 2007-10-23 02:40:56 +00:00
Thomas Wouters 3ccec68a05 Improve extended slicing support in builtin types and classes. Specifically:
- Specialcase extended slices that amount to a shallow copy the same way as
   is done for simple slices, in the tuple, string and unicode case.

 - Specialcase step-1 extended slices to optimize the common case for all
   involved types.

 - For lists, allow extended slice assignment of differing lengths as long
   as the step is 1. (Previously, 'l[:2:1] = []' failed even though
   'l[:2] = []' and 'l[:2:None] = []' do not.)

 - Implement extended slicing for buffer, array, structseq, mmap and
   UserString.UserString.

 - Implement slice-object support (but not non-step-1 slice assignment) for
   UserString.MutableString.

 - Add tests for all new functionality.
2007-08-28 15:28:19 +00:00
Martin v. Löwis 6819210b9e PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +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 5ed4997e1f Get rid of compiler warning 2006-08-13 18:41:15 +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
Martin v. Löwis 0e8bd7e1cc Patch #1495999: Part two of Windows CE changes.
- update header checks, using autoconf
- provide dummies for getenv, environ, and GetVersion
- adjust MSC_VER check in socketmodule.c
2006-06-10 12:23:46 +00:00
Georg Brandl 96a8c3954c Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
2006-05-29 21:04:52 +00:00
Georg Brandl 2cfaa34dfa Correct some value converting strangenesses. 2006-05-29 19:39:45 +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
Martin v. Löwis 02cbf4ae4b More unconsting. 2006-02-27 17:20:04 +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
Thomas Wouters 2c98a7bbc6 Fix typo. 2006-02-17 09:59:00 +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
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
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
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Neal Norwitz 3b4fff8079 Fix SF bug #1402308, segfault when using mmap(-1, ...)
This didn't crash on Linux, but valgrind complained.
I'm not sure if this test is valid on Windows.

Will backport.
2006-01-11 08:54:45 +00:00
Neal Norwitz 8856fb750b SF Patch #1365916, mmap fails on AMD64
Fix some 64-bit issues due to mismatch format characters w/actual data types
2005-12-18 03:34:22 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
In C++, it's an error to pass a string literal to a char* function
without a const_cast().  Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.

I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc.  Predictably, there were a large set of functions that
needed to be fixed as a result of these changes.  The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].

One cast was required as a result of the changes:  A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
2005-12-10 18:50:16 +00:00
Neal Norwitz 6eac2005bf Cleanup the previous checkin.
Close the fd in the close method and invalidated it.  Don't try
to close a second time when deallocating.
2005-11-02 05:36:37 +00:00
Neal Norwitz 7b631793ab Bug #1344508, Fix UNIX mmap leaking file descriptors. Will backport. 2005-11-02 05:26:07 +00:00
Armin Rigo 335ffe88bb C89 compliance. 2005-09-20 19:04:02 +00:00
Georg Brandl 38387b8b91 bug [ 728515 ] mmap's resize method resizes the file in win32 but not unix 2005-08-24 07:17:40 +00:00
Martin v. Löwis 7fe60c0a0a Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.
2005-03-03 11:22:44 +00:00
Andrew M. Kuchling 16581c8614 Set data pointer to NULL after an error; this keeps the mmap_dealloc() function from trying to do msync(-1);munmap(-1).
2.3 bugfix candidate, but this bug isn't critical enough that the fix has to go into 2.3.4
2004-05-19 14:39:08 +00:00
Skip Montanaro ce59c04127 Remove support for SunOS 4.
Remove BAD_EXEC_PROTOYPE (leftover from IRIX 4 demolition).
2004-01-17 14:19:44 +00:00
Andrew M. Kuchling a3016678ed [Patch #708374] Only apply the check for file size if the file is a regular file, not a character or block device. 2003-07-15 12:37:46 +00:00