klen / python-scss

Python scss parser.

Home Page:http://packages.python.org/scss/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negative value mistaken for an operator

ncadou opened this issue · comments

Converting this valid CSS:

.test { margin: 0 auto -1px auto; }

Results in this (removing the negative sign works as expected):

Traceback (most recent call last):
  File "/tmp/test/bin/scss", line 51, in <module>
    scss.tool.main()
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/tool.py", line 185, in main
    outfile.write(s.load(infile))
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/parser.py", line 329, in load
    self.parse(nodes)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/parser.py", line 289, in parse
    map(lambda n: n.parse(self) if isinstance(n, Node) else None, nodes)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/parser.py", line 289, in <lambda>
    map(lambda n: n.parse(self) if isinstance(n, Node) else None, nodes)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/parser.py", line 59, in parse
    super(Ruleset, self).parse(target)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/base.py", line 51, in parse
    n.parse(self)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/parser.py", line 85, in parse
    self.expr = ' '.join(str(n) for n in self.data[2:] if not isinstance(n, Declaration))
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/parser.py", line 85, in <genexpr>
    self.expr = ' '.join(str(n) for n in self.data[2:] if not isinstance(n, Declaration))
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/value.py", line 100, in __str__
    return str(self.value)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/control.py", line 56, in value
    first = op(first, second)
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/value.py", line 63, in __sub__
    return self._do_op(self, other, OPRT['-'])
  File "/tmp/test/eggs/scss-0.8.3-py2.6.egg/scss/value.py", line 44, in _do_op
    return op(first.value, second.value)
TypeError: unsupported operand type(s) for -: 'str' and 'str'

Another one, probably related to the same problem:

.test { margin: 0 -1px -1px 0; }

Results in this:

invalid literal for float(): 0 -1px

BTW, is there a way to get the line number where an error happened?

Fixed in version 0.8.4

Thanks

Thanks! Works like a charm.

And I should add: that was fast :)