Fix a encoding issues for future Python 3 support.
This commit is contained in:
		
							parent
							
								
									4c3661ad19
								
							
						
					
					
						commit
						69725698ae
					
				
					 2 changed files with 2 additions and 7 deletions
				
			
		| 
						 | 
					@ -13,7 +13,7 @@ class ParameterValidator(object):
 | 
				
			||||||
            self.given_hash = given_hash_or_params
 | 
					            self.given_hash = given_hash_or_params
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.given_hash = given_hash_or_params.get(params_hash_key)
 | 
					            self.given_hash = given_hash_or_params.get(params_hash_key)
 | 
				
			||||||
        seed = getattr(settings, 'CONSERVANCY_SECRET_KEY', '')
 | 
					        seed = getattr(settings, 'CONSERVANCY_SECRET_KEY', '').encode('utf-8')
 | 
				
			||||||
        self.hasher = hashlib.sha256(seed)
 | 
					        self.hasher = hashlib.sha256(seed)
 | 
				
			||||||
        if isinstance(self.given_hash, basestring):
 | 
					        if isinstance(self.given_hash, basestring):
 | 
				
			||||||
            self.hash_type = type(self.given_hash)
 | 
					            self.hash_type = type(self.given_hash)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,12 +32,7 @@ def index(request, *args, **kwargs):
 | 
				
			||||||
    path = request.path.lstrip(u'/')
 | 
					    path = request.path.lstrip(u'/')
 | 
				
			||||||
    if path.endswith(u'/'):
 | 
					    if path.endswith(u'/'):
 | 
				
			||||||
        path += u'index.html'
 | 
					        path += u'index.html'
 | 
				
			||||||
    try:
 | 
					    fullpath = os.path.join(STATIC_ROOT, path)
 | 
				
			||||||
        path_bytes = path.encode(FILESYSTEM_ENCODING)
 | 
					 | 
				
			||||||
    except UnicodeEncodeError:
 | 
					 | 
				
			||||||
        # If the path can't be expressed on the filesystem, it must not exist.
 | 
					 | 
				
			||||||
        return handler404(request)
 | 
					 | 
				
			||||||
    fullpath = os.path.join(STATIC_ROOT, path_bytes)
 | 
					 | 
				
			||||||
    if not os.path.exists(fullpath):
 | 
					    if not os.path.exists(fullpath):
 | 
				
			||||||
        return handler404(request)
 | 
					        return handler404(request)
 | 
				
			||||||
    content_type, _ = mimetypes.guess_type(path)
 | 
					    content_type, _ = mimetypes.guess_type(path)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue