This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3 set default encoding
Type: compile error Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: graingert, xxm
Priority: normal Keywords:

Created on 2019-07-30 06:11 by xxm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
struts-scan.py xxm, 2019-07-30 06:11 This is a program from GitHub. https://github.com/Lucifer1993/struts-scan Download it and it can be run normally in Python2. However, after the conversion of 2to3, AttributeError will happen.
Messages (2)
msg348716 - (view) Author: Xinmeng Xia (xxm) Date: 2019-07-30 06:11
There is a bug in lib2to3. When dealing with this project "struts-scan" by 2to3,the following bug will show up. 
Traceback (most recent call last):
  File "/home/xxm/Desktop/instrument/datasetpy3/struts-scan/struts-scan.py", line 18, in <module>
    sys.setdefaultencoding('utf-8')
AttributeError: module 'sys' has no attribute 'setdefaultencoding'

"sys.setdefaultencoding('utf-8')" is not dealt with by lib2to3. In Python3, there is no such API "setdefaultencoding" for "sys". 

A possible solution to improve 2to3 is to delete this line     "sys.setdefaultencoding('utf-8')" when converting Python2 projects
msg398313 - (view) Author: Thomas Grainger (graingert) * Date: 2021-07-27 18:10
lib2to3 is deprecated and is pending removal, so I think this can be closed
History
Date User Action Args
2022-04-11 14:59:18adminsetgithub: 81896
2021-07-28 02:41:49benjamin.petersonsetstatus: open -> closed
resolution: wont fix
stage: resolved
2021-07-27 18:10:05graingertsetnosy: + graingert
messages: + msg398313
2019-07-30 06:11:45xxmcreate