Skip to content

fix: pickle lab can‘t respond #9

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YuevUwU
Copy link

@YuevUwU YuevUwU commented Nov 10, 2024

It'would report a TypeError when I built it now

Python Module Version

Python 3.8.20
Flask 2.2.5
Werkzeug 3.0.6

Reproduction method

  1. docker compose up --build --force-recreate under lab/deserialization/pickle
  2. Acess http://127.0.0.1:8600
  3. Type admin in Name field and 23 in Age field
  4. Error:
pickle-1     | [2024-11-10 00:31:13,657] ERROR in app: Exception on /login [POST]
pickle-1     | Traceback (most recent call last):
pickle-1     |   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2529, in wsgi_app
pickle-1     |     response = self.full_dispatch_request()
pickle-1     |   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1825, in full_dispatch_request
pickle-1     |     rv = self.handle_user_exception(e)
pickle-1     |   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1823, in full_dispatch_request
pickle-1     |     rv = self.dispatch_request()
pickle-1     |   File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
pickle-1     |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
pickle-1     |   File "/app/./main.py", line 34, in login
pickle-1     |     resp.set_cookie("session", user)
pickle-1     |   File "/usr/local/lib/python3.8/site-packages/werkzeug/sansio/response.py", line 227, in set_cookie
pickle-1     |     dump_cookie(
pickle-1     |   File "/usr/local/lib/python3.8/site-packages/werkzeug/http.py", line 1322, in dump_cookie
pickle-1     |     if not _cookie_no_quote_re.fullmatch(value):
pickle-1     | TypeError: cannot use a string pattern on a bytes-like object

My Solution

Decode to convert user from bytes back to str

Alternative Solution

Specify a specific version of uwsgi-nginx-flask image
Or Other...

Note

The reason may be that the old version is accommodating or supports this syntax?

External Link

Python 3.8
API — Flask Documentation (2.2.x)
Latest Stable Documentation
tiangolo/uwsgi-nginx-flask

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

Successfully merging this pull request may close these issues.

1 participant