GithubHelp home page GithubHelp logo

Comments (8)

robhagemans avatar robhagemans commented on July 28, 2024

This may have to do with the inability to pickle memoryview objects, see https://bugs.python.org/issue27098

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024
  • Does not happen if we simply define a variable i.
  • Does not happen if we allow the program to finish and then exit.
  • Does happen if we include a STOP statement and exit after the break.
  • Also happens if we interrupt PC-BASIC with Alt+F4 while the program is running.

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024

Another suspect is the ByteStream class which is derived from _pyio.BytesIO

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024

10 i=1: goto 10 does not have the issue. FOR loops only?

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024

interpreter.py lines 385, 386:

        counter_view = self._scalars.view(varname)
        self.for_stack.append((varname, counter_view, stop, step, step.sign(), forpos, nextpos,))

This stores a view in a structure that is to be pickled - may be the cause?

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024

The memoryview is the issue. Apparently I'm storing most variables simply as bytearrays, but in a FOR-loop I'm keeping a copy of the Value object, which contains a memoryview. Adding __setstate__ and __getstate__ to Value to convert the memoryview to bytearray and back avoids the crash, but cuts the connection between the loop variable and the view of it which is being incremented.

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024

As far as I can see, the loop record contains the Value objects counter_view, stop and step. Not sure why the Scalars object itself pickles without problems in the absence of a FOR-loop.

from pcbasic.

robhagemans avatar robhagemans commented on July 28, 2024

Fixed by 35e5640

from pcbasic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.