- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 33.3k
 
Closed as not planned
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-IOtopic-unicodetype-featureA feature request or enhancementA feature request or enhancement
Description
Bug report
Bug description:
from 3.10, io.text_encoding may return 'locale' if encoding is None, and the function open can support it well, like:
>>> open('/dev/null',encoding=io.text_encoding(None))
<_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>but codes.open raised an error when i was doing this:
>>> codecs.open('/dev/null',encoding=io.text_encoding(None))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen codecs>", line 910, in open
LookupError: unknown encoding: locale
>>> codecs.open('/dev/null',encoding='locale')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen codecs>", line 910, in open
LookupError: unknown encoding: localeand codes.open can deal None correctly:
>>> codecs.open('/dev/null',encoding=None)
<_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>My Python version is:
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
CPython versions tested on:
3.11
Operating systems tested on:
Linux, Windows
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-IOtopic-unicodetype-featureA feature request or enhancementA feature request or enhancement
Projects
Status
Done