Created
December 28, 2013 22:21
-
-
Save plq/8164989 to your computer and use it in GitHub Desktop.
lxml segfault
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from lxml import etree | |
from StringIO import StringIO | |
def coroutine(func): | |
def start(*args, **kwargs): | |
ret = func(*args, **kwargs) | |
try: | |
next(ret) | |
except StopIteration: | |
return None | |
return ret | |
return start | |
@coroutine | |
def yo_gen2(parent): | |
with parent.element("yo"): | |
while True: | |
a = yield | |
print(2, a) | |
@coroutine | |
def yo_gen(parent): | |
with etree.xmlfile(parent) as xf: | |
ret = yo_gen2(xf) | |
while True: | |
val = yield | |
ret.send(val) | |
gen = yo_gen(StringIO()) | |
gen.send("hellooo") | |
try: | |
gen.throw(Exception()) | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment