Skip to content

Bug #3308

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

Closed
3 tasks done
Prodigysec opened this issue May 11, 2022 · 1 comment
Closed
3 tasks done

Bug #3308

Prodigysec opened this issue May 11, 2022 · 1 comment

Comments

@Prodigysec
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

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 200 Keys:
 \ P y t h o n 3 7 \ p y t h o n . e x e ' Space ' c : \ U s e r s \ H P \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . p y t h o n - 2 0 2 2 . 4 . 1 \ p y t h o n F i l e s \ l i b \ p y t h o n \ d e b u g p y \ l a u n c h e r ' Space ' 6 1 5 2 3 ' Space ' - - ' Space ' c : \ U s e r s \ H P \ D e s k t o p \ P Y T H O N \ P y B a s i c s P r a c t i c a l \ W E B \ s c r a p e E X C 1 . p y ' Space Enter


Exception:
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: top
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   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

N/A

Environment data

PS Version: 5.1.19041.1645
PS HostName: ConsoleHost
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.320 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 3000

Steps to reproduce

#1. Write a script that grabs the full HTML from the page
#2. Use the string .find() method to display the text following “Name:” and “Favorite Color:” (not including

any leading spaces or trailing HTML tags that might appear on the same line).

3. Repeat the previous exercise using regular expressions. The end of each pattern

should be a “<” (the start of an HTML tag) or a newline character, and you should remove

any extra spaces or newline characters from the resulting text using the string .strip() method.

import re
from urllib.request import urlopen

url = "http://olympus.realpython.org/profiles/dionysus"
page = urlopen(url)
html = page.read().decode("utf-8")

print(html)
print("+++++")

start_heading = "

"
end_heading = "

"
start_index = html.find(start_heading) + len(start_heading) + len("Name: ")
end_index = html.find(end_heading)

print(html[start_index:end_index])
print("+++++")
f_Color_start = "
"
f_Color_end = ""
start_index = html.find("Favorite Color") + len("Favorite Color: ")
end_index = html.find(f_Color_end)

print(html[start_index:end_index])

#Using re
pattern = "<h2.?>.?"
match_results = re.search(pattern,html,re.IGNORECASE)
name = match_results.group()
name = re.sub("<.*?>", "",name)

name = re.sub("Name: ","",name)

print(name)

pattern = "
\n.?"
match_result = re.search(pattern,html,re.IGNORECASE)
print(match_result)
#name = match_result.group()
name = re.sub("<.
?>", "",name)

name = re.sub("Name: ","",name)

print(name)

Expected behavior

<TITLE >Profile: Dionysus</title / >

Name: Dionysus



Hometown: Mount Olympus

Favorite animal: Leopard

Favorite Color: Wine

+++++
Dionysus
+++++
Wine

Name: Dionysus
None
Name: Dionysus

Actual behavior

Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new

Last 200 Keys:
\ P y t h o n 3 7 \ p y t h o n . e x e ' Space ' c : \ U s e r s \ H P \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . p y t h o n - 2 0 2 2 . 4 . 1 \ p y t h o n F i l e s \ l i b \ p y t h o n \ d e b u g p y \ l a u n c h e r ' Space ' 6 1 5 2 3 ' Space ' - - ' Space ' c : \ U s e r s \ H P \ D e s k t o p \ P Y T H O N \ P y B a s i c s P r a c t i c a l \ W E B \ s c r a p e E X C 1 . p y ' Space Enter

Exception:
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: top
Actual value was -1.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
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(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label May 11, 2022
@github-actions
Copy link

This issue was already fixed (see #1306). Please upgrade to the 2.2.3 version of PSReadLine from PowerShell Gallery.
See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

@ghost ghost removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label May 11, 2022
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

1 participant