mandarons / icloudpy

iCloud web service interface library in Python
Other
179 stars 17 forks source link

AttributeError: 'NoneType' object has no attribute 'isatty' #23

Closed clstaudt closed 1 year ago

clstaudt commented 1 year ago

https://github.com/mandarons/icloudpy/blob/e7edabd2f82fc217d8504cacf9e942e5d7a9808b/icloudpy/utils.py#L12

Running this from an app packaged with pyinstaller on Windows raises:

Traceback (most recent call last):
  File "app.py", line 18, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "tuttle\__init__.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "tuttle\calendar.py", line 11, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "icloudpy\__init__.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "icloudpy\base.py", line 21, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "icloudpy\services\__init__.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "icloudpy\services\account.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "icloudpy\utils.py", line 12, in <module>
AttributeError: 'NoneType' object has no attribute 'isatty'
mandarons commented 1 year ago

Looks like stdout is None. Not sure how exactly you're using the library but here are few references to look at:

https://docs.python.org/3/library/sys.html#sys.__stderr__

https://stackoverflow.com/questions/67610859/show-stdout-with-pyinstaller-noconsole

clstaudt commented 1 year ago

@mandarons Since stdout can be None in some cases, this should be considered a bug in the library. The default argument should be set to None and the parameter should be determined later, with proper error handling. Would you agree?

mandarons commented 1 year ago

Ohh yes. This case needs to be handled in icloudpy.

clstaudt commented 1 year ago

@mandarons Can you give us an ETA for a new version?

mandarons commented 1 year ago

@clstaudt Can you please try using main branch and see if that fixes the issue?