A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-August/091402.html below:

[Python-Dev] deleting setdefaultencoding iin site.py is evil

[Python-Dev] deleting setdefaultencoding iin site.py is evil [Python-Dev] deleting setdefaultencoding iin site.py is evilChris Withers chris at simplistix.co.uk
Thu Aug 27 10:01:33 CEST 2009
Martin v. Löwis wrote:
>> - If people were somehow relying on sys not having an attribute called
>> _setdefaultencoding, or were relying on stuffing an attribute into sys
>> called _setdefaultencoding then... well... that seems pretty unlikely ;-)
> 
> If people were using the reload trickery, that would break if the
> function changed its name.

No it doesn't:

$ svn diff
Index: Lib/site.py
===================================================================
--- Lib/site.py (revision 74552)
+++ Lib/site.py (working copy)
@@ -540,6 +540,7 @@
      if hasattr(sys, "setdefaultencoding"):
+        sys._setdefaultencoding = sys.setdefaultencoding
          del sys.setdefaultencoding

 >>> import sys
 >>> sys._setdefaultencoding
<built-in function setdefaultencoding>
 >>> sys.setdefaultencoding
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setdefaultencoding'

 >>> reload(sys)
<module 'sys' (built-in)>
 >>> sys.setdefaultencoding
<built-in function setdefaultencoding>
 >>> sys._setdefaultencoding
<built-in function setdefaultencoding>

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4