Skip to content

Commit b099600

Browse files
author
Christopher Doris
committed
display PyCode and PyInternedString a bit nicer
1 parent 59c30dd commit b099600

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/PyCode.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ pyptr(co::PyCode) = begin
3434
ptr
3535
end
3636
Base.unsafe_convert(::Type{CPyPtr}, x::PyCode) = checknull(pyptr(x))
37+
Base.show(io::IO, x::PyCode) = begin
38+
show(io, typeof(x))
39+
print(io, "(")
40+
show(io, x.code)
41+
print(io, ", ")
42+
show(io, x.filename)
43+
print(io, ", ")
44+
show(io, x.mode)
45+
print(io, ")")
46+
end

src/PyInternedString.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ pyptr(x::PyInternedString) = begin
2727
ptr
2828
end
2929
Base.unsafe_convert(::Type{CPyPtr}, x::PyInternedString) = checknull(pyptr(x))
30+
Base.show(io::IO, x::PyInternedString) = begin
31+
show(io, typeof(x))
32+
print(io, '(')
33+
show(io, x.val)
34+
print(io, ')')
35+
end
3036

3137
"""
3238
pystr"..." :: PyInternedString

0 commit comments

Comments
 (0)