summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2010-08-26 12:47:17 +0000
committerBob Ippolito <bob@redivi.com>2010-08-26 12:47:17 +0000
commitdc1e4606324008cb3bf8cf127d63159030d610e3 (patch)
treed964350a0668ff493cff636788e20e13c39b8075
parent011c4a2df43c84bce41955dc0b15606effeb78f5 (diff)
downloadxattr-dc1e4606324008cb3bf8cf127d63159030d610e3.tar.gz
patch from Jim Wilcoxson to reduce calls to listxattrv0.6.1
-rw-r--r--setup.py4
-rw-r--r--xattr/__init__.py16
-rw-r--r--xattr/_xattr.c5
3 files changed, 21 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 8ee78c7..7b4ebeb 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ ez_setup.use_setuptools()
from setuptools import setup, Extension
-VERSION = '0.5'
+VERSION = '0.6.1'
DESCRIPTION = "Python wrapper for extended filesystem attributes"
LONG_DESCRIPTION = """
Extended attributes extend the basic attributes of files and directories
@@ -24,7 +24,7 @@ License :: OSI Approved :: MIT License
Natural Language :: English
Operating System :: MacOS :: MacOS X
Operating System :: POSIX :: Linux
-Operating System :: POSIX :: FreeBSD
+Operating System :: POSIX :: BSD :: FreeBSD
Programming Language :: Python
Topic :: Software Development :: Libraries :: Python Modules
""".splitlines()))
diff --git a/xattr/__init__.py b/xattr/__init__.py
index 3a85acf..3ec0ff3 100644
--- a/xattr/__init__.py
+++ b/xattr/__init__.py
@@ -7,10 +7,22 @@ The xattr type wraps a path or file descriptor with a dict-like interface
that exposes these extended attributes.
"""
-__version__ = '0.5'
-from constants import *
+__version__ = '0.6.1'
+from constants import XATTR_NOFOLLOW, XATTR_CREATE, XATTR_REPLACE, \
+ XATTR_NOSECURITY, XATTR_MAXNAMELEN, XATTR_FINDERINFO_NAME, \
+ XATTR_RESOURCEFORK_NAME
+
import _xattr
+def _pyflakes_api():
+ # trick pyflakes into thinking these are used.
+ return [
+ XATTR_NOFOLLOW, XATTR_CREATE, XATTR_REPLACE,
+ XATTR_NOSECURITY, XATTR_MAXNAMELEN, XATTR_FINDERINFO_NAME,
+ XATTR_RESOURCEFORK_NAME,
+ ]
+
+
def _boundfunc(func, first):
def _func(*args):
return func(first, *args)
diff --git a/xattr/_xattr.c b/xattr/_xattr.c
index 59ee0b1..e162c92 100644
--- a/xattr/_xattr.c
+++ b/xattr/_xattr.c
@@ -848,6 +848,11 @@ py_listxattr(PyObject* self __attribute__((__unused__)), PyObject *args) /* , Py
PyMem_Free(path);
return NULL;
}
+ /* avoid 2nd listxattr call if the first one returns 0 */
+ if (res == 0) {
+ PyMem_Free(path);
+ return buffer;
+ }
Py_BEGIN_ALLOW_THREADS
res = xattr_listxattr((const char *)path, (void *)PyString_AS_STRING(buffer), (size_t)PyString_GET_SIZE(buffer), options);
Py_END_ALLOW_THREADS