-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Conversation
@@ -479,7 +480,13 @@ _io_text_encoding_impl(PyObject *module, PyObject *encoding, int stacklevel) | |||
return NULL; | |||
} | |||
} | |||
return &_Py_ID(locale); |
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.
@ericsnowcurrently We need to incref this until we implement immortal object. Am I correct?
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.
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.
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.
I am afraid breaking refleak buildbot.
Would you tell my why this return &_Py_ID(locale);
don't break refleak test?
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.
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.)
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.
(_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?
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.
Good point. It didn't cause a problem before. I'd have to look into why not.
When you're done making the requested changes, leave the comment: |
Co-authored-by: Eric Snow <[email protected]>
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
Co-authored-by: Eric Snow <[email protected]>
io.text_encoding()
respects UTF-8 mode
https://bugs.python.org/issue47000