From 36f08be034d8ca043f072d4010a00d6a605eb491 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Wed, 16 May 2012 01:19:58 +0200 Subject: [PATCH] Complete the change of namespace handling This disables None as a valid namespace under Python 2.x too; now only an empty string is accepted. The patch also documents the change. --- test/test_xattr.py | 6 ++++++ xattr.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/test_xattr.py b/test/test_xattr.py index 4c0c0bc..8df00b9 100644 --- a/test/test_xattr.py +++ b/test/test_xattr.py @@ -363,5 +363,11 @@ class xattrTest(unittest.TestCase): self.assertEqual(xattr.get_all(fh, namespace=NS_USER), [(self.USER_NN, self.USER_VAL)]) + def testNoneNamespace(self): + fh, fname = self._getfile() + self.assertRaises(TypeError, xattr.get, fh, self.USER_ATTR, + namespace=None) + + if __name__ == "__main__": unittest.main() diff --git a/xattr.c b/xattr.c index b6bead0..70dcc4f 100644 --- a/xattr.c +++ b/xattr.c @@ -36,7 +36,7 @@ typedef int Py_ssize_t; #define IS_PY3K #define BYTES_CHAR "y" #else -#define BYTES_CHAR "z" +#define BYTES_CHAR "s" #define PyBytes_Check PyString_Check #define PyBytes_AS_STRING PyString_AS_STRING #define PyBytes_FromStringAndSize PyString_FromStringAndSize @@ -86,6 +86,12 @@ typedef int Py_ssize_t; " giving an error if it doesn't exist;\n" \ ":type flags: integer\n" +#define NS_CHANGED_DOC \ + ".. versionchanged:: 0.5.1\n" \ + " The namespace argument, if passed, cannot be None anymore; to\n" \ + " explicitly specify an empty namespace, pass an empty\n" \ + " string (byte string under Python 3)." + /* the estimated (startup) attribute buffer size in multi-operations */ @@ -327,6 +333,7 @@ static char __get_doc__[] = ":raises EnvironmentError: caused by any system errors\n" "\n" ".. versionadded:: 0.4\n" + NS_CHANGED_DOC ; static PyObject * @@ -427,6 +434,7 @@ static char __get_all_doc__[] = " attribute names and that were still present when the read\n" " attempt for the value is made.\n" ".. versionadded:: 0.4\n" + NS_CHANGED_DOC ; static PyObject * @@ -640,6 +648,7 @@ static char __set_doc__[] = ":raises EnvironmentError: caused by any system errors\n" "\n" ".. versionadded:: 0.4\n" + NS_CHANGED_DOC ; /* Wrapper for setxattr */ @@ -766,6 +775,7 @@ static char __remove_doc__[] = ":raises EnvironmentError: caused by any system errors\n" "\n" ".. versionadded:: 0.4\n" + NS_CHANGED_DOC ; /* Wrapper for removexattr */ @@ -921,6 +931,7 @@ static char __list_doc__[] = ":raises EnvironmentError: caused by any system errors\n" "\n" ".. versionadded:: 0.4\n" + NS_CHANGED_DOC ; /* Wrapper for listxattr */ -- 2.39.2