Page 1 of 1

New bytearray implementation buggy or not used as intended?

Posted: Sun Jan 04, 2015 1:36 pm
by kfricke
With firmware verisons 1.3.7 I can run the OLED display library forked from the other thread without any problems (SSD1306 using I2C). After updating the firmware to any 1.3.8 version I do get the following TypeError:

Code: Select all

Micro Python v1.3.8-9-g8a2cc1c on 2014-12-30; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import ssd1306_test2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ssd1306_test2.py", line 30, in <module>
  File "ssd1306.py", line 179, in init_display
  File "ssd1306.py", line 120, in clear
TypeError: 'int' object is not iterable
>>>
Within this library a bytearray gets initialized with a computed size:

Code: Select all

def clear(self):
        """Clears the display buffer. This is equivalent to setting the 
        whole screen black."""
        self.display_buffer = bytearray(self.offset + self.pages * self.width)
        if self.offset == 1:
            self.display_buffer[0] = CTL_DAT
Of course we do see a lot of recent changes around the bytearray thingy. Am I using this not as intended anymore? I did check the soure-code and the test cases in Github, but i have no real clue on what i may do wrong. Maybe initializing the bytearray with an integer or integer arithmetic result (int object) is handled differently!?

If this is a bug i will of course file one on Github. Just wanted to make sure this is not my fault :?

Re: New bytearray implementation buggy or not used as intend

Posted: Sun Jan 04, 2015 2:04 pm
by pfalcon
I did check the soure-code and the test cases in Github
Why so complicated (based on your other messages too)? The standard procedure should be: 1) test micropython build for the host; 2) compare with CPython behavior; 3) check the docs at http://docs.micropython.org/ . At this point, it's fair to submit a bug, and looking into source code can come after that ;-).

Anyway, please submit bug, citing following testcase:

Code: Select all

bytearray(2**65 - (2**65 - 1))

Re: New bytearray implementation buggy or not used as intend

Posted: Sun Jan 04, 2015 3:17 pm
by kfricke
pfalcon wrote:Why so complicated (based on your other messages too)?
I do simply try to understand the things I talk about.