Giter Club home page Giter Club logo

cheetah's People

Contributors

abbeyj avatar arunk avatar jbq avatar js-cfl avatar karmix avatar mikebonnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cheetah's Issues

still maintained?

Hey,
is this repo still maintained? I amconsidering submitting a pull request to fix a bug

Anachronistic use of PyUnicode_FromString in _namemapper.c

I'm stuck with using a somewhat older version of python (2.4) for development, and have run into an issue building the cheetah package. In the C version of _namemapper.c, cheetah uses the PyUnicode_FromFormat function. While this is fine for python version 3.0+, this function doesn't appear anywhere in the python C API documentation for the 2.x versions. It is, however, present in the C API starting in at least 2.6 for some reason.

This appears to be the only thing holding cheetah back from being compatible with 2.4. The fix is trivial, and I've got a patch if you'd like it.

Line ending tests break in 2.7

There are 6 failures which are line endings tests. Python 2.7
changed the behaviour of the compile() builtin (change documented
at http://docs.python.org/dev/whatsnew/2.7.html). The following
minimally reproduces the change:

c = compile('x="""\r\nx\r\n"""', 'file', 'exec')
exec(c, globals(), locals())

print x == "\nx\n"

Under 2.7 this prints "True". Under earlier versions of python, it prints
"False".

I can't see a way round this short of replacing all in-string literal
newlines
with "\r\n" or "\r". This would require pre-parsing the template to find
the strings. Hopefully there's a nicer way.

Here, we don't actually care that literal line endings get converted to UNIX
line endings; does this matter to anyone? Would it be easier to require
non-UNIX line endings to be escaped?

segfault grabbing attributes off of objects that implement __getattribute__

_namemapper.c:PyNamemapper_valueForName calls PyObject_GetAttrString and doesn't check its return value for NULL. It does check PyErr_Occurred(), but that isn't being triggered in this case (which looks like a bug in the python c api -- I was getting this sporadically on a live service running python 2.4.6).

It should be checking for NULL as well and setting a python error and returning NULL in that case.

We worked around this by overriding getattr instead of getattribute (which should have been done in the first place), but the python issue, not protected against by cheetah, is still there.

Problem with non-ascii attributes

Hi! First I got the problem with Cheetah 2.4.2 in Debian 6.0, but it seems latest Cheetah 2.4.4 has the same bug (if it's a bug and not an error on my side). I narrowed the problem to the following code in Compiler.py, line 1476:

def attributes(self):
    attribs = [self.setting('indentationStep') + str(attrib)
                  for attrib in self._generatedAttribs ]
    return '\n\n'.join(attribs)

The problem is in str(attrib) - if attrib is non-ascii unicode (I don't know how Cheetah works but it seems it converts the entire source to unicode) then str(attrib) fails. I cannot even compile the following simple template:

#encoding utf-8
#attr $test = 'тест' # this is 'test' in Russian

See:

$ cheetah compile test.tmpl
Compiling test.tmpl -> test.py
Traceback (most recent call last):
        ...
      File "/usr/lib/pymodules/python2.6/Cheetah/Compiler.py", line 1478, in attributes for attrib in self._generatedAttribs ]
UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-11: ordinal not in range(128)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.