I'm always daunted by the prospect of trying to implement file locking.
This just came up again in SpamBayes where we have never protected our
pickle files from corruption when multiple processes access them
simultaneously. The presence of networked file systems and
platform-independent locks make it a nasty little problem. Maybe I'm just
showing my age. Does fcntl.flock work over NFS and SMB and on Windows? If
this is still as much of a mess as I remember, should Python provide a
simple file locking module in the standard distribution?
Side note: While reading the fcntl man page on my Mac I came across this
text in the description of F_GETLK/F_SETLK/F_SETLKW.
This interface follows the completely stupid semantics of System V and
IEEE Std 1003.1-1988 (``POSIX.1'') that require that all locks
associated with a file for a given process are removed when any file
descriptor for that file is closed by that process.... Flock(2) is
recommended for applications that want to ensure the integrity of their
locks when using library routines or wish to pass locks to their
I guess the BSD folks were a bit upset when they wrote that.
At 11:09 AM 10/31/2007 -0700, Guido van Rossum wrote:
>Yes, though I think that if prop.fdel is None, we could use func in
Eh? Isn't prop.fdel supposed to be a single-argument function? ISTM
that C is the only place where fset and fdel are the same thing.
> I'd like to make this [propset] a standard built-in,
+1 -- I find this to be an attractive syntax
> I'd also like to change property so that the doc
> string defaults to the doc string of the getter.
+1 -- This should also be done for classmethod,
staticmethod, and anything else that wraps functions.
Alternatively, the doc string could be made a little
__doc__ = 'property of function %s: %s' % (f.__name__, f.__doc__)
> I'm not sure about the name "propset" ...
>Maybe something like "setproperty" would be better.
I think not. Saying "setproperty" has too many ambiguous mental parsings. When does "set" take place -- assigning a value to a property is different defining the property itself. Is "set" a verb so that we're talking about a property of sets/frozensets. Is "set" a completed action so that the property has been set.
Let's stick with "propset" which has precedent as an svn action and serves as a short, simple mnemonic to the functionality.
Also, I find that these unique words are easier to search for. I once co-owned a magazine called Know Your Boston and it was very difficult for clients to find using Google.
I'm following the issue 1259 (http://bugs.python.org/issue1259)
It basically says that this should be ok: "'asd'.find('s', None,
None)", as the documentation says that "start" and "end" arguments
behaves like in slices (right now it gives a TypeError).
I created a patch, that solves the problem presented in that patch, as
is suggested by Barry A. Warsaw.
The patch touches three files:
- Lib/test/string_tests.py: The test cases for this.
- Objects/stringobject.c: Here I modified the string_find_internal()
function, for PyArg_ParseTuple to not call directly to
PyEval_SliceIndex: I just call it if the function received an argument
and is not None.
- Objects/unicodeobject.c: Here I needed to make the same in
unicode_find(), unicode_rfind(), unicode_index(), and
unicode_rindex(), so I created another function called
_ParseTupleFinds(), for this family of functions, which handles the
arguments and returns the needed info for each function.
All the tests pass ok, I'm sending this mail to see if anybody could
please review the patch before I apply it, as this is the first patch
that I create in C. Feel free to ignore this mail if the patch is ok,