Skip to content
Snippets Groups Projects
  1. May 21, 2019
    • stijn's avatar
      py/objarray: Add decode method to bytearray. · fb54736b
      stijn authored
      Reuse the implementation for bytes since it works the same way regardless
      of the underlying type.  This method gets added for CPython compatibility
      of bytearray, but to keep the code simple and small array.array now also
      has a working decode method, which is non-standard but doesn't hurt.
      fb54736b
  2. May 14, 2019
  3. May 09, 2019
  4. May 06, 2019
  5. May 03, 2019
  6. Apr 30, 2019
    • Paul Sokolovsky's avatar
      tests/ussl_basic: Disable setblocking() calls. · 7b540013
      Paul Sokolovsky authored
      Now that setblocking() is implemented in modussl_axtls, it calls into the
      underlying stream object, and io.BytesIO doesn't have setblocking().
      7b540013
    • Paul Sokolovsky's avatar
      extmod/modussl_axtls: Add non-blocking mode support. · c7644531
      Paul Sokolovsky authored
      It consists of:
      
      1. "do_handhake" param (default True) to wrap_socket(). If it's False,
      handshake won't be performed by wrap_socket(), as it would be done in
      blocking way normally. Instead, SSL socket can be set to non-blocking mode,
      and handshake would be performed before the first read/write request (by
      just returning EAGAIN to these requests, while instead reading/writing/
      processing handshake over the connection). Unfortunately, axTLS doesn't
      really support non-blocking handshake correctly. So, while framework for
      this is implemented on MicroPython's module side, in case of axTLS, it
      won't work reliably.
      
      2. Implementation of .setblocking() method. It must be called on SSL socket
      for blocking vs non-blocking operation to be handled correctly (for
      example, it's not enough to wrap non-blocking socket with wrap_socket()
      call - resulting SSL socket won't be itself non-blocking).  Note that
      .setblocking() propagates call to the underlying socket object, as
      expected.
      c7644531
  7. Apr 28, 2019
  8. Apr 18, 2019
  9. Apr 04, 2019
    • stijn's avatar
      tests/run-tests: Ignore exception in process kill when ending repl test. · d89ce2ed
      stijn authored
      When running Linux on WSL, Popen.kill() can raise a ProcessLookupError if
      the process does not exist anymore, which can happen here since the
      previous statement already tries to close the process by sending Ctrl-D to
      the running repl.  This doesn't seem to be a problem on other OSes, so just
      swallow the exception silently since it indicates the process has been
      closed already, which after all is what we want.
      d89ce2ed
  10. Mar 26, 2019
  11. Mar 08, 2019
  12. Mar 05, 2019
    • Damien George's avatar
      py/persistentcode: Add a qstr window to save mpy files more efficiently. · 5996eeb4
      Damien George authored
      This is an implementation of a sliding qstr window used to reduce the
      number of qstrs stored in a .mpy file.  The window size is configured to 32
      entries which takes a fixed 64 bytes (16-bits each) on the C stack when
      loading/saving a .mpy file.  It allows to remember the most recent 32 qstrs
      so they don't need to be stored again in the .mpy file.  The qstr window
      uses a simple least-recently-used mechanism to discard the least recently
      used qstr when the window overflows (similar to dictionary compression).
      This scheme only needs a single pass to save/load the .mpy file.
      
      Reduces mpy file size by about 25% with a window size of 32.
      5996eeb4
    • Damien George's avatar
      py: Replace POP_BLOCK and POP_EXCEPT opcodes with POP_EXCEPT_JUMP. · 5a2599d9
      Damien George authored
      POP_BLOCK and POP_EXCEPT are now the same, and are always followed by a
      JUMP.  So this optimisation reduces code size, and RAM usage of bytecode by
      two bytes for each try-except handler.
      5a2599d9
    • Damien George's avatar
      py: Fix VM crash with unwinding jump out of a finally block. · e1fb03f3
      Damien George authored
      This patch fixes a bug in the VM when breaking within a try-finally.  The
      bug has to do with executing a break within the finally block of a
      try-finally statement.  For example:
      
          def f():
              for x in (1,):
                  print('a', x)
                  try:
                      raise Exception
                  finally:
                      print(1)
                      break
                  print('b', x)
          f()
      
      Currently in uPy the above code will print:
      
          a 1
          1
          1
          segmentation fault (core dumped)  micropython
      
      Not only is there a seg fault, but the "1" in the finally block is printed
      twice.  This is because when the VM executes a finally block it doesn't
      really know if that block was executed due to a fall-through of the try (no
      exception raised), or because an exception is active.  In particular, for
      nested finallys the VM has no idea which of the nested ones have active
      exceptions and which are just fall-throughs.  So when a break (or continue)
      is executed it tries to unwind all of the finallys, when in fact only some
      may be active.
      
      It's questionable whether break (or return or continue) should be allowed
      within a finally block, because they implicitly swallow any active
      exception, but nevertheless it's allowed by CPython (although almost never
      used in the standard library).  And uPy should at least not crash in such a
      case.
      
      The solution here relies on the fact that exception and finally handlers
      always appear in the bytecode after the try body.
      
      Note: there was a similar bug with a return in a finally block, but that
      was previously fixed in b7352084
      e1fb03f3
  13. Feb 26, 2019
  14. Feb 21, 2019
  15. Feb 13, 2019
  16. Jan 27, 2019
  17. Dec 12, 2018
  18. Dec 10, 2018
  19. Dec 07, 2018
  20. Dec 06, 2018
    • Damien George's avatar
      py/objboundmeth: Support loading generic attrs from the method. · 113f00a9
      Damien George authored
      Instead of assuming that the method is a bytecode object, and only
      supporting load of __name__, make the operation generic by delegating the
      load to the method object itself.  Saves a bit of code size and fixes the
      case of attempting to load __name__ on a native method, see issue #4028.
      113f00a9
  21. Dec 05, 2018
  22. Dec 04, 2018
  23. Nov 26, 2018
  24. Nov 01, 2018
  25. Oct 30, 2018
  26. Oct 27, 2018
  27. Oct 23, 2018
Loading