Skip to content

Screen: TypeError: integer argument expected, got float #128

Closed

Description

@251
>>> import ev3dev.ev3 as ev3
>>> s = ev3.Screen()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/python_ev3dev-0.6.0-py3.4.egg/ev3dev/core.py", line 2310, in __init__
    "white")
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2030, in new
    return Image()._new(core.fill(mode, size, color))
TypeError: integer argument expected, got float

It works with integer division in core.py:Screen

<                 (self.fix_info.line_length * 8 / self.var_info.bits_per_pixel, self.yres),

---
>                 (self.fix_info.line_length * 8 // self.var_info.bits_per_pixel, self.yres),

Activity

  1. ddemidov commented on Jan 21, 2016

    @ddemidov
    Member

    Thanks! Can you make a pull request?

  2. 251 commented on Jan 21, 2016

    @251
    ContributorAuthor

    It depends on how we solve this issue. My solution is Python3 specific, because I'm not interested in 2.x. We could add new features (from __future__ import division) and remove many casts or add another explicit type conversion here...

  3. ddemidov commented on Jan 21, 2016

    @ddemidov
    Member

    Integer division // seems to work on python2 as well:

    $ python2
    Python 2.7.11 (default, Dec  6 2015, 15:43:46) 
    [GCC 5.2.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 3 / 2
    1
    >>> 3 // 2
    1
    >>> 
    
  4. 251 commented on Jan 21, 2016

    @251
    ContributorAuthor

    It was PEP238 (15 years ago for 2.2).

  5. ddemidov commented on Jan 21, 2016

    @ddemidov
    Member

    Why do you say your solution is python3 specific then?

  6. 251 commented on Jan 21, 2016

    @251
    ContributorAuthor

    Because I'm old. ;)

  7. rhempel commented on Jan 22, 2016

    @rhempel
    Member

    Will merge this weekend - thks for the fix!

  8. added a commit that references this issue on Mar 12, 2016
    1c9265d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions