Show More
@@ -23,7 +23,7 b' import textwrap' | |||
|
23 | 23 | from string import Formatter |
|
24 | 24 | |
|
25 | 25 | from IPython.external.path import path |
|
26 | ||
|
26 | from IPython.utils import py3compat | |
|
27 | 27 | from IPython.utils.io import nlprint |
|
28 | 28 | from IPython.utils.data import flatten |
|
29 | 29 | |
@@ -284,7 +284,7 b' def make_quoted_expr(s):' | |||
|
284 | 284 | tail = '' |
|
285 | 285 | tailpadding = '' |
|
286 | 286 | raw = '' |
|
287 | ucode = 'u' | |
|
287 | ucode = '' if py3compat.PY3 else 'u' | |
|
288 | 288 | if "\\" in s: |
|
289 | 289 | raw = 'r' |
|
290 | 290 | if s.endswith('\\'): |
@@ -494,7 +494,7 b" def marquee(txt='',width=78,mark='*'):" | |||
|
494 | 494 | """ |
|
495 | 495 | if not txt: |
|
496 | 496 | return (mark*width)[:width] |
|
497 | nmark = (width-len(txt)-2)/len(mark)/2 | |
|
497 | nmark = (width-len(txt)-2)//len(mark)//2 | |
|
498 | 498 | if nmark < 0: nmark =0 |
|
499 | 499 | marks = mark*nmark |
|
500 | 500 | return '%s %s %s' % (marks,txt,marks) |
@@ -52,15 +52,17 b' import inspect' | |||
|
52 | 52 | import re |
|
53 | 53 | import sys |
|
54 | 54 | import types |
|
55 |
from types import |
|
|
56 | InstanceType, ClassType, FunctionType, | |
|
57 | ListType, TupleType | |
|
58 | ) | |
|
59 | from .importstring import import_item | |
|
60 | ||
|
55 | from types import FunctionType | |
|
56 | try: | |
|
57 | from types import ClassType, InstanceType | |
|
61 | 58 | ClassTypes = (ClassType, type) |
|
59 | except: | |
|
60 | ClassTypes = (type,) | |
|
62 | 61 | |
|
63 | SequenceTypes = (ListType, TupleType, set, frozenset) | |
|
62 | from .importstring import import_item | |
|
63 | from IPython.utils import py3compat | |
|
64 | ||
|
65 | SequenceTypes = (list, tuple, set, frozenset) | |
|
64 | 66 | |
|
65 | 67 | #----------------------------------------------------------------------------- |
|
66 | 68 | # Basic classes |
@@ -108,7 +110,7 b' def repr_type(obj):' | |||
|
108 | 110 | error messages. |
|
109 | 111 | """ |
|
110 | 112 | the_type = type(obj) |
|
111 | if the_type is InstanceType: | |
|
113 | if (not py3compat.PY3) and the_type is InstanceType: | |
|
112 | 114 | # Old-style class. |
|
113 | 115 | the_type = obj.__class__ |
|
114 | 116 | msg = '%r %r' % (obj, the_type) |
@@ -616,7 +618,7 b' class ClassBasedTraitType(TraitType):' | |||
|
616 | 618 | |
|
617 | 619 | def error(self, obj, value): |
|
618 | 620 | kind = type(value) |
|
619 | if kind is InstanceType: | |
|
621 | if (not py3compat.PY3) and kind is InstanceType: | |
|
620 | 622 | msg = 'class %s' % value.__class__.__name__ |
|
621 | 623 | else: |
|
622 | 624 | msg = '%s (i.e. %s)' % ( str( kind )[1:-1], repr( value ) ) |
@@ -880,7 +882,7 b' class CInt(Int):' | |||
|
880 | 882 | except: |
|
881 | 883 | self.error(obj, value) |
|
882 | 884 | |
|
883 | ||
|
885 | if not py3compat.PY3: | |
|
884 | 886 | class Long(TraitType): |
|
885 | 887 | """A long integer trait.""" |
|
886 | 888 | |
@@ -955,7 +957,7 b' class CComplex(Complex):' | |||
|
955 | 957 | # for Python 3 conversion and for reliable unicode behaviour on Python 2. So |
|
956 | 958 | # we don't have a Str type. |
|
957 | 959 | class Bytes(TraitType): |
|
958 | """A trait for strings.""" | |
|
960 | """A trait for byte strings.""" | |
|
959 | 961 | |
|
960 | 962 | default_value = '' |
|
961 | 963 | info_text = 'a string' |
@@ -967,7 +969,7 b' class Bytes(TraitType):' | |||
|
967 | 969 | |
|
968 | 970 | |
|
969 | 971 | class CBytes(Bytes): |
|
970 | """A casting version of the string trait.""" | |
|
972 | """A casting version of the byte string trait.""" | |
|
971 | 973 | |
|
972 | 974 | def validate(self, obj, value): |
|
973 | 975 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now