Skip to content

Different behaviour when reading from filename vs string #393

Closed
@adamlwgriffiths

Description

@adamlwgriffiths

Using compile(string='<sass content>') I get the following error: Invalid CSS after ""

But if I put that same SASS into a file and load it, the error disappears.
The output below describes this issue.

In [4]: sass.compile(filename='server/style.sass')
Out[4]: 'a b {\n  color: blue; }\n'

In [5]: x = '''
   ...: a
   ...:   b
   ...:     color: blue
   ...: '''

In [6]: sass.compile(string=x)
---------------------------------------------------------------------------
CompileError                              Traceback (most recent call last)
<ipython-input-6-030bbd1c42f9> in <module>
----> 1 sass.compile(string=x)

/nix/store/p5qcpw0b0y290wdkw4dxwrs6c0m9nzk0-python3-3.9.9-env/lib/python3.9/site-packages/sass.py in compile(**kwargs)
    736         raise TypeError('something went wrong')
    737     assert not s
--> 738     raise CompileError(v)
    739 
    740 

CompileError: Error: Invalid CSS after "": expected 1 selector or at-rule, was "a"
        on line 1:1 of stdin
>> 

   ^


In [7]: with open('server/style.sass', 'r') as f:
   ...:     print(f.read())
   ...: 
a
  b
    color: blue

In [8]: sass.__version__
Out[8]: '0.21.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions