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

bpo-47000: Make io.text_encoding() respects UTF-8 mode #32003

Merged
merged 11 commits into from
Apr 4, 2022

Conversation

methane
Copy link
Member

@methane methane commented Mar 20, 2022

@@ -479,7 +480,13 @@ _io_text_encoding_impl(PyObject *module, PyObject *encoding, int stacklevel)
return NULL;
}
}
return &_Py_ID(locale);
Copy link
Member Author

Choose a reason for hiding this comment

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

@ericsnowcurrently We need to incref this until we implement immortal object. Am I correct?

Copy link
Member

Choose a reason for hiding this comment

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

Sort of. Currently all statically allocated global objects have their refcount initialized to a really large value. So we haven't been bothering with the incref if we know the object is one of those, which it is in this case. Incref'ing it won't hurt. However, it is effectively unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am afraid breaking refleak buildbot.
Would you tell my why this return &_Py_ID(locale); don't break refleak test?

Copy link
Member

Choose a reason for hiding this comment

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

The refcount of static objects is not directly included in _Py_RefTotal, which is used for refleak detection. (_Py_RefTotal will still ensure that refcount operations are balanced though, regardless of the objects involved.)

Copy link
Member Author

Choose a reason for hiding this comment

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

(_Py_RefTotal will still ensure that refcount operations are balanced though, regardless of the objects involved.)

So skipping INCREF here might cause in-balance of _Py_RefTotal. Doesn't it break refleak test?

Copy link
Member

Choose a reason for hiding this comment

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

Good point. It didn't cause a problem before. I'd have to look into why not.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

ericsnowcurrently added a commit that referenced this pull request Mar 23, 2022
In a gh-32003 comment, I realized it wasn't very clear how _Py_DECLARE_STR() should be used.  This changes adds a comment to clarify.

https://bugs.python.org/issue46541
@methane methane changed the title bpo-47000: Make io.text_encoding() respects UTF-8 mode. bpo-47000: Make io.text_encoding() respects UTF-8 mode Apr 3, 2022
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