[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Eric V. Smith
Eric V. Smith added the comment: I think the issue is that it should be an error in any string used for format_map() to have a positional argument. So the right thing to do is detect this case in get_field_object (index != -1 and args is NULL). So I think a new test near line 515 really is th

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Julian
Julian added the comment: Fair enough. I suppose I take .format_map to mean, here is a mapping, call __getitem__ on it for each of the keys inside the format string, to which calling 12["foo"] would get me a TypeError. I suppose I see both as appropriate, but the fact that it's implemented by

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Eric V. Smith
Eric V. Smith added the comment: I think KeyError for "{foo}".format(12) is correct. It's looking up "foo" in the empty dict of **kwargs. -- ___ Python tracker ___

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Julian
Julian added the comment: Sorry for the double post, meant to say, in line 506. -- ___ Python tracker ___ ___ Python-bugs-list mailin

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Julian
Julian added the comment: Yeah, I saw the line you suggested and didn't think that was it. To expand on this, perhaps "{foo}".format(12) should raise a TypeError as well? I'd expect that more than the current behavior which is a KeyError. That KeyError is getting raised in get_field_object, w

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Eric V. Smith
Eric V. Smith added the comment: Actually that's probably not the place to catch it. Let me look at it closer. Of course, patches welcome! -- ___ Python tracker ___ ___

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Eric V. Smith
Eric V. Smith added the comment: If you want to look at this, I think there's a missing check for args being non-null in string_format.h, line 515. I'd have to think to see if there are other possible failure scenarios. Thanks for the report. -- _

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Eric V. Smith
Changes by Eric V. Smith : -- assignee: -> eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue12579] str.format_map raises a SystemError for non-mapping

2011-07-17 Thread Julian
New submission from Julian : Attached is just a failing test case (just `print("{}".format_map(12))`), haven't been able to decipher the chain of calls in the unicodeobject.c code yet to see where the best place to put the fix would be (inside do_format_map before the pass back upwards maybe?)