GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-148849: Deprecate http.cookies.BaseCookie.js_output() by kishorhange111 · Pull Request #148978 · python/cpython

Conversation

@kishorhange111

@kishorhange111 kishorhange111 commented Apr 25, 2026 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

gh-148849: Deprecate http.cookies.BaseCookie.js_output()

I didn’t see anyone assigned to this issue, so I tried working on it. I’m new to open source contributions, so please let me know if anything should be done differently.

This deprecates BaseCookie.js_output() as discussed in the issue. The method seems to be unused and tied to older browser behavior that isn’t really relevant anymore.

I added a deprecation decorator to the method, updated the existing tests to expect a DeprecationWarning, and updated the docs along with a NEWS entry.

I ran test_http_cookies locally — all tests pass (33 tests, 1 skipped):

Ran 33 tests in 0.122s
OK (skipped=1)

I also checked that calling js_output() raises the warning while still returning the same result.

I left Morsel.js_output() unchanged since the issue only mentions BaseCookie.js_output(), but I can update that too if needed.

Would appreciate a review whenever you get a chance. Thanks!

Fixes gh-148849


📚 Documentation preview 📚: https://cpython-previews--148978.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kishorhange111
pythongh-148849: Deprecate http.cookies.BaseCookie.js_output()
f67449d
@kishorhange111
kishorhange111 requested a review from AA-Turner as a code owner April 25, 2026 07:47
@python-cla-bot

python-cla-bot Bot commented Apr 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Apr 25, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Apr 25, 2026
Deprecate BaseCookie.js_output() method #148849
Closed
picnixz
picnixz requested changes Apr 25, 2026
View reviewed changes
Comment thread Doc/library/http.cookies.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/http.cookies.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/http/cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_http_cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_http_cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_http_cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting review labels Apr 25, 2026
@bedevere-app

bedevere-app Bot commented Apr 25, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Apr 25, 2026

Copy link
Copy Markdown
Member

Please, do not update your branch if there is no need to. Please read https://devguide.python.org/getting-started/pull-request-lifecycle/ before doing future contributions.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Apr 25, 2026
View reviewed changes
Comment thread Doc/library/http.cookies.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2026-04-25-12-04-27.gh-issue-148849.Vk6yEW.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kishorhange111
Address review comments
d1e4a57
@kishorhange111
kishorhange111 force-pushed the gh-148849-deprecate-js-output branch from d9ae235 to d1e4a57 Compare April 25, 2026 08:26
@kishorhange111
Version updated to 3.19
627fa9b
@kishorhange111

kishorhange111 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Apr 25, 2026
@bedevere-app

bedevere-app Bot commented Apr 25, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from picnixz April 25, 2026 08:58
@kishorhange111
Fix deprecation warning implementation
60cf501
@kishorhange111

kishorhange111 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

Please let me know if there are any further suggestions or changes needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Apr 25, 2026
View reviewed changes
Comment thread Doc/library/http.cookies.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kishorhange111 @StanFromIreland
Update Doc/library/http.cookies.rst
964c27f
Co-authored-by: Stan Ulbrych <[email protected]>
picnixz
picnixz reviewed Apr 25, 2026
View reviewed changes
Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Apr 25, 2026
View reviewed changes
Comment thread Lib/http/cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Apr 25, 2026
View reviewed changes
Comment thread Lib/test/test_http_cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kishorhange111 and others added 2 commits April 25, 2026 15:09
@kishorhange111 @picnixz
Update Doc/whatsnew/3.15.rst
3d31227
Co-authored-by: Bénédikt Tran <[email protected]>
@kishorhange111
Fix deprecation warning message to match tests
b169fc8
@kishorhange111

kishorhange111 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Apr 25, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Apr 27, 2026
View reviewed changes
Comment thread Lib/http/cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
Update Lib/http/cookies.py
ed75b1e
picnixz
picnixz reviewed Apr 27, 2026
View reviewed changes
Comment thread Lib/http/cookies.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
Update Lib/http/cookies.py
38f1708
picnixz
picnixz approved these changes Apr 27, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Apr 27, 2026
@picnixz

picnixz commented Apr 27, 2026

