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

Builtin ascii() function from future_builtins includes leading "u" of unicode strings #47891

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

Builtin ascii() function from future_builtins includes leading "u" of unicode strings #47891

tav mannequin opened this issue Aug 22, 2008 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@tav
Copy link
Mannequin

tav mannequin commented Aug 22, 2008

BPO 3641
Nosy @benjaminp

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.00:36:43.054>
created_at = <Date 2008-08-22.00:19:55.327>
labels = ['type-bug', 'library']
title = 'Builtin ascii() function from future_builtins includes leading "u" of unicode strings'
updated_at = <Date 2008-08-22.00:36:43.039>
user = 'https://bugs.python.org/tav'

bugs.python.org fields:

activity = <Date 2008-08-22.00:36:43.039>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2008-08-22.00:36:43.054>
closer = 'benjamin.peterson'
components = ['Library (Lib)']
creation = <Date 2008-08-22.00:19:55.327>
creator = 'tav'
dependencies = []
files = []
hgrepos = []
issue_num = 3641
keywords = []
message_count = 2.0
messages = ['71708', '71710']
nosy_count = 2.0
nosy_names = ['benjamin.peterson', 'tav']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue3641'
versions = ['Python 2.6']

@tav
Copy link
Mannequin Author

tav mannequin commented Aug 22, 2008

Perhaps I misunderstood the intended behaviour of the ascii() builtin in
the future_builtins module, but the following behaviour is unexpected:

>>> from __future__ import unicode_literals
>>> from future_builtins import ascii

>>> test = 'hello'

  >>> ascii(test)
  "u'hello'"

Surely the leading 'u' should not be there?

After all, this is a future builtin we are importing -- when all
'strings' are unicode by default?

@tav tav mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 22, 2008
@benjaminp
Copy link
Contributor

This is a side effect of ascii returning a python 2.x unicode object.
The repr still gives a leading "u". The point of ascii is that it
returns a unicode object with only ascii characters. See PEP-3138 for
more information.

@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
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant