Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Flecart
Copy link
Contributor

@Flecart Flecart commented Feb 10, 2024

Summary

Added the partitioned attribute.

See #2500.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Why was this draft?

Wait for python/cpython#112714 to get merged. (it was merged in Jan 2025)

@Flecart Flecart changed the title feat: add partiioned attribute to cookie feat: add partitioned attribute to cookie Feb 10, 2024
@Kludex
Copy link
Owner

Kludex commented Feb 15, 2024

Closing this since SimpleCookie doesn't support it. When that is supported, PR welcome.

@Kludex Kludex closed this Feb 15, 2024
@Flecart
Copy link
Contributor Author

Flecart commented Feb 19, 2024

@Kludex can we keep this open as draft like python/cpython#112714 in the meantime?

@Kludex
Copy link
Owner

Kludex commented Feb 19, 2024

I prefer to keep it closed for organization. When that is merged, we can continue the work here.

Flecart added a commit to cartabinaria/csgitbot that referenced this pull request Feb 23, 2024
@estyrke
Copy link

estyrke commented Apr 9, 2025

The CPython PR is merged now (targeted at 3.14 as far as I can tell). Can this be reopened or do we need a new PR?

@Flecart
Copy link
Contributor Author

Flecart commented Apr 9, 2025

The CPython PR is merged now (targeted at 3.14 as far as I can tell). Can this be reopened or do we need a new PR?

I'd be happy if this is reopened :)

@Kludex Kludex reopened this Apr 9, 2025
@aaronted009
Copy link

The CPython PR is merged now (targeted at 3.14 as far as I can tell). Can this be reopened or do we need a new PR?

I'd be happy if this is reopened :)

@Flecart , wish granted 😅 . I guess conflicts could be resolved here so this can move forward?

@Flecart
Copy link
Contributor Author

Flecart commented Apr 17, 2025

The CPython PR is merged now (targeted at 3.14 as far as I can tell). Can this be reopened or do we need a new PR?

I'd be happy if this is reopened :)

@Flecart , wish granted 😅 . I guess conflicts could be resolved here so this can move forward?

Sry for the delay, coming!

Flecart added 4 commits April 17, 2025 16:55
Old message 10 Feb 2024:
the test should fail, we need to wait for python/cpython#112713

Current update: 17 Apr 2025:
It was merged, so it should be ok.
@Flecart
Copy link
Contributor Author

Flecart commented Apr 17, 2025

Hello people,
I added the change for partitioned cookies.

This is a breaking change, I currently do not know a cleaner version other than checking the version we are in currently, if you have better ways, that'll be well accepted.

Ifrunning set cookie for python version earlier than 3.14 just returns an error like:

    def __setitem__(self, K, V):
        K = K.lower()
        if not K in self._reserved:
>           raise CookieError("Invalid attribute %r" % (K,))
E           http.cookies.CookieError: Invalid attribute 'partitioned'

I have tested locally, it passes tests with python version 3.14.0a7, and returns that error for python 3.11.8

style: run linter

fix: compatible with 3.13

fix: use partition test only for higher versions
@Flecart Flecart marked this pull request as ready for review April 17, 2025 15:40
There is a problem with the coverage, sometimes it is not compatible with python versions, some code should not be executed for some python versions, and coverage is not able to handle this thing well
@Flecart
Copy link
Contributor Author

Flecart commented Apr 18, 2025

Hello people.
I have added no cover for the whole test that checks for raising errors. I've looked up that in theory we should separate which tests are run for each version and then combine the coverage reports, but this is not compatible with the current testing format. The easiest solution I got was just to ignore coverage so that it works for all versions. Better ideas are welcome.

@Flecart
Copy link
Contributor Author

Flecart commented Apr 26, 2025

@Kludex reminder to check this when you have time. Thank you very much!

@Flecart Flecart requested a review from Kludex April 29, 2025 12:36
* `secure` - A bool indicating that the cookie will only be sent to the server if request is made using SSL and the HTTPS protocol. `Optional`
* `httponly` - A bool indicating that the cookie cannot be accessed via JavaScript through `Document.cookie` property, the `XMLHttpRequest` or `Request` APIs. `Optional`
* `samesite` - A string that specifies the samesite strategy for the cookie. Valid values are `'lax'`, `'strict'` and `'none'`. Defaults to `'lax'`. `Optional`
* `partitioned` - A bool indicates to user agents that these cross-site cookies should only be available in the same top-level context that the cookie was first set in. `Optional`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that it's only available on Python 3.14+.

@Flecart Flecart requested a review from Kludex May 3, 2025 20:33
@Kludex Kludex enabled auto-merge (squash) May 4, 2025 09:51
@Kludex Kludex merged commit 4acf1d1 into Kludex:master May 4, 2025
7 checks passed
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.

4 participants