[pypy-commit] pypy py3.5-xattr: Enable getxattr, setxattr, removexattr
rlamy
pypy.commits at gmail.com
Tue Dec 19 11:10:53 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5-xattr
Changeset: r93493:7bb9dfa2b7ff
Date: 2017-12-19 16:10 +0000
http://bitbucket.org/pypy/pypy/changeset/7bb9dfa2b7ff/
Log: Enable getxattr, setxattr, removexattr
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -229,7 +229,7 @@
'POSIX_FADV_RANDOM', 'POSIX_FADV_NOREUSE', 'POSIX_FADV_DONTNEED']:
assert getattr(rposix, _name) is not None, "missing %r" % (_name,)
interpleveldefs[_name] = 'space.wrap(%d)' % getattr(rposix, _name)
-
+
if hasattr(rposix, 'sched_get_priority_max'):
interpleveldefs['sched_get_priority_max'] = 'interp_posix.sched_get_priority_max'
interpleveldefs['sched_get_priority_min'] = 'interp_posix.sched_get_priority_min'
@@ -246,11 +246,20 @@
if hasattr(rposix, 'sched_yield'):
interpleveldefs['sched_yield'] = 'interp_posix.sched_yield'
-
+
for _name in ["O_CLOEXEC"]:
if getattr(rposix, _name) is not None:
interpleveldefs[_name] = 'space.wrap(%d)' % getattr(rposix, _name)
+ if hasattr(rposix, 'getxattr'):
+ interpleveldefs['getxattr'] = 'interp_posix.getxattr'
+ interpleveldefs['setxattr'] = 'interp_posix.setxattr'
+ interpleveldefs['removexattr'] = 'interp_posix.removexattr'
+ for _name in ['XATTR_SIZE_MAX', 'XATTR_CREATE', 'XATTR_REPLACE']:
+ if getattr(rposix, _name) is not None:
+ interpleveldefs[_name] = 'space.wrap(%d)' % getattr(rposix, _name)
+
+
def startup(self, space):
from pypy.module.posix import interp_posix
from pypy.module.imp import importing
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -386,8 +386,8 @@
def test_times(self):
"""
- posix.times() should return a posix.times_result object giving
- float-representations (seconds, effectively) of the four fields from
+ posix.times() should return a posix.times_result object giving
+ float-representations (seconds, effectively) of the four fields from
the underlying struct tms and the return value.
"""
result = self.posix.times()
@@ -977,7 +977,7 @@
assert posix.sched_get_priority_min(posix.SCHED_OTHER) != -1
if getattr(posix, 'SCHED_BATCH', None):
assert posix.sched_get_priority_min(posix.SCHED_BATCH) != -1
-
+
if hasattr(rposix, 'sched_get_priority_min'):
def test_os_sched_priority_max_greater_than_min(self):
posix, os = self.posix, self.os
@@ -992,7 +992,7 @@
def test_sched_yield(self):
os = self.posix
#Always suceeds on Linux
- os.sched_yield()
+ os.sched_yield()
def test_write_buffer(self):
os = self.posix
@@ -1350,7 +1350,7 @@
posix.close(fd)
s2.close()
s1.close()
-
+
def test_os_lockf(self):
posix, os = self.posix, self.os
fd = os.open(self.path2 + 'test_os_lockf', os.O_WRONLY | os.O_CREAT)
@@ -1441,6 +1441,20 @@
e = raises(OSError, self.posix.symlink, 'bok', '/nonexistentdir/boz')
assert str(e.value).endswith(": 'bok' -> '/nonexistentdir/boz'")
+ if hasattr(rposix, 'getxattr'):
+ def test_xattr_simple(self):
+ # Minimal testing here, lib-python has better tests.
+ os = self.posix
+ with open(self.path, 'wb'):
+ pass
+ raises(OSError, os.getxattr, self.path, 'user.test')
+ os.setxattr(self.path, 'user.test', b'', os.XATTR_CREATE)
+ assert os.getxattr(self.path, 'user.test') == b''
+ os.setxattr(self.path, 'user.test', b'foo', os.XATTR_REPLACE)
+ assert os.getxattr(self.path, 'user.test') == b'foo'
+ os.removexattr(self.path, 'user.test')
+ raises(OSError, os.getxattr, self.path, 'user.test')
+
class AppTestEnvironment(object):
def setup_class(cls):
@@ -1495,6 +1509,7 @@
res = os.system(cmd)
assert res == 0
+
@py.test.fixture
def check_fsencoding(space, pytestconfig):
if pytestconfig.getvalue('runappdirect'):
More information about the pypy-commit
mailing list