Ticket #78 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Stub patch for cleanup checks in python bindings

Reported by: insomniac Owned by: dsmith
Priority: major Milestone:
Component: other Version:
Keywords: Cc:

Description

I'm absolutely new to cwiid. I downloaded it for the first time a couple of hourse ago, so I don't know if I'm acting the right way. Anyway, I tried a sequence of commands like this:

$ python Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import cwiid wiimote = cwiid.Wiimote() wiimote.led = 1 wiimote.close() wiimote.led = 1

Segmentation fault

Looking at the code in the python/ directory, I see that there's no check on the self->wiimote pointer whether it's NULL or not. I think the correct approach would be to raise an exception, but I'm not familiar with Python bindings, so I wrote a small patch that just returns NULL in case the self->wiimote is NULL. A more experienced programmer may replace the "return NULL" with something better.

The patch is located at http://insomniac.slackware.it/download/cwiid-0.6.00.self-wiimote.patch and also attached to the ticket.

Best regards, Andrea Barberio

Attachments

cwiid-0.6.00.self-wiimote.patch (3.2 kB) - added by insomniac 3 years ago.
Patch for memory violation after the resources are released
j78-closed-wiimote-value-error.patch (5.9 kB) - added by jonaskoelker 3 years ago.
Improved handling of closed wiimotes

Change History

Changed 3 years ago by insomniac

Patch for memory violation after the resources are released

Changed 3 years ago by jonaskoelker

Improved handling of closed wiimotes

Changed 3 years ago by jonaskoelker

Some of the functions should return ints (and return -1 in the case of error). Also, one should tell the python interpreter that an error has occurred (via, say, PyErr?_SetString(PyExc?_ValueError, "wiimote is closed")).

I've attached a patch which fixes this (and touches up Wiimote.c a little bit; includes cwiid_internal.h to declare send_event; removes an unused variable, `Time').

Changed 3 years ago by dsmith

  • status changed from new to closed
  • resolution set to fixed

Patch applied, with changes (r186, r187). Why is cwiid_internal.h required?

Note: See TracTickets for help on using tickets.