blockpy-edu / blockpy

Blockly that's more Python than JavaScript, powered with Skulpt
Apache License 2.0
398 stars 133 forks source link

get_output not working #47

Closed lukesg08 closed 5 years ago

lukesg08 commented 5 years ago

calls to get output causing error seen below

Feedback: Internal Error Internal Error Error in instructor feedback. Please show the following to an instructor: AttributeError: '' object has no attribute 'output' File "src/lib/pedal/sandbox/compatibility.py", line 48 File "_instructor.on_run.py", line 56

lukesg08 commented 5 years ago

see problem 8.5, problem is not across all problems

acbart commented 5 years ago

Oh man, this one was crazy. I've been on it for the past few hours, and it's my own fault. Basically, it's not what you'd probably think.

First, the get_output function works just fine. Or rather, when the system properly patches Sandbox's get_output function, things work just fine. In this case, the system patched it, but it got overwritten when the following code was run in 8.5:

from pedal.mistakes.iteration_context import *

Inside the iteration_context module, the following line of code managed to dig up an unpatched copy of get_output, and the import star brought it into the instructor's on_run namespace:

from pedal.sandbox.compatibility import get_output

Now, the question became where did that unpatched get_output come from? The way I patched things, a regular Python installation wouldn't have any issues. Initially, I thought Skulpt wasn't doing the right thing, but after downloading a fresh copy I was able to verify I had broken something. Turns out some of the modifications I made for Python 3 compatibility stuff were faulty and did the wrong thing. Long story short, I was preventing the system from noticing that it had already loaded the module. I believe I have it fixed and live on the server - I think the right feedback shows now.

That was awful, lost an entire afternoon to 5 lines of code that I wrote :P