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

No __mod__ on str subclass #37231

Closed
nascheme opened this issue Sep 27, 2002 · 3 comments
Closed

No __mod__ on str subclass #37231

nascheme opened this issue Sep 27, 2002 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@nascheme
Copy link
Member

BPO 615506
Nosy @gvanrossum, @nascheme
Files
  • str_mod.diff
  • 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 = 'https://github.com/nascheme'
    closed_at = <Date 2002-11-17.20:34:00.000>
    created_at = <Date 2002-09-27.14:35:28.000>
    labels = ['interpreter-core']
    title = 'No __mod__ on str subclass'
    updated_at = <Date 2002-11-17.20:34:00.000>
    user = 'https://github.com/nascheme'

    bugs.python.org fields:

    activity = <Date 2002-11-17.20:34:00.000>
    actor = 'gvanrossum'
    assignee = 'nascheme'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2002-09-27.14:35:28.000>
    creator = 'nascheme'
    dependencies = []
    files = ['624']
    hgrepos = []
    issue_num = 615506
    keywords = []
    message_count = 3.0
    messages = ['12520', '12521', '12522']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'nascheme']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue615506'
    versions = []

    @nascheme
    Copy link
    Member Author

    PyNumber_Remainder does not use __mod__ on str and unicode
    subclasses. I guess the fix would be to check for
    nb_remainder first
    and then fallback to PyString_Format or PyUnicode_Format.

    @nascheme nascheme self-assigned this Sep 27, 2002
    @nascheme nascheme added interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 27, 2002
    @nascheme
    Copy link
    Member Author

    Logged In: YES
    user_id=35752

    The attached patch adds __mod__ to the 'str' and 'unicode'
    types. The side effect of this is that PyNumber_Check returns
    true for these types. This is not a huge loss since
    PyNumber_Check is already pretty useless. selectmodule.c
    was affected by this and was fixed by improving the error
    message returned by PyFloat_AsDouble (matching what
    PyInt_AsLong does) and using it to convert the timeout
    argument to a float.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Looks good to me.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 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)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants