Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ascii' shoud be range(256) or just set another default encoding #47898

Closed
electronixtar mannequin opened this issue Aug 22, 2008 · 2 comments
Closed

'ascii' shoud be range(256) or just set another default encoding #47898

electronixtar mannequin opened this issue Aug 22, 2008 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@electronixtar
Copy link
Mannequin

electronixtar mannequin commented Aug 22, 2008

BPO 3648
Nosy @pitrou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-08-22.15:35:18.180>
created_at = <Date 2008-08-22.14:14:09.466>
labels = ['interpreter-core', 'type-bug', 'invalid']
title = "'ascii' shoud be range(256) or just set another default encoding"
updated_at = <Date 2008-08-22.15:35:18.052>
user = 'https://bugs.python.org/electronixtar'

bugs.python.org fields:

activity = <Date 2008-08-22.15:35:18.052>
actor = 'pitrou'
assignee = 'none'
closed = True
closed_date = <Date 2008-08-22.15:35:18.180>
closer = 'pitrou'
components = ['Interpreter Core']
creation = <Date 2008-08-22.14:14:09.466>
creator = 'electronixtar'
dependencies = []
files = []
hgrepos = []
issue_num = 3648
keywords = []
message_count = 2.0
messages = ['71747', '71753']
nosy_count = 2.0
nosy_names = ['pitrou', 'electronixtar']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue3648'
versions = ['Python 2.5']

@electronixtar
Copy link
Mannequin Author

electronixtar mannequin commented Aug 22, 2008

One of the MOST common scene for Python developers on CJK/Widecharacter
is this error:

'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range
(128)

Why cann't Python just define ascii to range(256), or alternatively,
just use another default encoding that handles 0x00 to 0xff. Sometimes
encoding problems in Python are driving me mad.

Currently I am using mbcs, but it's only available on Windows.

@electronixtar electronixtar mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Aug 22, 2008
@pitrou
Copy link
Member

pitrou commented Aug 22, 2008

Sometimes
encoding problems in Python are driving me mad.

The thing is, they are not "encoding problems in Python", they are
encoding problems in the outside world. Python cannot know magically
which encoding is used in third-party data, so you have to tell it
yourself what the encoding is.

The default is "ascii" because only ASCII chars (from 32 to 127) can be
interpreted properly in most situations without having any knowledge of
the encoding (barring obsolete stuff such as EBCDIC, that is).

The only solution is to know what encoding you are expecting and
decode/encode it yourself. Python can't decide it for you.

@pitrou pitrou closed this as completed Aug 22, 2008
@pitrou pitrou added the invalid label Aug 22, 2008
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant