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

Add.isascii() to str, bytes and bytearray #76858

Closed
methane opened this issue Jan 26, 2018 · 4 comments
Closed

Add.isascii() to str, bytes and bytearray #76858

methane opened this issue Jan 26, 2018 · 4 comments
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@methane
Copy link
Member

methane commented Jan 26, 2018

BPO 32677
Nosy @vstinner, @methane
PRs
  • bpo-32677: Add .isascii() to str, bytes and bytearray #5342
  • bpo-32677: Optimize str.isascii() #5356
  • 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 2018-01-28.01:01:04.244>
    created_at = <Date 2018-01-26.11:09:08.156>
    labels = ['interpreter-core', 'type-feature', '3.7']
    title = 'Add.isascii() to str, bytes and bytearray'
    updated_at = <Date 2018-01-28.01:01:04.244>
    user = 'https://github.com/methane'

    bugs.python.org fields:

    activity = <Date 2018-01-28.01:01:04.244>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-01-28.01:01:04.244>
    closer = 'methane'
    components = ['Interpreter Core']
    creation = <Date 2018-01-26.11:09:08.156>
    creator = 'methane'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32677
    keywords = ['patch']
    message_count = 4.0
    messages = ['310754', '310755', '310839', '310902']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'methane']
    pr_nums = ['5342', '5356']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32677'
    versions = ['Python 3.7']

    @methane
    Copy link
    Member Author

    methane commented Jan 26, 2018

    int() and str.is*** functions accepts other than ASCII.
    But we want to accept only ASCII in some cases. (e.g. ipaddress module)

    We can use try-except to check ASCII, but it's inefficient.

    try:
    s.encode('ascii')
    except UnicodeEncodeError:
    ascii = False
    else:
    ascii = True

    CPython can check string is ASCII efficiently.

    (Voting on python-ideas ML now)

    @methane methane added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Jan 26, 2018
    @vstinner
    Copy link
    Member

    (Voting on python-ideas ML now)

    https://mail.python.org/pipermail/python-ideas/2018-January/048737.html

    @methane methane changed the title Add str.isascii() Add.isascii() to str, bytes and bytearray Jan 26, 2018
    @methane
    Copy link
    Member Author

    methane commented Jan 27, 2018

    New changeset a49ac99 by INADA Naoki in branch 'master':
    bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342)
    a49ac99

    @methane
    Copy link
    Member Author

    methane commented Jan 28, 2018

    New changeset bea5706 by INADA Naoki in branch 'master':
    bpo-32677: Optimize str.isascii() (GH-5356)
    bea5706

    @methane methane closed this as completed Jan 28, 2018
    @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
    3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants