Issue635969
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-11-09 17:53 by loewis, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (7) | |||
---|---|---|---|
msg13163 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-11-09 17:53 | |
The expression r'.po$' % "hallo" used to give an error, but now succeeds and gives the string '.po'. I think producing the error should be restored. |
|||
msg13164 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2002-11-10 15:45 | |
Logged In: YES user_id=33168 I'm pretty sure this change (between 2.2.2 and 2.3) in stringobject.c is the problem: @@ -3320,7 +3623,7 @@ arglen = -1; argidx = -2; } - if (args->ob_type->tp_as_mapping) + if (args->ob_type->tp_as_mapping && !PyTuple_Check(args)) dict = args; Now for non-tuples, dict is set. dict is used later on to determine if an exception should be set. This still works, ie produces the exception: (r'.po$' % "hallo",) |
|||
msg13165 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2002-11-10 15:49 | |
Logged In: YES user_id=33168 Let me try that again: r'.po$' % ("hallo",) The line was changed in rev 2.166 by mwh for extended slicing. |
|||
msg13166 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2002-11-10 16:35 | |
Logged In: YES user_id=33168 The problem is that string is a mapping (also changed in 2.166). The patch below fixes the problem. Michael, do you have any problem with this change? If not, I'll check it in with a test (unless you beat me to it). - if (args->ob_type->tp_as_mapping && !PyTuple_Check(args)) + if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) && !PyString_Check(args)) |
|||
msg13167 - (view) | Author: Michael Hudson (mwh) | Date: 2002-11-11 10:29 | |
Logged In: YES user_id=6656 You're right. Please do add a test! Also note that unicode's are mappings too. |
|||
msg13168 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2002-11-12 23:01 | |
Logged In: YES user_id=33168 In order to deal with either the format or the arg being a string or unicode, I changed the code to check PyObject_TypeCheck(args, &PyBaseString_Type). This was changed in both PyString_Format and PyUnicode_Format. Checked in as: * Objects/unicodeobject.c 2.174 * Objects/stringobject.c 2.196 * Lib/test/test_format.py 1.18 |
|||
msg13169 - (view) | Author: Michael Hudson (mwh) | Date: 2002-11-13 10:55 | |
Logged In: YES user_id=6656 Of course, the moral to this story is "always pass a tuple to str % args"... |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:52 | admin | set | github: 37447 |
2002-11-09 17:53:57 | loewis | create |