summaryrefslogtreecommitdiff
path: root/modules/language/python/module.scm
diff options
context:
space:
mode:
Diffstat (limited to 'modules/language/python/module.scm')
-rw-r--r--modules/language/python/module.scm31
1 files changed, 23 insertions, 8 deletions
diff --git a/modules/language/python/module.scm b/modules/language/python/module.scm
index adc87fd..eff20f0 100644
--- a/modules/language/python/module.scm
+++ b/modules/language/python/module.scm
@@ -11,7 +11,7 @@
#:use-module (language python dict)
#:export (Module private public import __import__ modules))
-(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
+(define-syntax-rule (aif it p . x) (let ((it p)) (if it . x)))
(define-syntax-rule (in-scheme x)
(let ((lan (current-language)))
@@ -58,7 +58,14 @@
(begin
(rawset self id (Module pre l nm))
(_make self pre nm skip-error?)))
- (_make self pre nm skip-error?))))
+ (aif it (and (module-defined? (current-module) (car nm))
+ (module-ref (current-module) (car nm)))
+ (if (module? it)
+ (begin
+ ((rawref it '__init__) pre l nm)
+ it)
+ (_make self pre nm skip-error?))
+ (_make self pre nm skip-error?)))))
(define _contupdate
(lambda (self id pre l nm)
@@ -151,14 +158,21 @@
(raise (AttributeError "getattr in Module")))
(let ((k (_k k)))
(cond
- ((memq k '(__iter__ __repr__))
+ ((memq k '(__iter__ __repr__ __dir__))
(lambda () ((rawref self k) self)))
(else
- (let ((x (module-ref (rawref self '_export) k e)))
+ (let ((x (aif it (rawref self '_export)
+ (module-ref it k e)
+ e)))
(if (eq? e x)
- (let ((x (module-ref (_m self) k e)))
+ (let ((x (aif it (_m self)
+ (module-ref it k e)
+ e)))
(if (eq? e x)
- (fail)
+ (let ((x (rawref self k e)))
+ (if (eq? e x)
+ (fail)
+ x))
x))
x)))))))
@@ -237,8 +251,9 @@
(if (not (in "-" (symbol->string k)))
(set! l (cons (symbol->string k) l))))))
(hash-for-each add h)
- (module-for-each add m)
- (module-for-each add (rawref self '_export))
+ (if m (module-for-each add m))
+ (aif it (rawref self '_export) (module-for-each add it))
+ (hash-for-each add (slot-ref self 'h))
(py-list l))))