Author: Carl Friedrich Bolz <[email protected]>
Branch: py3.5
Changeset: r88219:88143396c66f
Date: 2016-11-08 16:26 +0100
http://bitbucket.org/pypy/pypy/changeset/88143396c66f/
Log: make PyErr_SetFromErrnoWithFilename use wrap_fsdecoded
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -147,7 +147,7 @@
# XXX Doesn't actually do anything with PyErr_CheckSignals.
if llfilename:
filename = rffi.charp2str(llfilename)
- w_filename = space.wrap(filename)
+ w_filename = space.wrap_fsdecoded(filename)
else:
w_filename = space.w_None
diff --git a/pypy/module/cpyext/test/test_pyerrors.py
b/pypy/module/cpyext/test/test_pyerrors.py
--- a/pypy/module/cpyext/test/test_pyerrors.py
+++ b/pypy/module/cpyext/test/test_pyerrors.py
@@ -105,6 +105,13 @@
assert api.PyOS_InterruptOccurred()
class AppTestFetch(AppTestCpythonExtensionBase):
+ def setup_class(cls):
+ from pypy.module.imp.test.support import get_special_char
+ space = cls.space
+ cls.special_char = get_special_char()
+ cls.w_special_char = space.wrap(cls.special_char)
+ AppTestCpythonExtensionBase.setup_class.im_func(cls)
+
def test_occurred(self):
module = self.import_extension('foo', [
@@ -199,6 +206,9 @@
assert e.filename is None
def test_SetFromErrnoWithFilename(self):
+ char = self.special_char
+ if char is None:
+ char = "a" # boring
import errno, os
module = self.import_extension('foo', [
@@ -208,6 +218,12 @@
PyErr_SetFromErrnoWithFilename(PyExc_OSError,
"/path/to/file");
return NULL;
'''),
+ ("set_from_errno_special", "METH_NOARGS",
+ '''
+ errno = EBADF;
+ PyErr_SetFromErrnoWithFilename(PyExc_OSError, "/path/to/%s");
+ return NULL;
+ ''' % (char, )),
],
prologue="#include <errno.h>")
exc_info = raises(OSError, module.set_from_errno)
@@ -215,6 +231,11 @@
assert exc_info.value.errno == errno.EBADF
assert exc_info.value.strerror == os.strerror(errno.EBADF)
+ exc_info = raises(OSError, module.set_from_errno_special)
+ assert exc_info.value.filename == "/path/to/%s" % (char, )
+ assert exc_info.value.errno == errno.EBADF
+ assert exc_info.value.strerror == os.strerror(errno.EBADF)
+
def test_SetFromErrnoWithFilename_NULL(self):
import errno, os
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit