Show More
@@ -953,6 +953,8 b' Currently the magic system has the following functions:\\n"""' | |||||
953 | except UnicodeEncodeError: |
|
953 | except UnicodeEncodeError: | |
954 | vstr = unicode(var).encode(DEFAULT_ENCODING, |
|
954 | vstr = unicode(var).encode(DEFAULT_ENCODING, | |
955 | 'backslashreplace') |
|
955 | 'backslashreplace') | |
|
956 | except: | |||
|
957 | vstr = "<object with id %d (repr failed)>" % id(var) | |||
956 | vstr = vstr.replace('\n','\\n') |
|
958 | vstr = vstr.replace('\n','\\n') | |
957 | if len(vstr) < 50: |
|
959 | if len(vstr) < 50: | |
958 | print vstr |
|
960 | print vstr |
@@ -376,6 +376,14 b' def doctest_who():' | |||||
376 | Out[7]: ['alpha', 'beta'] |
|
376 | Out[7]: ['alpha', 'beta'] | |
377 | """ |
|
377 | """ | |
378 |
|
378 | |||
|
379 | def test_whos(): | |||
|
380 | """Check that whos is protected against objects where repr() fails.""" | |||
|
381 | class A(object): | |||
|
382 | def __repr__(self): | |||
|
383 | raise Exception() | |||
|
384 | _ip.user_ns['a'] = A() | |||
|
385 | _ip.magic("whos") | |||
|
386 | ||||
379 | @py3compat.u_format |
|
387 | @py3compat.u_format | |
380 | def doctest_precision(): |
|
388 | def doctest_precision(): | |
381 | """doctest for %precision |
|
389 | """doctest for %precision |
General Comments 0
You need to be logged in to leave comments.
Login now