piface / pifacecommon

Common functions for interacting with PiFace products
GNU General Public License v3.0
42 stars 30 forks source link

Upgrade to 4.0 has UnboundLocalError in deinit #6

Closed chrisalexander closed 10 years ago

chrisalexander commented 10 years ago

I just upgraded common to v4.0.0 and digitalio to v3.0.0. When I call pifacedigitalio.deinit() I now get the following message:

Exception UnboundLocalError: UnboundLocalError("local variable 'pfd' referenced before assignment",) in <bound method AmoebaTwo.del of <amoebatwo.AmoebaTwo object at 0xb69e0830>> ignored

I didn't see this previously and I'm not sure if it's causing any problems, but as its in the del it doesn't make a lot of difference.

I checked I had followed the installation instructions and all appears to be well.

Any thoughts on this? I played around with the code a bit but didn't seem to ever get to a situation with no errors. Not calling deinit is the workaround for now but I would prefer to have this cleaning up correctly.

Thanks =)

tompreston commented 10 years ago

Ah, it's because the pfd variable is being referenced in a finally clause instead of an else. I'll push a fix soon.

tompreston commented 10 years ago

By the way, deinit just disables the interrupts on a PiFace Digital which you can do by running:

pfd = pifacedigitalio.PiFaceDigital()
pfd.disable_interrupts()

pifacedigitalio.deinit() is just there for backwards compatibility and digital_read()/digital_write().

chrisalexander commented 10 years ago

Awesome, thanks.

tompreston commented 10 years ago

It should be fixed now, try downloading the latest version (4.0.2). :-)