This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: The strangest glitch I have ever seen - incorrect indenterror, even on commented out code.
Type: behavior Stage: resolved
Components: Build, Cross-Build Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Alex.Willmer, bob.vegena, eric.smith, steven.daprano, tim.peters
Priority: normal Keywords:

Created on 2019-05-27 01:17 by bob.vegena, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sys32pack.py bob.vegena, 2019-05-27 01:17 The bug causer
sys32pack.py bob.vegena, 2019-05-27 01:50
Messages (10)
msg343591 - (view) Author: Bob Vegene (bob.vegena) Date: 2019-05-27 01:17
So, I'm making a simple program that will allow me to quickly copy programs to System32 for use on the command line. When I tried testing this in a file called test.py in the same directory as sys32move.py, I got a very strange error. IndentError. I am very experienced with python and I know how to fix this and why it is caused. I fixed what I thought I could, but the I realized something was off. 

I commented out everything in sys32move.py and it still outputs this error.

Now, commenting this out is unnecessary, as this is a false error anyway.


This is test.py:
try:
    import sys32pack
    install_folder(testfolder)
except Exception as e:
    print(e)
    input()

(you get same behavior without the catching of the error.)


SYS32PACK.py:
msg343592 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-05-27 01:25
Hi Bob, and welcome. Can you copy and paste the actual traceback or error you get? It isn't obvious from your description what the error is.

Just glancing at the attached sample code, I see what seems to be an obvious indentation error:

    for _ in range(len(files)):
        try:
            e = files[x] # e = the file with a paramater of x
            os.copy(e,"C:\\Windows\\System32") # copy the file to system32
        except Exception as e:
            print(Fore.RED,"Could not install file ",x,". The following error occurred: ",e,Fore.WHITE)
        print(Fore.GREEN,"Installed file ",e,Fore.WHITE)
            if x>=len(files):  # if x is more than or equal to the number of files in teh directory
                print(Fore.GREEN,"Installed ",Fore.WHITE)


Notice that the "if" statement is indented under the print. Is that the cause of your error?
msg343593 - (view) Author: Bob Vegene (bob.vegena) Date: 2019-05-27 01:29
No, I removed that before. I actually did have one, but I removed that and it still shows.
msg343594 - (view) Author: Bob Vegene (bob.vegena) Date: 2019-05-27 01:30
The error it gives is 

unexpected indent (sys32pack.py, line 41)

(im also using IDLE)

FYI.
msg343597 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2019-05-27 01:47
As Steven said, there's an obvious indentation error in the file you actually attached.  So nobody can _guess_ what your problem is.  Please upload a file showing your actual problem.

If I increase the indentation of the `print` Steven identified to match the indentation of the `print` before it, IDLE's Run -> Check Module has no complaints.
msg343598 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-05-27 01:48
Sorry Bob, are you telling us that the code you submitted to demonstrate 
the error isn't the code that demonstrates the error?

Perhaps you could read this:

http://www.sscce.org/

for some ideas on how to submit a good bug report. It is written for 
Java programmers but most of it applies equally to Python.
msg343599 - (view) Author: Bob Vegene (bob.vegena) Date: 2019-05-27 01:50
uhm, the current file is attached now

is there some sort of error and you guys see it differently???

i can't be the only one getting this. I swear i have everything right, and i'll attach an image if i need too.
msg343600 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-05-27 01:51
Line 41 is indented 4 spaces past line 38, but should not be.

You'd be better served by first asking questions like this on the python-list mailing list.
msg343601 - (view) Author: Bob Vegene (bob.vegena) Date: 2019-05-27 01:56
I decided to check the file in notepad++ and I saw that there actually is an indentationerror... However, the save button wasn't working I guess. I can't tell you how many times i hit ctrl+s and clicked save. Wow, so it still is a bug.
msg343602 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2019-05-27 02:07
Same kind of problem with the new upload, Bob.

Line 38 is:

print(Fore.GREEN,"Installed file ",e,Fore.WHITE)

indented 8 spaces. Lines 39 and 40 are empty.  Then line 41 is:

if x>=len(files):  # if x is more than or equal to the number of files in teh directory

indented 12 spaces.  That's an indentation error, indented more than the statement before it.

Maybe you have some kind of weird binary data (by mistake) in the file that gets lost when you upload it?
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81242
2019-05-27 02:07:43tim.peterssetmessages: + msg343602
2019-05-27 01:56:35bob.vegenasetmessages: + msg343601
2019-05-27 01:51:39eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg343600

resolution: not a bug
stage: resolved
2019-05-27 01:50:03bob.vegenasetfiles: + sys32pack.py

messages: + msg343599
2019-05-27 01:48:40steven.dapranosetmessages: + msg343598
2019-05-27 01:47:19tim.peterssetnosy: + tim.peters
messages: + msg343597
2019-05-27 01:30:14bob.vegenasetmessages: + msg343594
2019-05-27 01:29:10bob.vegenasetmessages: + msg343593
2019-05-27 01:25:44steven.dapranosetnosy: + steven.daprano
messages: + msg343592
2019-05-27 01:17:32bob.vegenacreate