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

Declare http.cookies.SimpleCookie as non generic(?) #10700

Closed
flaeppe opened this issue Sep 11, 2023 · 0 comments · Fixed by #10701
Closed

Declare http.cookies.SimpleCookie as non generic(?) #10700

flaeppe opened this issue Sep 11, 2023 · 0 comments · Fixed by #10701

Comments

@flaeppe
Copy link

flaeppe commented Sep 11, 2023

I'm a bit confused as to why http.cookies.SimpleCookie is declared as a generic class and not like below?

class SimpleCookie(BaseCookie[str]):
    ...

The documentation on SimpleCookie only talks about strings:

class http.cookies.SimpleCookie([input])
This class derives from BaseCookie and overrides value_decode() and value_encode(). SimpleCookie supports strings as cookie values. When setting the value, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings.

And from what I'm seeing, implementations value_decode and value_encode for SimpleCookie only produces strings (but perhaps I'm missing something)?

Ref: https://github.com/python/cpython/blob/1ee50e2a78f644d81d341a08562073ad169d8cc7/Lib/http/cookies.py#L607-L612

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 a pull request may close this issue.

1 participant