Commit 1f18f343 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge commit '2e19356a' into refcounting

parents 89d32425 2e19356a
......@@ -10,9 +10,9 @@ The custom unwinder is in `src/runtime/cxx_unwind.cpp`.
### Useful references on C++ exception handling
- [https://monoinfinito.wordpress.com/series/exception-handling-in-c/](): Good overview of C++ exceptions.
- [http://www.airs.com/blog/archives/460](): Covers dirty details of `.eh_frame`.
- [http://www.airs.com/blog/archives/464](): Covers dirty details of the personality function and the LSDA.
- [https://monoinfinito.wordpress.com/series/exception-handling-in-c/](https://monoinfinito.wordpress.com/series/exception-handling-in-c/): Good overview of C++ exceptions.
- [http://www.airs.com/blog/archives/460](http://www.airs.com/blog/archives/460): Covers dirty details of `.eh_frame`.
- [http://www.airs.com/blog/archives/464](http://www.airs.com/blog/archives/464): Covers dirty details of the personality function and the LSDA.
# How normal C++ unwinding works
......
......@@ -409,7 +409,13 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
return rtn;
}
static Box* methodGetName(Box* b, void*) {
assert(b->cls == method_cls);
const char* s = static_cast<BoxedMethodDescriptor*>(b)->method->ml_name;
if (s)
return boxString(s);
return None;
}
static Box* methodGetDoc(Box* b, void*) {
assert(b->cls == method_cls);
const char* s = static_cast<BoxedMethodDescriptor*>(b)->method->ml_doc;
......@@ -691,7 +697,14 @@ Box* BoxedWrapperDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args,
static Box* wrapperdescrGetDoc(Box* b, void*) {
assert(b->cls == wrapperdescr_cls);
auto s = static_cast<BoxedWrapperDescriptor*>(b)->wrapper->doc;
StringRef s = static_cast<BoxedWrapperDescriptor*>(b)->wrapper->doc;
assert(s.size());
return boxString(s);
}
static Box* wrapperdescrGetName(Box* b, void*) {
assert(b->cls == wrapperdescr_cls);
StringRef s = static_cast<BoxedWrapperDescriptor*>(b)->wrapper->name;
assert(s.size());
return boxString(s);
}
......@@ -862,12 +875,14 @@ void setupDescr() {
method_cls->tpp_call.capi_val = BoxedMethodDescriptor::tppCall<CAPI>;
method_cls->tpp_call.cxx_val = BoxedMethodDescriptor::tppCall<CXX>;
method_cls->giveAttrDescriptor("__doc__", methodGetDoc, NULL);
method_cls->giveAttrDescriptor("__name__", methodGetName, NULL);
method_cls->giveAttr("__repr__", new BoxedFunction(FunctionMetadata::create((void*)methodRepr, UNKNOWN, 1)));
method_cls->freeze();
wrapperdescr_cls->giveAttr("__call__", new BoxedFunction(FunctionMetadata::create(
(void*)BoxedWrapperDescriptor::__call__, UNKNOWN, 2, true, true)));
wrapperdescr_cls->giveAttrDescriptor("__doc__", wrapperdescrGetDoc, NULL);
wrapperdescr_cls->giveAttrDescriptor("__name__", wrapperdescrGetName, NULL);
wrapperdescr_cls->tp_descr_get = BoxedWrapperDescriptor::descr_get;
wrapperdescr_cls->tpp_call.capi_val = BoxedWrapperDescriptor::tppCall<CAPI>;
wrapperdescr_cls->tpp_call.cxx_val = BoxedWrapperDescriptor::tppCall<CXX>;
......
#-*- coding: utf-8 -*-
#flask test
#todo: It should be tested as django_test.py.
import os, sys, subprocess, shutil
import multiprocessing, time, signal
import urllib2
sys.path.append(os.path.dirname(__file__) + "/../lib")
from test_helper import create_virtenv, run_test
ENV_NAME = "flask_test_env_" + os.path.basename(sys.executable)
create_virtenv(ENV_NAME,
["flask == 0.10.1",
"Werkzeug == 0.11.3",
"jinja2 == 2.8",
"itsdangerous == 0.24",
"markupsafe == 0.23"]
, force_create = True)
sys.path.append(ENV_NAME + "/site-packages")
from flask import Flask, Markup
from jinja2 import Template
app = Flask(__name__)
@app.route('/')
def test_template():
t = Template("Hello, World!: {% for n in range(1,10) %}{{n}} " "{% endfor %}")
return t.render()
if __name__ == '__main__':
app.config['TESTING'] = True
assert isinstance(app, Flask)
server = multiprocessing.Process(target=app.run)
server.start()
time.sleep(1)
f = urllib2.urlopen("http://127.0.0.1:5000/", timeout=1)
s = f.read()
assert 'Hello, World!: 1 2 3 4 5 6 7 8 9' in s
server.terminate()
server.join()
m1 = Markup('<strong>Hello %s!</strong>') % '<blink>hacker</blink>'
m2 = Markup.escape('<blink>hacker</blink>')
m3 = Markup('<em>Marked up</em> &raquo; HTML').striptags()
print 'PASSED'
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