Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move function does not take None #684

Closed
arisliang opened this issue Mar 31, 2022 · 2 comments
Closed

move function does not take None #684

arisliang opened this issue Mar 31, 2022 · 2 comments

Comments

@arisliang
Copy link

arisliang commented Mar 31, 2022

There's an example usage in readme pyautogui.move(None, 10).

It runs with error in repl:

int() argument must be a string, a bytes-like object or a number, not 'NoneType'

version: '0.9.53'
windows 10

JayRizzo added a commit to JayRizzo/pyautogui that referenced this issue Apr 15, 2022
Hi all, This is a quick fix for asweigart#684.  Please update if needed.  This is in addition to asweigart#559 asweigart#592 that have already been merged.
@JayRizzo
Copy link
Contributor

Hi @arisliang, I hope you are doing well. Yes, I see this too.

This behaviour changed after 3.10 None values do not behave the same. As you can no longer run int(None). Which throws the [Type Conversion error] (https://docs.python.org/3.10/library/functions.html#int). But it should not as it hasn't even been updated yet in the main documentation. int(None) ""used"" to return Zero, hence why we are seeing this complain.

int(None)
# Traceback (most recent call last):
#  File "<stdin>", line 1, in <module>
# TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

I did some digging around and created a fix for you. if you want to resolve this on your machine as a workaround until this gets resolved do the following.

Update Yourself (Workaround)

Locate your pyautogui init file

in your error you will get the path to the file it is complaining on line 701 of pyautogui.init Copy that path and open the file in your text editor.

THEN: Paste these two lines into your existing pyautogui installed package: (mine is line 701 & 702):

        firstArg = 0 if firstArg is None else firstArg
        secondArg = 0 if secondArg is None else secondArg

It should look like this:

    else:
        firstArg = 0 if firstArg is None else firstArg
        secondArg = 0 if secondArg is None else secondArg
        return Point(int(firstArg), int(secondArg))  # firstArg and secondArg are just x and y number values

You can reference my commit if it helps visually.

  1. Save the file.
  2. Close & Reopen your python terminal or interactive session.
  3. ReOpen it and retry your code OR rerun your file. It should work.
  4. If you break something and forgot what you changed you can revert all changes by running.
pip install pyautogui --upgrade --force

# OR

pip3 install pyautogui --upgrade --force

Found & fixed a Separate Issue

** Now in my search I discovered another odd behaviour that I addressed in #690. and PR691
Separately, but just as an FYI.

Have a Great day!

@arisliang
Copy link
Author

Thanks for the fix. I can wait for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants