Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 092ab27

Browse files
icholysbinet
authored andcommitted
object: implement fmt.Stringer
1 parent ddccf66 commit 092ab27

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

object.go

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ type PyObject struct {
1515
ptr *C.PyObject
1616
}
1717

18+
// String returns a string representation of the PyObject
19+
func (self *PyObject) String() string {
20+
o := self.Str()
21+
defer o.DecRef()
22+
return PyString_AsString(o)
23+
}
24+
1825
func (self *PyObject) topy() *C.PyObject {
1926
return self.ptr
2027
}

python_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestErrFetch(t *testing.T) {
112112
t.Parallel()
113113
testPkg(t, pkg{
114114
path: "tests/errfetch",
115-
want: []byte("exc=&{<nil>}\nval=&{<nil>}\ntb=&{<nil>}\n"),
115+
want: []byte("exc=<NULL>\nval=<NULL>\ntb=<NULL>\n"),
116116
})
117117
}
118118

0 commit comments

Comments
 (0)