summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/language/python/dict.scm11
-rw-r--r--modules/language/python/dir.scm3
-rw-r--r--modules/language/python/format2.scm9
-rw-r--r--modules/language/python/list.scm16
-rw-r--r--modules/language/python/module/optparse.py1
-rw-r--r--modules/language/python/module/sys.scm6
-rw-r--r--modules/oop/pf-objects.scm2
7 files changed, 38 insertions, 10 deletions
diff --git a/modules/language/python/dict.scm b/modules/language/python/dict.scm
index 194da2d..f32b134 100644
--- a/modules/language/python/dict.scm
+++ b/modules/language/python/dict.scm
@@ -636,7 +636,7 @@
(lambda (yield)
(for ((k v : (ref self '_dict))) ()
(yield (renorm k) v)))))))
-
+
(define pop
(lambda (self k . l)
(apply pylist-pop! (ref self '_dict) (norm k) l)))
@@ -669,7 +669,14 @@
(define __repr__
(lambda (self)
- (format #f "Ns:~a" (ref (ref self '_dict) '__name__))))
+ (for ((k v : (ref self '_dict))) ((l '()))
+ (cons (format #f "~a:~a" k v) l)
+ #:final
+ (aif it (ref (ref self '_dict) '__name__)
+ (format #f "Ns-~a: ~a" it (reverse l))
+ (format #f "Ns: ~a" (reverse l))))))
+
+ (define __str__ __repr__)
(define __getattr__
(lambda (self key)
diff --git a/modules/language/python/dir.scm b/modules/language/python/dir.scm
index 457c28f..75c42d7 100644
--- a/modules/language/python/dir.scm
+++ b/modules/language/python/dir.scm
@@ -177,5 +177,4 @@
(pylist-sort! ret)
ret)))
-
-
+
diff --git a/modules/language/python/format2.scm b/modules/language/python/format2.scm
index 70ee212..4a9af31 100644
--- a/modules/language/python/format2.scm
+++ b/modules/language/python/format2.scm
@@ -63,7 +63,14 @@
(if (and (number? x) (integer? x))
(list->string (list (integer->char x)))
x)))
- ("s" (lambda (x) (scm-format #f "~a" x)))
+
+ ("s" (lambda (x)
+ (if (is-a? x <p>)
+ (aif it (ref x '__str__)
+ (scm-format #f "~a" (it))
+ (scm-format #f "~a" x))
+ (scm-format #f "~a" x))))
+
("a" (lambda (x) (scm-format #f "~a" x)))
("r" (lambda (x) (scm-format #f "~a" x)))
("%"
diff --git a/modules/language/python/list.scm b/modules/language/python/list.scm
index 5cdb3d3..7deda10 100644
--- a/modules/language/python/list.scm
+++ b/modules/language/python/list.scm
@@ -189,7 +189,13 @@
(define-method (pylist-slice (o <py-list>) n1 n2 n3)
(define N (slot-ref o 'n))
- (define (f n) (if (< n 0) (+ N n) n))
+ (define (f n)
+ (let ((x (if (< n 0) (+ N n) n)))
+ (if (< x 0)
+ 0
+ (if (> x N)
+ N
+ x))))
(let* ((n1 (f (if (eq? n1 None) 0 n1)))
(n2 (f (if (eq? n2 None) (slot-ref o 'n) n2)))
(n3 (f (if (eq? n3 None) 1 n3)))
@@ -203,7 +209,13 @@
(define-method (pylist-slice (o <string>) n1 n2 n3)
(define N (string-length o))
- (define (f n) (if (< n 0) (+ N n) n))
+ (define (f n)
+ (let ((x (if (< n 0) (+ N n) n)))
+ (if (< x 0)
+ 0
+ (if (> x N)
+ N
+ x))))
(let* ((n1 (f (if (eq? n1 None) 0 n1)))
(n2 (f (if (eq? n2 None) (string-length o) n2)))
diff --git a/modules/language/python/module/optparse.py b/modules/language/python/module/optparse.py
index 903b374..043ea9a 100644
--- a/modules/language/python/module/optparse.py
+++ b/modules/language/python/module/optparse.py
@@ -1420,6 +1420,7 @@ class OptionParser (OptionContainer):
"""
while rargs:
arg = rargs[0]
+
# We handle bare "--" explicitly, and bare "-" is handled by the
# standard arg handler since the short arg case ensures that the
# len of the opt string is greater than 1.
diff --git a/modules/language/python/module/sys.scm b/modules/language/python/module/sys.scm
index fe0a4ea..d24b7e2 100644
--- a/modules/language/python/module/sys.scm
+++ b/modules/language/python/module/sys.scm
@@ -4,6 +4,7 @@
#:use-module (language python hash)
#:use-module (language python module io)
#:use-module (language python try)
+ #:use-module (language python string)
#:use-module (language python module python)
#:use-module (oop pf-objects)
#:export (argv byteorder copyright implementation
@@ -92,8 +93,9 @@
(define exec_prefix "/usr/local")
(define executable "")
(define exit
- (lambda arg
- (apply raise SystemException arg)))
+ (lambda (arg)
+ (raise (SystemException ((@ (guile) format)
+ #f "exit called with arg ~a" arg)))))
(define flags '())
(define float_info '())
diff --git a/modules/oop/pf-objects.scm b/modules/oop/pf-objects.scm
index eff5853..4b11202 100644
--- a/modules/oop/pf-objects.scm
+++ b/modules/oop/pf-objects.scm
@@ -1472,7 +1472,7 @@ explicitly tell it to not update etc.
(define attr __getattribute__)
-(define (*str* self)
+(define (*str* self . l)
(scmstr (ref self '__name__)))
(define *setattr* __setattr__)