@@ -52,13 +52,18 @@ def isidentifier(s):
5252
5353    StringIO  =  io .StringIO 
5454
55+ if  hasattr (os , "fspath" ):  # PY3 
56+     fspath  =  os .fspath 
57+ else :  # PY2 
58+     fspath  =  str 
59+ 
5560
5661class  Rule :
5762    """A single set of rules for 'unasync'ing file(s)""" 
5863
5964    def  __init__ (self , fromdir , todir , additional_replacements = None ):
60-         self .fromdir  =  fromdir .replace ("/" , os .sep )
61-         self .todir  =  todir .replace ("/" , os .sep )
65+         self .fromdir  =  fspath ( fromdir ) .replace ("/" , os .sep )
66+         self .todir  =  fspath ( todir ) .replace ("/" , os .sep )
6267
6368        # Add any additional user-defined token replacements to our list. 
6469        self .token_replacements  =  _ASYNC_TO_SYNC .copy ()
@@ -69,6 +74,8 @@ def _match(self, filepath):
6974        """Determines if a Rule matches a given filepath and if so 
7075        returns a higher comparable value if the match is more specific. 
7176        """ 
77+         filepath  =  fspath (filepath )
78+ 
7279        file_segments  =  [x  for  x  in  filepath .split (os .sep ) if  x ]
7380        from_segments  =  [x  for  x  in  self .fromdir .split (os .sep ) if  x ]
7481        len_from_segments  =  len (from_segments )
@@ -83,6 +90,7 @@ def _match(self, filepath):
8390        return  False 
8491
8592    def  _unasync_file (self , filepath ):
93+         filepath  =  fspath (filepath )
8694        with  open (filepath , "rb" ) as  f :
8795            write_kwargs  =  {}
8896            if  sys .version_info [0 ] >=  3 :  # PY3  # pragma: no branch 
0 commit comments