bepasty-server icon indicating copy to clipboard operation
bepasty-server copied to clipboard

Cannot display text

Open ecsuae opened this issue 2 years ago • 3 comments

i am using bepasty from last one year and i am very much impressed by your work.recently i have to change my vps to a new colo i copied the storage folder from old vps and i have a very strange problem , all paste that have image are working fine but all paste that are text show error Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. Nginx logs show

 [26/Apr/2022:02:11:08 +0000] "GET /3pMPY229 HTTP/1.1" 500 290 "http://46.101.209.46/+list" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"

and gunicorn_supervisor logs show:

[2022-04-26 02:11:08,038] ERROR in app: Exception on /3pMPY229 [GET]
Traceback (most recent call last):
  File "/home/bepasty/lib/python3.8/site-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/bepasty/lib/python3.8/site-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/bepasty/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/bepasty/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/bepasty/lib/python3.8/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/home/bepasty/lib/python3.8/site-packages/flask/views.py", line 158, in dispatch_request
    return current_app.ensure_sync(meth)(*args, **kwargs)
  File "/home/bepasty/repo/src/bepasty/views/display.py", line 129, in get
    rendered_content = Markup(highlight(text, lexer, formatter))
  File "/home/bepasty/lib/python3.8/site-packages/pygments/__init__.py", line 82, in highlight
    return format(lex(code, lexer), formatter, outfile)
  File "/home/bepasty/lib/python3.8/site-packages/pygments/__init__.py", line 61, in format
    formatter.format(tokens, realoutfile)
  File "/home/bepasty/lib/python3.8/site-packages/pygments/formatter.py", line 94, in format
    return self.format_unencoded(tokensource, outfile)
  File "/home/bepasty/repo/src/bepasty/utils/formatters.py", line 43, in format_unencoded
    source = self.wrap(source, outfile)
TypeError: wrap() takes 2 positional arguments but 3 were given

can some one guide whats wrong?

ecsuae avatar Apr 26 '22 02:04 ecsuae

Looks like the pygments code you use calls the formatter inside bepasty differently than it used to do.

Maybe try an older pygments library?

ThomasWaldmann avatar Apr 26 '22 13:04 ThomasWaldmann

Maybe this?: https://github.com/pygments/pygments/blob/2.12.0/CHANGES#L64

If so, pip install 'pygments<2.12' might help for a quick fix.

For our code, we need a PR that makes the api compatible (preferably to old and new pygments).

ThomasWaldmann avatar Apr 26 '22 13:04 ThomasWaldmann

I confirm the problem resolved after running pip install 'pygments<2.12' .Thanks for the prompt reply.Stay blessed.

ecsuae avatar Apr 26 '22 18:04 ecsuae