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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

object.go

Lines changed: 7 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy