<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 19, 2014 at 4:13 PM, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On 03/19/2014 03:57 PM, Antoine Pitrou wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On Wed, 19 Mar 2014 15:17:53 -0700<br>
Ethan Furman <<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On 03/19/2014 03:13 PM, Antoine Pitrou wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On Wed, 19 Mar 2014 14:37:42 -0700<br>
Ethan Furman <<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Here's the code in question:<br>
<br>
class PsuedoFloat:<br>
def __init__(self, value):<br>
self.value = float(value)<br>
def __int__(self):<br>
return int(self.value)<br>
<br>
pi = PsuedoFloat(3.1415)<br>
<br>
self.assertRaisesRegex(<u></u>TypeError, '%x format: an integer is required, not PsuedoFloat', '%x'.__mod__, pi),<br>
<br>
Here's the exception:<br>
<br>
==============================<u></u>==============================<u></u>==========<br>
ERROR: test_formatting (test.test_unicode.<u></u>UnicodeTest)<br>
------------------------------<u></u>------------------------------<u></u>----------<br>
TypeError: 'PsuedoFloat' object is not callable<br>
<br>
During handling of the above exception, another exception occurred:<br>
<br>
Traceback (most recent call last):<br>
File "/home/ethan/source/python/<u></u>issue19995/Lib/test/test_<u></u>unicode.py", line 1156, in test_formatting<br>
self.assertRaisesRegex(<u></u>TypeError, '%c'.__mod__, pi),<br>
</blockquote>
<br>
This is certainly not the code you are showing above.<br>
</blockquote>
<br>
More words, please! :)<br>
</blockquote>
<br>
I mean the line shown just above in the traceback does not match the<br>
code you presented at the top, and that line clearly has a missing<br>
regex pattern.<br>
</blockquote>
<br></div></div>
A regex pattern can be a literal, yes? In which case<br>
<br>
exception -> TypeError<br>
regex -> '%x format: an integer is required, not PsuedoFloat'<br>
callable -> '%x'.__mod__<br>
*args -> pi<br>
**kwargs -> None<br>
<br>
So, unless you can point to where I've gone wrong with the above (which is why I posted in the first place), I think we have a bug in unittest.<br>
<br>
Also:<br>
<br>
self.assertRaisesRegex(<u></u>TypeError, '%x format: an integer is required, not float','%x'.__mod__, 3.14),<br>
self.assertRaisesRegex(<u></u>TypeError, '%X format: an integer is required, not float','%X'.__mod__, 2.11),<br>
self.assertRaisesRegex(<u></u>TypeError, '%o format: an integer is required, not float','%o'.__mod__, 1.79),<br>
<br>
these lines all work just fine.<br></blockquote><div><br></div><div>What Antoine is trying to tell you is that the traceback you pasted shows this:</div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px"> File "/home/ethan/source/python/</span><u style="font-family:arial,sans-serif;font-size:13.333333969116211px"></u><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">iss</span><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">ue19995/Lib/test/test_</span><u style="font-family:arial,sans-serif;font-size:13.333333969116211px"></u><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">unicode.</span><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">py", line 1156, in test_formatting</span><br style="font-family:arial,sans-serif;font-size:13.333333969116211px">
<span style="font-family:arial,sans-serif;font-size:13.333333969116211px"> self.assertRaisesRegex(</span><u style="font-family:arial,sans-serif;font-size:13.333333969116211px"></u><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">TypeErr</span><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">or, '%c'.__mod__, pi),</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">... which is passing '%c'.__mod__ as the 'regex' argument. '%c'.__mod__ is a method of a builtin type, a 'method-wrapper' object, which is why you get the error you're getting: </span><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">AttributeError: 'method-wrapper' object has no attribute 'search'.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px"><br></span></div></div>-- <br>Thomas Wouters <<a href="mailto:thomas@python.org" target="_blank">thomas@python.org</a>><br><br>Hi! I'm an email virus! Think twice before sending your email to help me spread!
</div></div>