Commit a60167d
gvanrossum
Printing objects to a real file still wasn't done right: if the
object's type didn't define tp_print, there were still cases where the
full "print uses str() which falls back to repr()" semantics weren't
honored. This resulted in
>>> print None
<None object at 0x80bd674>
>>> print type(u'')
<type object at 0x80c0a80>
Fixed this by always using the appropriate PyObject_Repr() or
PyObject_Str() call, rather than trying to emulate what they would do.
Also simplified PyObject_Str() to always fall back on PyObject_Repr()
when tp_str is not defined (rather than making an extra check for
instances with a __str__ method). And got rid of the special case for
strings.
git-svn-id: http://svn.python.org/projects/python/trunk@20566 6015fed2-1504-0410-9fe1-9d1591cc47711 parent f71e223 commit a60167d
1 file changed
Lines changed: 14 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
206 | 206 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 207 | + | |
219 | 208 | | |
| 209 | + | |
220 | 210 | | |
221 | 211 | | |
222 | 212 | | |
| |||
301 | 291 | | |
302 | 292 | | |
303 | 293 | | |
304 | | - | |
| 294 | + | |
305 | 295 | | |
306 | 296 | | |
307 | 297 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
320 | 302 | | |
321 | 303 | | |
322 | 304 | | |
| |||
0 commit comments