New bytearray implementation buggy or not used as intended?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

New bytearray implementation buggy or not used as intended?

Post by kfricke » Sun Jan 04, 2015 1:36 pm

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 :?

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: New bytearray implementation buggy or not used as intend

Post by pfalcon » Sun Jan 04, 2015 2:04 pm

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))
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: New bytearray implementation buggy or not used as intend

Post by kfricke » Sun Jan 04, 2015 3:17 pm

pfalcon wrote:Why so complicated (based on your other messages too)?
I do simply try to understand the things I talk about.

Post Reply