@@ -239,7 +239,7 @@ def compile_dirname(
239239 input_filename = input_filename .encode (fs_encoding )
240240 s , v , _ = _sass .compile_filename (
241241 input_filename , output_style , source_comments , include_paths ,
242- precision , None , custom_functions , importers
242+ precision , None , custom_functions , importers , None ,
243243 )
244244 if s :
245245 v = v .decode ('UTF-8' )
@@ -539,30 +539,32 @@ def my_importer(path):
539539 raise TypeError ('source_comments must be bool, not ' +
540540 repr (source_comments ))
541541 fs_encoding = sys .getfilesystemencoding () or sys .getdefaultencoding ()
542- source_map_filename = kwargs .pop ('source_map_filename' , None )
543- if not (source_map_filename is None or
544- isinstance (source_map_filename , string_types )):
545- raise TypeError ('source_map_filename must be a string, not ' +
546- repr (source_map_filename ))
547- elif isinstance (source_map_filename , text_type ):
548- source_map_filename = source_map_filename .encode (fs_encoding )
549- if not ('filename' in modes or source_map_filename is None ):
550- raise CompileError ('source_map_filename is only available with '
551- 'filename= keyword argument since it has to be '
552- 'aware of it' )
553- try :
554- include_paths = kwargs .pop ('include_paths' ) or b''
555- except KeyError :
556- include_paths = b''
557- else :
558- if isinstance (include_paths , collections .Sequence ):
559- include_paths = os .pathsep .join (include_paths )
560- elif not isinstance (include_paths , string_types ):
561- raise TypeError ('include_paths must be a sequence of strings, or '
562- 'a colon-separated (or semicolon-separated if '
563- 'Windows) string, not ' + repr (include_paths ))
564- if isinstance (include_paths , text_type ):
565- include_paths = include_paths .encode (fs_encoding )
542+
543+ def _get_file_arg (key ):
544+ ret = kwargs .pop (key , None )
545+ if ret is not None and not isinstance (ret , string_types ):
546+ raise TypeError ('{} must be a string, not {!r}' .format (key , ret ))
547+ elif isinstance (ret , text_type ):
548+ ret = ret .encode (fs_encoding )
549+ if ret and 'filename' not in modes :
550+ raise CompileError (
551+ '{} is only available with filename= keyword argument since '
552+ 'has to be aware of it' .format (key )
553+ )
554+ return ret
555+
556+ source_map_filename = _get_file_arg ('source_map_filename' )
557+ output_filename_hint = _get_file_arg ('output_filename_hint' )
558+
559+ include_paths = kwargs .pop ('include_paths' , b'' ) or b''
560+ if isinstance (include_paths , collections .Sequence ):
561+ include_paths = os .pathsep .join (include_paths )
562+ elif not isinstance (include_paths , string_types ):
563+ raise TypeError ('include_paths must be a sequence of strings, or '
564+ 'a colon-separated (or semicolon-separated if '
565+ 'Windows) string, not ' + repr (include_paths ))
566+ if isinstance (include_paths , text_type ):
567+ include_paths = include_paths .encode (fs_encoding )
566568
567569 custom_functions = kwargs .pop ('custom_functions' , ())
568570 if isinstance (custom_functions , collections .Mapping ):
@@ -614,6 +616,7 @@ def my_importer(path):
614616 s , v , source_map = _sass .compile_filename (
615617 filename , output_style , source_comments , include_paths , precision ,
616618 source_map_filename , custom_functions , importers ,
619+ output_filename_hint ,
617620 )
618621 if s :
619622 v = v .decode ('utf-8' )
0 commit comments