Copy link
Copy Markdown
Member

Nothing to do on your side! Don't update your branch since there won't be a need to, I'll just wait a few days before alpha closes to merge this.

cc @sethmlarson @serhiy-storchaka @encukou

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sethmlarson
sethmlarson approved these changes Apr 27, 2026
View reviewed changes

@sethmlarson sethmlarson left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
serhiy-storchaka
serhiy-storchaka approved these changes Apr 27, 2026
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
StanFromIreland
StanFromIreland approved these changes Apr 27, 2026
View reviewed changes
@encukou

encukou commented May 1, 2026

Copy link
Copy Markdown
Member

Sorry for being late to the party, but, IMO Morsel.js_output should be deprecated as well -- it has exactly the same issues.
(and BaseCookie uses that, so the warning should only be emitted there.)

sethmlarson reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kishorhange111

kishorhange111 commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

Hey, quick question — should I include this change in the current PR, or would you prefer I open a separate PR specifically for the Morsel.js_output update?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou

encukou commented May 1, 2026

Copy link
Copy Markdown
Member

I'd prefer here since they're so related.

sethmlarson and kishorhange111 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kishorhange111 added 2 commits May 2, 2026 07:36
@kishorhange111
pythongh-148849: Deprecate Morsel.js_output()
948a8f8
@kishorhange111
pythongh-148849: Fix duplicate Morsel.js_output doc entry and indenta…
c957098
…tion
@kishorhange111

kishorhange111 commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

As suggested by @encukou, I’ve deprecated Morsel.js_output(). The implementation now routes through Morsel.js_output(), so the deprecation warning is emitted only once.

Note on stacklevel:
The current implementation uses warnings._deprecated(), which has a fixed stacklevel=3. As a result, when BaseCookie.js_output() calls Morsel.js_output(), the warning points to BaseCookie.js_output() rather than the user's code. This could be improved by switching to warnings.warn() with a configurable stacklevel.
I'm happy to adjust this if preferred .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting merge labels May 2, 2026
@bedevere-app

bedevere-app Bot commented May 2, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@picnixz, @StanFromIreland, @serhiy-storchaka: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested review from StanFromIreland, picnixz and serhiy-storchaka May 2, 2026 08:01
@read-the-docs-community

read-the-docs-community Bot commented May 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32507822 | 📁 Comparing a91d066 against main (db0ee44)

  🔍 Preview build  

40 files changed · ± 40 modified

± Modified

  • contents.html
  • download.html
  • genindex-B.html
  • genindex-C.html
  • genindex-E.html
  • genindex-F.html
  • genindex-G.html
  • genindex-H.html
  • genindex-I.html
  • genindex-N.html
  • and 30 more...
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed May 2, 2026
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

To avoid multiple deprecation warnings from internal use, you can add private Morsel._js_output and use it in BaseCookie.js_output and Morsel.js_output after emitting a warning.

You can use self.assertEqual(cm.filename, __file__) to assert that the warning points to the correct calling place.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kishorhange111
pythongh-148849: Add Morsel._js_output() to avoid multiple warnings
a91d066
@kishorhange111

kishorhange111 commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka Thank you so much for the suggestion!
I've added Morsel._js_output() as a protected method containing the actual logic, so both Morsel.js_output() and BaseCookie.js_output() can warn independently and then delegate to _js_output(). This cleanly avoids multiple warnings and also fixes the stacklevel issue. I've also added cm.filename == file assertions to verify that the warning correctly points to the user's call site.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sethmlarson
sethmlarson approved these changes May 3, 2026
View reviewed changes

@sethmlarson sethmlarson left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kishorhange111 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@serhiy-storchaka serhiy-storchaka removed the awaiting change review label May 4, 2026
@serhiy-storchaka
serhiy-storchaka merged commit 246fe14 into python:main May 4, 2026
52 of 53 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@sethmlarson sethmlarson sethmlarson approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@picnixz picnixz Awaiting requested review from picnixz
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Deprecate BaseCookie.js_output() method

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@kishorhange111 @picnixz @encukou @serhiy-storchaka @sethmlarson @StanFromIreland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.