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

Exception System.ArgumentOutOfRangeException #4002

Closed
3 tasks done
irmavheerden opened this issue Apr 25, 2024 · 1 comment
Closed
3 tasks done

Exception System.ArgumentOutOfRangeException #4002

irmavheerden opened this issue Apr 25, 2024 · 1 comment

Comments

@irmavheerden
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: left
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Screenshot

ERROR.pdf

Environment data

PS C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3>  & 'c:\Users\Irma\AppData\Local\Programs\Python\Python312\python.exe' 'c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '60511' '--' 'C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3\Untitled-1.py'
Traceback (most recent call last):
  File "c:\Users\Irma\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main 
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Irma\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../    run()
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
ydevd\_pydevd_bundle\pydevd_runpy.py", line 320, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3\Untitled-1.py", line 1
    & {
    ^
SyntaxError: invalid syntax
PS C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3> ^C
PS C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3>
PS C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3>  c:; cd 'c:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3'; & 'c:\Users\Irma\AppData\Local\Programs\Python\Python312\python.exe' 'c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '60558' '--' 'C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3\Untitled-1.py' 
Traceback (most recent call last):
  File "c:\Users\Irma\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Irma\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 320, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Irma\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3\Untitled-1.py", line 1
    & {
    ^
SyntaxError: invalid syntax
PS C:\Users\Irma\DropBox\IV23020006524\Task 24  Capstone Project 3\Task 24 Capstone Project 3>

Steps to reproduce

Task 19

Capstone Project II

Part 1 & 2

Irma van Heerden

IV23020006524

##=====importing libraries====
'''This is the section where you will import libraries'''
from datetime import date
today = date.today()

##=====.txt files=====

The .txt files must first be re-written to comply as per task specifications

It is commented out to keep all appended data from being erased

# # with open('users.txt','w') as file:

# # file.write('admin, adm1n')

# # file.write('\nmanager, man!up')

# # file.write('\nreception, callme')

# # file.close()

###====Login Section====

The login-section must have files for USERNAMES and PASSWORDS with which the existing user can be verified

All print()-statements are for readibility in output

All uncommented print()-statements are used to check for errors

print('LOGIN')

Create a file that stores the data for the USERNAMES.

usernames = []
user_name = input('Enter your username:\n').lower()

Append to usernames-list from users.txt-file

with open('users.txt','r') as file:
for lines in file:
temp = lines.strip()
temp = temp.split(', ')
usernames.append(temp[0])
#print(temp[0]) # To check for errors

Use the while-loop to validate the username in the usernames[]

count = 0
while user_name not in usernames:
print('Username incorrect.')
user_name = input('Enter your username:\n').lower()
count += 1
if user_name in usernames:
print('Username accepted')
print()
count += 1

Create a file that stores the data for PASSWORDS.

passwords = []
pass_word = input('Enter your password:\n').lower()

Append to passwords from users.txt-file

with open('users.txt','r') as file:
for lines in file:
temp = lines.strip()
temp = temp.split(', ')
passwords.append(temp[1])
#print(temp[1]) # To check for errors

Use the while-loop to validate the password in the passwords[]

count = 0
while pass_word not in passwords:
print('Password incorrect.')
pass_word = input('Enter your password:\n').lower()
count += 1
print()
if pass_word in passwords:
print('Password accepted')
print()

###====Presenting THE MENU to the appropriate user====

### Presenting the different menu's to the correct users using if-statement and else-statement

### The while-loop creates continuity for the user until they want to exit the menu

### The user input must be coneverted to lower case.

print('TASK MENU')
while True:
if user_name == 'admin':
print()
menu = input('''Select one of the following options:
r = Register a new user
a = Add a task to existing user
va = View all users tasks
vm = View my tasks
st = Statistics
e = Exit:\n''').lower()
print()

else:
    print()
    menu = input('''Select one of the following Options below:                     
    a   =   Add a task to existing user            
    va  =   View all users tasks
    vm  =   View my tasks
    e   =   Exit:\n''').lower()
    print()   

### REGISTERING A NEW USER
### The while-loop ensures that no user other than ADMIN can access this menu even if it was not presented to them.
if menu == 'r':
    while user_name != 'admin':
        print('You have made a wrong choice: Please try again')
        break
    print() 
    if user_name == 'admin':
        print('REGISTER A NEW USER')
        print()

        new_usernames = []
        ## To open and append usernames from user.txt-file
        with open('users.txt','r') as file:
            for lines in file:
                temp = lines.strip()
                temp = temp.split(', ')  
                new_usernames.append(temp[0])
                ## print(new_usernames) # To check for errors

        new_user = input('Enter the new username:\n').lower()
           
        ## Block code for checking USERNAMES
        while  new_user in new_usernames:
            print('This username already exists.')  
            new_user = input('Enter the new username:\n').lower()
            print() 
        if  new_user != new_usernames:
            new_usernames.append(new_user)
            print('New username accepted')
            ## print(new_user)
            ## print(new_usernames)
            print() 

        ### REGISTERING A NEW PASSWORD
        new_passwords = []
        ### To open and append to passwords from users.txt-file
        with open('users.txt','r') as file:
            for lines in file:
                temp = lines.strip()
                temp = temp.split(', ')  
                new_passwords.append(temp[1])
                ## print(new_passwords) # To check for errors

        new_password = input('Enter the new password:\n').lower()
            
        ### Block code for checking Passwords
        while new_password in new_passwords:
            print('This password already exists') 
            new_password = input('Enter the new password:\n').lower()
            print()  

        new_password_confirm = input('Conrirm the new password:\n').lower()                                    
        while  new_password_confirm != new_password:
            print('Confirmation of password incorrect.\n')
            print()     
            new_password = input('Enter the new password:\n').lower() 
            new_password_confirm = input('Conrirm the new password:\n').lower()
            print() 
    
        else: 
            new_password_confirm == new_password
            new_passwords.append(new_password_confirm)
            print('New password accepted')
            ## print(new_password)
            ## print(new_passwords)
            print() 

        ### The users.txt file must continiously be updated as it is the source for login validation
        file = open('users.txt','a')
        for user in new_usernames:
            (user) # The print statements had to be added for the correct output
        for word in new_passwords:
            (word) # This had to be added for the correct output   
        file.write(f'\n{user}, {word}')
        file.close()
        print()  

elif  menu == 'a':
    print('ASSIGN A NEW TASK')
    print() 
    usernames = []
    ### A new task can only be added to a user that already exists in the users.txt-file
    ### Append to usernames-list from updated users.txt-file 
    ### The username is essential for the task to be assigned to the correct user
    
    with open('users.txt','r') as file:
        for lines in file:
            temp = lines.strip()
            temp = temp.split(', ')  
            usernames.append(temp[0])
            ## print(temp[0]) # To check for errors
             
    task_user = input('Please enter the username assigned to task:\n')
    print()

    count = 0
    while task_user not in usernames:
        print('Invalid username') 
        print()
        user = input('Please enter the username assigned to task:\n') 

    if task_user in usernames: 
        print('COMPLETE REQUESTED INFORMATION:')
        user = task_user    
        task_title = input('\nTitle of task:\n' ).upper()
        description = input('\nDescription:\n').capitalize()
        date_due = input('\nDate due:format = yyyy-mm-dd\n') 
        status = input('\nTask completed: Yes or No\n').upper()
        print()

    ### Append input to tasks.txt file
    with open('tasks.txt','a') as file:
        file.write(f'\n{user}, {task_title}, {description}, {today}, {date_due}, {status}') 
    
elif menu == 'va':
    print('VIEW ALL TASKS')

    ### To view all users tasks both the users.txt file and tasks.txt file must open
    usernames = []
    with open('users.txt','r') as file:
        for lines in file:
            temp = lines.strip()
            temp = temp.split(', ')  
            usernames.append(temp[0])
        #print(usernames) # To check for errors

    tasks = []
    with open('tasks.txt','r') as tasks_file:
        tasks = tasks_file.readlines()   
        for lines in tasks:
            tasks = lines.strip()
            tasks = tasks.split(', ')
            ### The for-loop ensures that all users tasks are displayed in an easy to read format
            for usernames in tasks[0]:
                print(f'\nUSER:                        {tasks[0]}') 
                print(f'\nTASK:                        {tasks[1]}') 
                print(f'\nDESCRIPTION:                 {tasks[2]}') 
                print(f'\nDATE ASSIGNED:               {tasks[3]}')
                print(f'\nDUE DATE:                    {tasks[4]}')
                print(f'\nTASK COMPLETED: Yes or No:   {tasks[5]}\n')
                break

elif menu =='vm':
    ### Only tasks assigned to logged in user can be viewed 
    print('Tasks assigned to', user_name)
    print() 

    tasks = []
    with open('tasks.txt','r') as tasks_file:
        tasks = tasks_file.readlines()   
    for lines in tasks:
        tasks = lines.strip()
        tasks = tasks.split(', ')
        ### The if-statement ensures that only the user that is logged in, tasks are displayed in an easy to read format
        if user_name == tasks[0]:
            print(f'\nUSER:                        {tasks[0]}') 
            print(f'\nTASK:                        {tasks[1]}') 
            print(f'\nDESCRIPTION:                 {tasks[2]}') 
            print(f'\nDATE ASSIGNED:               {tasks[3]}')
            print(f'\nDUE DATE:                    {tasks[4]}')
            print(f'\nTASK COMPLETED: Yes or No:   {tasks[5]}\n')

elif menu == 'st':
    ### The while-loop ensures that no user other than ADMIN can access this menu
    while user_name != 'admin':
        print('You have made a wrong choice: Please try again')
        break
    print() 
    if user_name == 'admin':
        print('STATISTICS')
        print() 
    
        usernames = []    
        ## Append to usernames-list from updated users.txt-file 
        with open('users.txt','r') as file:
            for lines in file:
                temp = lines.strip()
                temp = temp.split(', ')  
                usernames.append(temp[0])
                ##print(temp[0]) # To check for errors
        print('Total number of users:', (len(usernames)))
        print() 

        tasks_1 = []
        with open('tasks.txt','r') as tasks_file:
            tasks = tasks_file.readlines()   
            for lines in tasks:
                tasks = lines.strip()
                tasks = tasks.split(', ')
                tasks_1.append(tasks[1])
                #print(f'{tasks[1]}')
        print('Total number of tasks:', len(tasks_1))
        print()
  
elif menu == 'e':
    print('Goodbye!!!')
    exit()

else:
    print('You have made a wrong choice: Please Try again')
    print() 

Expected behavior

The program should ask input from user
The program should give output as per user menu
When Run and Debug is used the following error message is given:

Actual behavior

"System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension."

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Apr 25, 2024
@daxian-dbw
Copy link
Member

The issue should have been fixed in later versions. Please install the latest v2.3.5 PSReadLine module and see if the issue is gone.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Apr 25, 2024
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