Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msabramo/2931197 to your computer and use it in GitHub Desktop.
Save msabramo/2931197 to your computer and use it in GitHub Desktop.
Python file generated by Chameleon that causes SyntaxError when running Pyramid test suite on PyPy 1.9.0 on Ubuntu
from sys import exc_info as _exc_info
_static_-1226789952 = {u'xmlns': u'http://www.w3.org/1999/xhtml', }
import re
import functools
__marker = object()
g_re_amp = re.compile('&(?!([A-Za-z]+|#[0-9]+);)')
g_re_needs_escape = re.compile('[&<>\\"\\\']').search
__re_whitespace = functools.partial(re.compile('\\s+').sub, ' ')
def initialize(nothing, macros, __loader, template):
def render(__stream, econtext, rcontext, __i18n_domain=None):
__append = __stream.append
__re_amp = g_re_amp
__re_needs_escape = g_re_needs_escape
decode = econtext['__decode']
convert = econtext['__convert']
translate = econtext['__translate']
getitem = econtext.__getitem__
get = econtext.get
# <Static value=<_ast.Dict object at 0xb6e0abc0> name=None at d688f70> -> __attrs_224956240
__attrs_224956240 = _static_-1226789952
# <div ... (1:0)
# --------------------------------------------------------
__append(u'<div')
__append(u' xmlns="http://www.w3.org/1999/xhtml"')
__append(u'>')
# <Interpolation value=<Substitution u'\n ${name}\n' (2:52)> braces_required=True translation=False at d68c410> -> __content_210819380
try:
try:
__content_210819380 = getitem('name')
if (__content_210819380 is None):
pass
else:
if (__content_210819380 is False):
__content_210819380 = None
else:
__tt = type(__content_210819380)
if ((__tt is int) or (__tt is float) or (__tt is long)):
__content_210819380 = unicode(__content_210819380)
else:
try:
if (__tt is str):
__content_210819380 = decode(__content_210819380)
else:
if (__tt is not unicode):
try:
__content_210819380 = __content_210819380.__html__
except:
__converted = convert(__content_210819380)
__content_210819380 = (unicode(__content_210819380) if (__content_210819380 is __converted) else __converted)
else:
raise RuntimeError
except RuntimeError:
__content_210819380 = __content_210819380()
else:
if (__content_210819380 is not None):
try:
econtext['escape'] = (__re_needs_escape(__content_210819380) is not None)
except get('TypeError', TypeError):
pass
else:
if getitem('escape'):
if ('&' in __content_210819380):
__content_210819380 = __content_210819380.replace('&', '&amp;')
if ('<' in __content_210819380):
__content_210819380 = __content_210819380.replace('<', '&lt;')
if ('>' in __content_210819380):
__content_210819380 = __content_210819380.replace('>', '&gt;')
if (('\x00' is not None) and ('\x00' in __content_210819380)):
__content_210819380 = __content_210819380.replace('\x00', '&#0;')
except:
rcontext.setdefault('__error__', []).append(('name', 3, 5, '/home/marca/dev/git-repos/pyramid/pyramid/tests/pkgs/rendererscanapp/one.pt', _exc_info()[1], ))
raise
__content_210819380 = ('%s%s%s' % ((u'\n ' if (u'\n ' is not None) else ''), (__content_210819380 if (__content_210819380 is not None) else ''), (u'\n' if (u'\n' is not None) else ''), ))
except:
rcontext.setdefault('__error__', []).append(('\n ${name}\n', 2, 52, '/home/marca/dev/git-repos/pyramid/pyramid/tests/pkgs/rendererscanapp/one.pt', _exc_info()[1], ))
raise
if (__content_210819380 is not None):
__append(__content_210819380)
__append(u'</div>')
__append(u'\n')
return {'render': render, }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment