/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py 504: sys.setdefaultencoding(encoding) # Needs Python Unicode build ! 557: # Remove sys.setdefaultencoding() so that users cannot change the 560: if hasattr(sys, "setdefaultencoding"): 561: del sys.setdefaultencoding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
defsetencoding(): """Set the string encoding used by the Unicode implementation. The default is 'ascii', but if you're willing to experiment, you can change this.""" encoding = "ascii"# Default value set by _PyUnicode_Init() if0: # Enable to support locale aware default string encodings. import locale loc = locale.getdefaultlocale() if loc[1]: encoding = loc[1] if0: # Enable to switch off string to Unicode coercion and implicit # Unicode to string conversion. encoding = "undefined" if encoding != "ascii": # On Non-Unicode builds this will raise an AttributeError... sys.setdefaultencoding(encoding) # Needs Python Unicode build !