Commit 6bba2b53 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add file_readlines

parent b1e0937b
This diff is collapsed.
...@@ -1833,6 +1833,23 @@ extern "C" int _PyString_Resize(PyObject** pv, Py_ssize_t newsize) noexcept { ...@@ -1833,6 +1833,23 @@ extern "C" int _PyString_Resize(PyObject** pv, Py_ssize_t newsize) noexcept {
return 0; return 0;
} }
extern "C" void PyString_Concat(register PyObject** pv, register PyObject* w) noexcept {
try {
if (*pv == NULL)
return;
if (w == NULL || !PyString_Check(*pv)) {
*pv = NULL;
return;
}
*pv = strAdd((BoxedString*)*pv, w);
} catch (ExcInfo e) {
setCAPIException(e);
*pv = NULL;
}
}
extern "C" void PyString_ConcatAndDel(register PyObject** pv, register PyObject* w) noexcept { extern "C" void PyString_ConcatAndDel(register PyObject** pv, register PyObject* w) noexcept {
Py_FatalError("unimplemented"); Py_FatalError("unimplemented");
} }
......
...@@ -1139,6 +1139,8 @@ void setupRuntime() { ...@@ -1139,6 +1139,8 @@ void setupRuntime() {
closure_cls->freeze(); closure_cls->freeze();
setupCAPI();
setupBool(); setupBool();
setupInt(); setupInt();
setupLong(); setupLong();
...@@ -1206,8 +1208,6 @@ void setupRuntime() { ...@@ -1206,8 +1208,6 @@ void setupRuntime() {
setupThread(); setupThread();
setupGC(); setupGC();
setupCAPI();
PyType_Ready(&PyCapsule_Type); PyType_Ready(&PyCapsule_Type);
initerrno(); initerrno();
......
...@@ -39,6 +39,9 @@ with open('README.md') as f: ...@@ -39,6 +39,9 @@ with open('README.md') as f:
print lines[:5] print lines[:5]
print lines[-5:] print lines[-5:]
with open('README.md') as f:
print len(f.readlines())
# Check that opening a non-existent file results in an IOError. # Check that opening a non-existent file results in an IOError.
try: try:
f = open('this-should-definitely-not-exist.txt') f = open('this-should-definitely-not-exist.txt')
...@@ -46,6 +49,6 @@ except IOError as e: ...@@ -46,6 +49,6 @@ except IOError as e:
print str(e) print str(e)
f = open("/dev/null", "w") f = open("/dev/null", "w")
f.write("hello world") print f.write("hello world")
print f.flush() print f.flush()
f.close() print f.close()
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