diff options
author | Aurelien Campeas <aurelien.campeas@logilab.fr> | 2011-10-10 15:14:43 +0200 |
---|---|---|
committer | Aurelien Campeas <aurelien.campeas@logilab.fr> | 2011-10-10 15:14:43 +0200 |
commit | a1af8ab0eed9033e955bf69564e0c82fbb3cb30b (patch) | |
tree | 0c1986f1d66555e594d3bc6a4c42975c2719c21b | |
parent | aa6078e554d6c23ae6dc5746c762241fd5290616 (diff) | |
parent | 2d13963f897afc927f974de0370057bcf2113e62 (diff) | |
download | logilab-common-a1af8ab0eed9033e955bf69564e0c82fbb3cb30b.tar.gz |
backport stable
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | __pkginfo__.py | 5 | ||||
-rw-r--r-- | compat.py | 23 | ||||
-rw-r--r-- | daemon.py | 1 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | debian/control | 5 | ||||
-rw-r--r-- | decorators.py | 10 |
7 files changed, 41 insertions, 17 deletions
@@ -1,8 +1,12 @@ ChangeLog for logilab.common ============================ --- <default> - * daemon: remove unused(?) DaemonMixin class + -- +* only install unittest2 when python version < 2.7 (closes: #76068) +* daemon: make pidfile world-readable (closes #75968) +* daemon: remove unused(?) DaemonMixin class +* update compat module for callable() and method_type() +* decorators: fix monkeypatch py3k compat (closes #75290) 2011-09-08 -- 0.56.2 * daemon: call initgroups/setgid before setuid (closes #74173) diff --git a/__pkginfo__.py b/__pkginfo__.py index a8a937b..41761dc 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -17,6 +17,7 @@ # with logilab-common. If not, see <http://www.gnu.org/licenses/>. """logilab.common packaging information""" __docformat__ = "restructuredtext en" +import sys distname = 'logilab-common' modname = 'common' @@ -39,4 +40,6 @@ from os.path import join scripts = [join('bin', 'pytest')] include_dirs = [join('test', 'data')] -install_requires = ['unittest2 >= 0.5.1'] +if sys.version_info < (2, 7): + install_requires = ['unittest2 >= 0.5.1'] + @@ -20,7 +20,7 @@ 2.5, making them available in for earlier versions of python. See another compatibility snippets from other projects: - + :mod:`lib2to3.fixes` :mod:`coverage.backward` :mod:`unittest2.compatibility` @@ -32,6 +32,7 @@ __docformat__ = "restructuredtext en" import os import sys +import types from warnings import warn import __builtin__ as builtins # 2to3 will tranform '__builtin__' to 'builtins' @@ -50,14 +51,22 @@ else: def str_encode(string, encoding): return str(string) -# XXX shouldn't we remove this and just let 2to3 do his job ? +# XXX callable built-in seems back in all python versions try: - callable = callable -except NameError:# callable removed from py3k - import collections + callable = builtins.callable +except AttributeError: + from collections import Callable def callable(something): - return isinstance(something, collections.Callable) - del collections + return isinstance(something, Callable) + del Callable + +# See also http://bugs.python.org/issue11776 +if sys.version_info[0] == 3: + def method_type(callable, instance, klass): + return types.MethodType(callable, klass) +else: + # alias types otherwise + method_type = types.MethodType if sys.version_info < (3, 0): raw_input = raw_input @@ -92,6 +92,7 @@ def daemonize(pidfile=None, uid=None, umask=077): f = file(pidfile, 'w') f.write(str(os.getpid())) f.close() + os.chmod(pidfile, 0644) # change process uid if uid: setugid(uid) diff --git a/debian/changelog b/debian/changelog index 7a678d1..82d6b88 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +logilab-common (0.56.2-2) unstable; urgency=low + + * depends on python >= 2.5 + + -- David Douard <david.douard@logilab.fr> Wed, 21 Sep 2011 11:55:32 +0200 + logilab-common (0.56.2-1) unstable; urgency=low * new upstream release diff --git a/debian/control b/debian/control index a06507c..c9af5e5 100644 --- a/debian/control +++ b/debian/control @@ -4,13 +4,14 @@ Priority: optional Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org> Uploaders: David Douard <david.douard@logilab.fr>, Alexandre Fayolle <afayolle@debian.org>, + Alexandre Fayolle <alexandre.fayolle@logilab.fr>, Sandro Tosi <morph@debian.org>, Adrien Di Mascio <Adrien.DiMascio@logilab.fr>, Nicolas Chauvat <nicolas.chauvat@logilab.fr>, Julien Jehannet <julien.jehannet@debian.org>, -Build-Depends: debhelper (>= 5.0.38), python (>= 2.4.6-2) +Build-Depends: debhelper (>= 5.0.38), python (>= 2.5) Build-Depends-Indep: python-support, python-epydoc, graphviz, python-egenix-mxdatetime, python-unittest2 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Standards-Version: 3.9.1 Homepage: http://www.logilab.org/project/logilab-common Vcs-Svn: svn://svn.debian.org/svn/python-modules/packages/logilab-common/trunk/ diff --git a/decorators.py b/decorators.py index 7bb08fc..91d7492 100644 --- a/decorators.py +++ b/decorators.py @@ -18,10 +18,10 @@ """ A few useful function/method decorators. """ __docformat__ = "restructuredtext en" -import types -import sys, re from time import clock, time +from logilab.common.compat import callable, method_type + # XXX rewrite so we can use the decorator syntax when keyarg has to be specified def _is_generator_function(callableobj): @@ -175,8 +175,8 @@ class iclassmethod(object): self.func = func def __get__(self, instance, objtype): if instance is None: - return types.MethodType(self.func, objtype, objtype.__class__) - return types.MethodType(self.func, instance, objtype) + return method_type(self.func, objtype, objtype.__class__) + return method_type(self.func, instance, objtype) def __set__(self, instance, value): raise AttributeError("can't set attribute") @@ -234,7 +234,7 @@ def monkeypatch(klass, methodname=None): 'you should provide an explicit `methodname`' % func) if callable(func): - setattr(klass, name, types.MethodType(func, None, klass)) + setattr(klass, name, method_type(func, None, klass)) else: # likely a property # this is quite borderline but usage already in the wild ... |