mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Fall back to ascii if the locale module cannot be loaded.
This commit is contained in:
		
							parent
							
								
									10f07c41e6
								
							
						
					
					
						commit
						d78d3b4541
					
				
					 1 changed files with 7 additions and 2 deletions
				
			
		| 
						 | 
					@ -976,7 +976,12 @@ def __init__(self, buffer, encoding=None, newline=None):
 | 
				
			||||||
            except AttributeError:
 | 
					            except AttributeError:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
            if encoding is None:
 | 
					            if encoding is None:
 | 
				
			||||||
 | 
					                try:
 | 
				
			||||||
                    import locale
 | 
					                    import locale
 | 
				
			||||||
 | 
					                except ImportError:
 | 
				
			||||||
 | 
					                    # Importing locale may fail if Python is being built
 | 
				
			||||||
 | 
					                    encoding = "ascii"
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
                    encoding = locale.getpreferredencoding()
 | 
					                    encoding = locale.getpreferredencoding()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.buffer = buffer
 | 
					        self.buffer = buffer
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue