Skip to content

Commit 4bbfc69

Browse files
author
Christopher Doris
committed
remove repr(::Py)
1 parent 107e6b0 commit 4bbfc69

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/Py.jl

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,6 @@ Py(x) = ispy(x) ? Py(getpy(x)) : pyjl(x)
153153
Base.string(x::Py) = pyisnull(x) ? "<py NULL>" : pystr(String, x)
154154
Base.print(io::IO, x::Py) = print(io, string(x))
155155

156-
function Base.repr(x::Py)
157-
if getptr(x) == C.PyNULL
158-
return "<py NULL>"
159-
else
160-
s = pyrepr(String, x)
161-
if startswith(s, "<") && endswith(s, ">")
162-
return "<py $(SubString(s, 2))"
163-
else
164-
return "<py $s>"
165-
end
166-
end
167-
end
168-
169156
function Base.show(io::IO, x::Py)
170157
if get(io, :typeinfo, Any) == Py
171158
if getptr(x) == C.PyNULL
@@ -174,11 +161,20 @@ function Base.show(io::IO, x::Py)
174161
print(io, pyrepr(String, x))
175162
end
176163
else
177-
print(io, repr(x))
164+
if getptr(x) == C.PyNULL
165+
print(io, "<py NULL>")
166+
else
167+
s = pyrepr(String, x)
168+
if startswith(s, "<") && endswith(s, ">")
169+
print(io, "<py ", SubString(s, 2))
170+
else
171+
print(io, "<py ", s, ">")
172+
end
173+
end
178174
end
179175
end
180176

181-
function Base.show(io::IO, mime::MIME"text/plain", o::Py)
177+
function Base.show(io::IO, ::MIME"text/plain", o::Py)
182178
hasprefix = get(io, :typeinfo, Any) != Py
183179
if pyisnull(o)
184180
if hasprefix

0 commit comments

Comments
 (0)