Mock.GPIO icon indicating copy to clipboard operation
Mock.GPIO copied to clipboard

[BUG] Global variables not set correctly on Python 3.11

Open quellus opened this issue 11 months ago • 0 comments

Describe the bug Variables such as setModeDone and _mode aren't set correctly.

I believe this is only an issue specifically with the setmode() function. After calling setmode(), the results of getmode() and setModeDone remain unchanged.

To Reproduce Steps to reproduce the behavior:

  1. call setmode()
  2. call getmode() and view the return value
  3. return value remains 0 regardless of what you set the mode to
  4. view the contents of setModeDone
  5. setModeDone is False despite that you just set mode

Expected behavior After calling, for example, setmode(GPIO.BCM), getmode() should return 11 setModeDone should contain True

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] N/A
  • Version [e.g. 22] 0.1.10
  • Python Version 3.11.9

Additional context The solution should really just be a 2 line change. At the top of the setmode function, add:

global setModeDone
global _mode

quellus avatar Mar 03 '25 00:03 quellus