Commit 85643b74 authored by Marius Wachtler's avatar Marius Wachtler

getiter(): don't ignore CAPI exception and add file.encoding

parent 66cbe50c
# expected: fail
# NOTE: this file tests the new `io` library backported from Python 3.x.
# Similar tests for the builtin file object can be found in test_file2k.py.
......@@ -27,6 +26,8 @@ class AutoFileTests(unittest.TestCase):
self.f.close()
os.remove(TESTFN)
# pyston change:
@unittest.skip("does not work with GC")
def testWeakRefs(self):
# verify weak references
p = proxy(self.f)
......
......@@ -1882,6 +1882,8 @@ void setupFile() {
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFile, f_name), true));
file_cls->giveAttr("mode",
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFile, f_mode), true));
file_cls->giveAttr("encoding",
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFile, f_encoding), true));
file_cls->giveAttr("__new__", new BoxedFunction(FunctionMetadata::create((void*)fileNew, UNKNOWN, 4, false, false),
{ boxString("r"), boxInt(-1) }));
......
......@@ -5726,6 +5726,8 @@ Box* getiter(Box* o) {
Box* r = NULL;
if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_ITER) && type->tp_iter != slot_tp_iter && type->tp_iter) {
r = type->tp_iter(o);
if (!r && PyErr_Occurred())
throwCAPIException();
} else {
r = type->callIterIC(o);
}
......
......@@ -97,7 +97,6 @@ test_extcall f(**kw) crashes if kw isn't a dict
test_file2k we abort when you try to open() a directory
test_file_eintr not sure
test_fileio [unknown]
test_file wontfix: we don't destruct file objects when the test wants
test_fork1 [unknown]
test_frozen [unknown]
test_ftplib [unknown]
......
......@@ -20,6 +20,7 @@ def chop(s):
for desc in [sys.stderr, sys.stdout, sys.stdin]:
print chop(str(desc))
print desc.encoding
f = open("/dev/null", 'w')
print chop(str(f))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment