mhammond / pywin32

Python for Windows (pywin32) Extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version 306 has an indentation issue in gencache.py which causes an error

AndyCWB opened this issue · comments

  • Expected behavior and actual behavior.
    Expected: import of win32 modules does not produce an error.
    Actual (edited to remove proprietary path information:
Error: inconsistent use of tabs and spaces in indentation (gencache.py, line 64)  File "<string>", line 101, in <module>
      File ".........python38\\lib\\site-packages\\xxxxx\\os_help\\win_help.py\", line 22, in <module>
        import win32com.client
      File ".........python38\\lib\\site-packages\\win32com\\client\\__init__.py\", line 14, in <module>
        from . import dynamic, gencache
  • Steps to reproduce the problem.
    import win32com.client

  • Version of Python and pywin32
    Python 3.8.18 and pywin32 v306

  • Fix: convert all indentation to spaces in the usage() function - lines 771-776 in gencache.py

Something doesn't seem to add up. The exception mentions gencache.py:64, not gencache.py:771-776. Line 64 doesn't have mixed indentation. It also seems like usage method could only be called from executing the module anyway, not importing it. Tabs in strings is fine anyway.

I was not able to replicate, even with this simplified scenario:

import sys
print(sys.version)
print(sys.platform)

def usage():
    usageString = """\
	  Usage: gencache [-q] [-d] [-r]

			 -q         - Quiet
			 -d         - Dump the cache (typelibrary description and filename).
			 -r         - Rebuild the cache dictionary from the existing .py files
	"""
    print(usageString)
      
usage()
3.8.5 (default, Jul 20 2020, 23:11:29) 
[GCC 9.3.0]
linux
	  Usage: gencache [-q] [-d] [-r]

			 -q         - Quiet
			 -d         - Dump the cache (typelibrary description and filename).
			 -r         - Rebuild the cache dictionary from the existing .py files
	

I still think it would be better to not mix indent in strings out of principle and consistency (and this isn't caught by black because it's in a string obviously). So I opened #2167