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
__str__ cannot be overridden on unicode-derived classes #44163
Comments
class S(str):
def __str__(self): return '__str__ overridden'
class U(unicode):
def __str__(self): return '__str__ overridden'
def __unicode__(self): return u'__unicode__ overridden'
s = S()
u = U() print 's:', s ----------------------------------------------------- s: __str__ overridden u: Results are identical for 2.4.2 and 2.5c2 (running |
Confirmed in trunk. |
Case "S" (type str): "%s" uses _PyObject_Str() which checks the object Case "U" (type unicode) "%s" uses PyUnicode_Check() and then calls xxx_CheckExact() is different than xxx_Check(): exact is only true for |
Patch: Use PyUnicode_CheckExact() instead of PyUnicode_CheckExact() in |
Commited: r79278+r79280 (trunk), r79281 (py3k), r79282 (3.1), r79283 (2.6). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: