From 163c93aaad39a4c0c9c9f21a652557f9fd71f6c9 Mon Sep 17 00:00:00 2001
From: Wander Lairson Costa <wander.lairson@gmail.com>
Date: Thu, 21 Feb 2013 22:02:16 -0300
Subject: [PATCH] Fixed: make sure there is a valid handle before do a reset.

If reset method is called without a valid device handle, we will
probably have a crash. So, call managed_open before calling reset.
---
 usb/core.py |    1 +
 1 file changed, 1 insertion(+)

diff --git a/usb/core.py b/usb/core.py
index 376948c..597637f 100644
--- a/usb/core.py
+++ b/usb/core.py
@@ -590,6 +590,7 @@ class Device(object):
 
     def reset(self):
         r"""Reset the device."""
+        self._ctx.managed_open()
         self._ctx.dispose(self, False)
         self._ctx.backend.reset_device(self._ctx.handle)
         self._ctx.dispose(self, True)
-- 
1.7.10.4

