Running Python 3.7 web.py Runtimeerror: generator raised stopiteration exception occurred during test

When I first started learning Python, I found an exception when I ran the web.py home page test code.
The code is as follows:

import web
        
urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()

The exceptions are as follows:

Traceback (most recent call last):
  File "C:\Users\HHHHH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\web\utils.py", line 526, in take
    yield next(seq)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\workspace\HelloPython\Helloworld.py", line 7, in <module>
    app = web.application(urls, globals())
  File "C:\Users\HHHHH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\web\application.py", line 62, in __init__
    self.init_mapping(mapping)
  File "C:\Users\HHHHH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\web\application.py", line 130, in init_mapping
    self.mapping = list(utils.group(mapping, 2))
  File "C:\Users\HHHHH\AppData\Local\Programs\Python\Python37-32\lib\site-packages\web\utils.py", line 531, in group
    x = list(take(seq, size))
RuntimeError: generator raised StopIteration

 
Follow the exception prompt to find the appropriate code (… Utils.py “, line 531, in group), as follows:

Here, call line 524 take method and modify it as follows according to the information on the official website (note the indentation) :

Restart successfully after modification:


END

Read More: