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 longer use implicit convertion to int with loss #82180

Closed
serhiy-storchaka opened this issue Sep 1, 2019 · 6 comments
Closed

No longer use implicit convertion to int with loss #82180

serhiy-storchaka opened this issue Sep 1, 2019 · 6 comments
Labels
3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Sep 1, 2019

BPO 37999
Nosy @mdickinson, @serhiy-storchaka, @hpjansson
PRs
  • bpo-37999: No longer use __int__ in implicit integer conversions. #15636
  • bpo-37999: Simplify the conversion code for %c, %d, %x, etc. #20437
  • bpo-37999: Fix outdated __int__ and nb_int references in comments #20449
  • bpo-36982: Add support for extended color functions in ncurses 6.1 #17536
  • 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 2020-05-28.08:12:43.571>
    created_at = <Date 2019-09-01.11:24:04.696>
    labels = ['interpreter-core', 'type-feature', '3.10']
    title = 'No longer use implicit convertion to int with loss'
    updated_at = <Date 2020-07-01.19:01:56.267>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-07-01.19:01:56.267>
    actor = 'hpj'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-28.08:12:43.571>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2019-09-01.11:24:04.696>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37999
    keywords = ['patch']
    message_count = 6.0
    messages = ['350947', '370004', '370063', '370072', '370173', '372622']
    nosy_count = 3.0
    nosy_names = ['mark.dickinson', 'serhiy.storchaka', 'hpj']
    pr_nums = ['15636', '20437', '20449', '17536']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue37999'
    versions = ['Python 3.10']

    Linked PRs

    @serhiy-storchaka
    Copy link
    Member Author

    Use only the __index__() method for implicit conversion to iteger, and not __int__().

    This converts deprecation warnings added in bpo-36048 into TypeError.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Sep 1, 2019
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 578c395 by Serhiy Storchaka in branch 'master':
    bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)
    578c395

    @mdickinson
    Copy link
    Member

    There are some comments in the Objects/longobject.c code that still refer to __int__, and could use an update.

    For example:

    /* Get a C long int from an int object or any object that has an __int__

    @mdickinson
    Copy link
    Member

    New changeset 20941de by Mark Dickinson in branch 'master':
    bpo-37999: Fix outdated __int__ and nb_int references in comments (GH-20449)
    20941de

    @serhiy-storchaka
    Copy link
    Member Author

    I think it is all here. Thank you Mark for your review and for fixing outdated docs and comments.

    @serhiy-storchaka serhiy-storchaka added the 3.10 only security fixes label May 28, 2020
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset e67f7db by Serhiy Storchaka in branch 'master':
    bpo-37999: Simplify the conversion code for %c, %d, %x, etc. (GH-20437)
    e67f7db

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    hugovk added a commit to hugovk/cpython that referenced this issue Jul 27, 2022
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 12, 2022
    ….getgrgid in 3.10 (pythonGH-95346)
    
    (cherry picked from commit 50bf5fa)
    
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 12, 2022
    ….getgrgid in 3.10 (pythonGH-95346)
    
    (cherry picked from commit 50bf5fa)
    
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    ambv pushed a commit that referenced this issue Aug 12, 2022
    …gid in 3.10 (GH-95346) (GH-95929)
    
    (cherry picked from commit 50bf5fa)
    
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    ambv pushed a commit that referenced this issue Aug 12, 2022
    …gid in 3.10 (GH-95346) (GH-95930)
    
    (cherry picked from commit 50bf5fa)
    
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    karlp added a commit to karlp/KiCost that referenced this issue Sep 14, 2022
    Apparently python 3.10 no longer silently truncates floats to ints,
    (see python/cpython#82180)
    
    Current code passes a float to the wxGauge progress bar, which then
    prints (not) tracebacks like:
    
    TypeError: Gauge.SetValue(): argument 1 has unexpected type 'float'
    Traceback (most recent call last):
      File "/usr/lib64/python3.10/site-packages/wx/core.py", line 3285, in <lambda>
        lambda event: event.callable(*event.args, **event.kw) )
    
    At least someone is catching and ignoring the exception, so the app
    works, just the progress bar is broken.
    
    It just needs to be explicitly forced to an int to make it work again
    
    Signed-off-by: Karl Palsson <karlp@etactica.com>
    andy-sweet pushed a commit to napari/napari that referenced this issue Jan 19, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    vstinner added a commit to vstinner/cpython that referenced this issue Jun 6, 2023
    vstinner added a commit to vstinner/cpython that referenced this issue Jun 6, 2023
    Czaki pushed a commit to napari/napari that referenced this issue Jun 16, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    Czaki pushed a commit to napari/napari that referenced this issue Jun 17, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    Czaki pushed a commit to napari/napari that referenced this issue Jun 18, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    Czaki pushed a commit to napari/napari that referenced this issue Jun 19, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    Czaki pushed a commit to napari/napari that referenced this issue Jun 21, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    Czaki pushed a commit to napari/napari that referenced this issue Jun 21, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    Czaki pushed a commit to napari/napari that referenced this issue Jun 21, 2023
    …3.10 (#5467)
    
    # Description
    Python 3.10 no longer casts floats to ints
    python/cpython#82180
    
    The variable `POLL_INTERVAL_MS` is used by QTimer and the
    `setInterval()` needs an int (in milliseconds), see:
    https://doc.qt.io/qt-5/qtimer.html
    
    This means that in python 3.10 the existing value (16.666) results in a
    TypeError (see #5415 ) and napari doesn't even launch.
    
    Note: This is part of the experimental async/octree and apparently not
    tested on 3.10 CI.
    
    `POLL_INTERVAL_MS` is fairly arbitrary and unused anywhere else, so in
    this PR I simply assign an int to it, `16` rather than the `16.666`
    (~1/60).
    
    
    ## Type of change
    <!-- Please delete options that are not relevant. -->
    - [x] Bug-fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
    - [ ] This change requires a documentation update
    
    # References
    
    Closes #5415 
    
    # How has this been tested?
    <!-- Please describe the tests that you ran to verify your changes. -->
    - [ ] example: the test suite for my feature covers cases x, y, and z
    - [ ] example: all tests pass with my change
    - [x] example: If I enable the experimental features in settings, then
    napari won't launch on main (as in the issue) but will launch with this
    branch.
    
    ## Final checklist:
    - [x] My PR is the minimum possible work for the desired functionality
    - [x] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have added tests that prove my fix is effective or that my
    feature works
    - [ ] If I included new strings, I have used `trans.` to make them
    localizable.
    For more information see our [translations
    guide](https://napari.org/developers/translations.html).
    adrientetar added a commit to trufont/trufont that referenced this issue Jun 24, 2023
    Implicit cast of float to int was removed, c.f. python/cpython#82180
    
    Also move the custom excepthook above since new versions of PyQt will abort on unhandled exceptions in absence of a custom hook.
    adrientetar added a commit to trufont/trufont that referenced this issue Jun 24, 2023
    Implicit cast of float to int was removed, c.f. python/cpython#82180
    
    Also move the custom excepthook above since new versions of PyQt will abort on unhandled exceptions in absence of a custom hook.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 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