Skip to content

Commit ee4f980

Browse files
committed
Fix __name__ lookup in Function object
1 parent 89966c1 commit ee4f980

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

py/function.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Function struct {
2626
Name string // The __name__ attribute, a string object
2727
Dict StringDict // The __dict__ attribute, a dict or NULL
2828
Weakreflist List // List of weak references
29-
Module *Module // The __module__ attribute, can be anything
29+
Module Object // The __module__ attribute, can be anything
3030
Annotations StringDict // Annotations, a dict or NULL
3131
Qualname string // The qualified name
3232
}
@@ -53,7 +53,7 @@ func (o *Function) Type() *Type {
5353
// attribute.
5454
func NewFunction(code *Code, globals StringDict, qualname string) *Function {
5555
var doc Object
56-
var module *Module
56+
var module Object = None
5757
if len(code.Consts) >= 1 {
5858
doc = code.Consts[0]
5959
if _, ok := doc.(String); !ok {
@@ -64,9 +64,8 @@ func NewFunction(code *Code, globals StringDict, qualname string) *Function {
6464
}
6565

6666
// __module__: If module name is in globals, use it. Otherwise, use None.
67-
6867
if moduleobj, ok := globals["__name__"]; ok {
69-
module = (moduleobj).(*Module)
68+
module = moduleobj
7069
}
7170

7271
if qualname == "" {

0 commit comments

Comments
 (0)