mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-04 03:27:00 -05:00 
			
		
		
		
	py3: check if quote_plus returns bytes or str
On python3, there is explicit decoding already, so this would fail.
This commit is contained in:
		
							parent
							
								
									57eaee584d
								
							
						
					
					
						commit
						3243aeaa04
					
				@ -51,7 +51,10 @@ all_author_searches = AUTHOR_SEARCHES.__iter__
 | 
				
			|||||||
def qquote(val):
 | 
					def qquote(val):
 | 
				
			||||||
    if not isinstance(val, bytes):
 | 
					    if not isinstance(val, bytes):
 | 
				
			||||||
        val = val.encode('utf-8')
 | 
					        val = val.encode('utf-8')
 | 
				
			||||||
    return quote_plus(val).decode('utf-8')
 | 
					    ans = quote_plus(val)
 | 
				
			||||||
 | 
					    if isinstance(ans, bytes):
 | 
				
			||||||
 | 
					        ans = ans.decode('utf-8')
 | 
				
			||||||
 | 
					    return ans
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def url_for(template, data):
 | 
					def url_for(template, data):
 | 
				
			||||||
 | 
				
			|||||||
@ -74,7 +74,10 @@ def query(br, url, key, dump_raw=None, limit=1, parser=parse_html, timeout=60):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def quote_term(x):
 | 
					def quote_term(x):
 | 
				
			||||||
    return quote_plus(x.encode('utf-8')).decode('utf-8')
 | 
					    ans = quote_plus(x.encode('utf-8'))
 | 
				
			||||||
 | 
					    if isinstance(ans, bytes):
 | 
				
			||||||
 | 
					        ans = ans.decode('utf-8')
 | 
				
			||||||
 | 
					    return ans
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# DDG + Wayback machine {{{
 | 
					# DDG + Wayback machine {{{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user