pydoc code

parent 4b0dc29b
......@@ -232,7 +232,8 @@ SOURCES = \
language/python/module/reprlib.py \
language/python/module/marshal.scm \
language/python/module/imp.scm \
language/python/module/pkgutil.scm
language/python/module/pkgutil.scm \
language/python/module/pydoc.py
......
......@@ -1888,22 +1888,29 @@ empty list."
(exp vs l)))
(#:raise
((_ #f . #f)
((_ #f)
`(,(T 'raise-stx)))
((_ code . #f)
`(,(T 'raise) ,(exp vs code)))
((_ code . from)
(let ((o (gensym "o"))
(c (gensym "c")))
((_ code #f . l)
(let ((c (gensym "c")))
`(,(T 'raise)
(,(G 'let) ((,c ,(exp vs code)))
(,(G 'let) ((,o (,(G 'if) (,(O 'pyclass?) ,c)
(,c)
,c)))
(,(O 'set) ,o (,(G 'quote) __cause__) ,(exp vs from))
,o))))))
(,(G 'if) (,(O 'pyclass?) ,c)
(,c ,@(map (lambda (x) (exp vs x)) l))
,c)))))
((_ code from . l)
(let ()
(if from
(let ((o (gensym "o"))
(c (gensym "c")))
`(,(T 'raise)
(,(G 'let) ((,c ,(exp vs code)))
(,(G 'let) ((,o (,(G 'if) (,(O 'pyclass?) ,c)
(,c ,@(map (lambda (x) (exp vs x)) l))
,c)))
(,(O 'set) ,o (,(G 'quote) __cause__) ,(exp vs from))
,o))))))))
(#:yield
......
......@@ -21,7 +21,7 @@
EnvironmentError ConnectionError NotADirectoryError
ConnectionResetError ChildProcessError TimeOutError
BrokenPipeError ConnectionAbortedError SystemExit
ConnectionRefusedError ArithmeticError
ConnectionRefusedError ArithmeticError
FutureWarning))
(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
......
......@@ -415,10 +415,11 @@
(define-python-class Raise (AST)
(define __init__
(lambda (self exc cause)
(lambda (self exc cause args)
(ast self #t)
(set self 'exc exc)
(set self 'cause cause))))
(set self 'cause cause)
(set self 'args args))))
(define-python-class Global (AST)
(define __init__
......@@ -1018,12 +1019,12 @@
(if fin (compx fin ) None))))
(#:raise
((_ #f #f)
((_ #f)
(Raise None None))
((_ code . #f)
(Raise (comp code) None))
((_ code . from)
(Raise (comp code) (comp from))))
((_ code #f . l)
(Raise (comp code) None (map comp l)))
((_ code from . l)
(Raise (comp code) (comp from) (map comp l))))
(#:assert
((_ x f . _)
......
......@@ -40,7 +40,7 @@
IndexError KeyError AttributeError
sendException next
GeneratorExit sendClose RuntimeError
SyntaxError compile
SyntaxError compile OSError
len dir next dict None property range
tuple bytes bytearray locals globals
exec type object __import__ frozenset
......
This diff is collapsed.
......@@ -13,7 +13,18 @@
#:use-module (language python bytes)
#:use-module ((parser stis-parser) #:select (*whitespace* f-n f-m))
#:use-module (parser stis-parser lang python3 tool)
#:export (Formatter ascii_letters digits hexdigits))
#:export (Formatter ascii_letters digits hexdigits
expandtabs, find, join, lower, split, strip, rfind,
rstrip))
(define expandtabs py-expandtabs)
(define find py-find)
(define join py-join)
(define lower py-lower)
(define split py-split)
(define strip py-strip)
(define rfine py-rfind)
(define rstrip py-rstrip)
(define digits "0123456789")
(define ascii_letters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
......
(define-module (language python module warnings)
#:export (warn))
#:use-module (oop pf-objects)
#:export (warn filterwarnings catch_warnings))
(define (warn . l) ((@ (guile) warn) l))
(define p? #t)
(define (warn . l) (if p? ((@ (guile) warn) l)))
(define-python-class wWarn ()
(define __enter__
(lambda (self)
(set self 'p p?)))
(define __exit__
(lambda (self . x)
(set! p? (ref self 'p)))))
(define (filterwarnings x)
(if (equal? x "ignore")
(set! p? #f)))
(define (catch_warnings) (wWarn))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment