Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-123503: Replace usages of addinfourl and HTTPResponse deprecated attributes with stable ones#132670

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Alexandr153 wants to merge6 commits intopython:main
base:main
Choose a base branch
Loading
fromAlexandr153:fix-issue-123503

Conversation

Alexandr153
Copy link
Contributor

I replaced deprecated features with the recommended current features(updated to the latest version)

@picnixz
Copy link
Member

picnixz commentedApr 18, 2025
edited
Loading

Please, don't re-create your PRs. Next time, just ask if there is some issue with git and I'll try helping you.

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

I would say "yes, let's do this", but I honestly want a second opinion on this change. We can always revert it later during the beta if this causes issues, though.

cc@serhiy-storchaka@vadmium

@python-cla-bot
Copy link

python-cla-botbot commentedApr 18, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

…fg0wD.rstCo-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

…fg0wD.rstCo-authored-by: Martin Panter <vadmium@users.noreply.github.com>
@vadmium
Copy link
Member

I don’t understand what you mean by “while retaining backwards compatibility”. Why are you changing the test suite?

There doesn’t seem to be any consideration given to existing user code, such as the caching class in the bug report. Does this change break code that implementscode but notstatus? Does it break code implementinginfo but notheaders? Before 3.9, only HTTP and HTTPS responses had thestatus attribute, andheaders was not documented whileinfo was.

I winder if we at least need documentation saying what changes a user needs to remain compatible with the changes in Python. Maybe also fall back to the old attribute and method as well? This is the problem with deprecating two-way APIs that are implemented in both user code and Python.

@picnixz
Copy link
Member

I winder if we at least need documentation saying what changes a user needs to remain compatible with the changes in Python

Mmh, I see your point. You mean that "what if someone coming from something before 3.9 is now trying to port stuff to Python 3.14"? I'd say that anything marked as being deprecated should also be changed on their side but I guess it doesn't hurt having a paragraph in "Porting to 3.14".

Does this change break code that implements code but not status

Strictly speaking, yes. But I wouldn't consider this as being critical as the attribute has been marked as deprecated since 3.9. And any class that inherits fromHTTPResponse oraddinfourl would automatically have astatus attribute.

Does it break code implementing info but not headers

I'd say it's the same as above.


That being said, we're already using "possible missing" attributes in, for instance, xmlrpc:

try:http_conn=self.send_request(host,handler,request_body,verbose)resp=http_conn.getresponse()ifresp.status==200:self.verbose=verbosereturnself.parse_response(resp)

OTOH, forcontextlib.closing(urlopen(url, data)) as fp: and the changefp.info() tofp.headers, the docs forurlopen says (emphasis mine):

This function always returns an object which can work as a
context manager and has the propertiesurl, headers, and status.

So we should already be on the safe side. But OTOH, the changes to other occurrences may indeed break stuff, though I wouldn't consider this as being critical, especially if it's something that's been deprecated since 3.9.

In the original report, what was actually annoying was more that users need to provide the deprecated attributes as well. So I think it's better to move forwards, at the cost of possibly breaking APIs that use deprecated attributes.

Now, if you want to be on the safe side, how about adding a true DeprecationWarning, without any removal plans, and implement a fallback logic if needs arise?

@vadmium
Copy link
Member

You mean that "what if someone coming from something before 3.9 is now trying to port stuff to Python 3.14"? I'd say that anything marked as being deprecated should also be changed on their side . . .

But someone using 3.13 today cannot change their deprecatedcode attribute andinfo method due to the bug. (They could add the recommended replacements, but they must keep the old ones.)

how about adding a true DeprecationWarning, without any removal plans, and implement a fallback logic if needs arise?

If the fix claims backwards compatibility, I suspect we should add that fallback logic. On the other hand, it would be simpler to just document that a custom class would need porting to the new response attributes in 3.14, and remove the claim that backwards compatibility is retained.

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

@vadmiumvadmiumvadmium left review comments

@picnixzpicnixzpicnixz approved these changes

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@Alexandr153@picnixz@vadmium@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp