]> gitweb.factorcode.org Git - factor.git/commitdiff
python: rename __builtin__ to builtins
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 18 Jan 2022 20:35:56 +0000 (12:35 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 18 Jan 2022 20:35:56 +0000 (12:35 -0800)
extra/python/ffi/ffi.factor
extra/python/modules/__builtin__/__builtin__.factor [deleted file]
extra/python/modules/builtins/builtins.factor [new file with mode: 0644]
extra/python/python-tests.factor
extra/python/syntax/syntax-tests.factor
extra/python/throwing/throwing.factor

index 010da84fd42ea1d71265e7e3417a8d601e395d0b..d63a99ab885c5ac2b9e191dc69e24575428a5711 100644 (file)
@@ -34,6 +34,19 @@ STRUCT: PyMethodDef
     { ml_flags int }
     { ml_doc c-string } ;
 
+STRUCT: PyPreConfig
+    { _config_init int }
+    { parse_argv int }
+    { isolated int }
+    { use_environment int }
+    { configure_locale int }
+    { coerce_c_locale int }
+    { coerce_c_locale_warn int }
+    ! { legacy_windows_fs_encoding int } ! on Windows
+    { utf8_mode int }
+    { dev_mode int }
+    { allocate int } ;
+
 FUNCTION: PyObject* PyCFunction_NewEx ( PyMethodDef* ml,
                                         PyObject* self,
                                         PyObject* module )
diff --git a/extra/python/modules/__builtin__/__builtin__.factor b/extra/python/modules/__builtin__/__builtin__.factor
deleted file mode 100644 (file)
index fb8c884..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-USING: python.syntax ;
-IN: python.modules.__builtin__
-
-PY-FROM: __builtin__ =>
-    callable ( obj -- ? )
-    dir ( obj -- seq )
-    int ( val -- s )
-    len ( seq -- n )
-    open ( name mode -- file )
-    range ( n -- seq )
-    repr ( obj -- str ) ;
-
-PY-METHODS: obj =>
-    __name__ ( self -- n )
-    __str__ ( o -- str ) ;
-
-PY-METHODS: file =>
-    close ( self -- )
-    fileno ( self -- n )
-    tell ( self -- n ) ;
-
-PY-METHODS: str =>
-    lower ( self -- self' )
-    partition ( self sep -- bef sep aft )
-    startswith ( self str -- ? )
-    title ( self -- self' )
-    zfill ( self n -- str' ) ;
-
-PY-METHODS: list =>
-    append ( list obj -- )
-    remove ( list obj -- ) ;
diff --git a/extra/python/modules/builtins/builtins.factor b/extra/python/modules/builtins/builtins.factor
new file mode 100644 (file)
index 0000000..58eaa24
--- /dev/null
@@ -0,0 +1,31 @@
+USING: python.syntax ;
+IN: python.modules.builtins
+
+PY-FROM: builtins =>
+    callable ( obj -- ? )
+    dir ( obj -- seq )
+    int ( val -- s )
+    len ( seq -- n )
+    open ( name mode -- file )
+    range ( n -- seq )
+    repr ( obj -- str ) ;
+
+PY-METHODS: obj =>
+    __name__ ( self -- n )
+    __str__ ( o -- str ) ;
+
+PY-METHODS: file =>
+    close ( self -- )
+    fileno ( self -- n )
+    tell ( self -- n ) ;
+
+PY-METHODS: str =>
+    lower ( self -- self' )
+    partition ( self sep -- bef sep aft )
+    startswith ( self str -- ? )
+    title ( self -- self' )
+    zfill ( self n -- str' ) ;
+
+PY-METHODS: list =>
+    append ( list obj -- )
+    remove ( list obj -- ) ;
index bde08dff11d01073e42600a400b0e41c39e9a0c1..6207461076ec3f279773e9f3baa46589d5358efe 100644 (file)
@@ -8,7 +8,7 @@ IN: python
 
 ! None testing
 { t } [
-    "__builtin__" py-import "None" getattr <none> =
+    "builtins" py-import "None" getattr <none> =
 ] py-test
 
 ! Pretty sure the # of None references should stay constant.
@@ -179,7 +179,7 @@ IN: python
 
 ! Callbacks
 : py-map ( -- alien )
-    "__builtin__" py-import "map" getattr ;
+    "builtins" py-import "map" getattr ;
 
 : py-map-call ( alien-cb -- seq )
     [
index af22e6ce219257da63ce2955a28846450db2a8df..927087e95cb1ee5c4b7a57ba32752030533f428d 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors arrays assocs continuations destructors destructors.private
 fry io.files.temp kernel math namespaces python python.ffi
-python.modules.__builtin__ python.modules.argparse python.modules.datetime
+python.modules.builtins python.modules.argparse python.modules.datetime
 python.modules.os python.modules.os.path python.modules.sys
 python.modules.time python.objects python.syntax sets splitting tools.test
 unicode ;
@@ -138,13 +138,13 @@ PY-QUALIFIED-FROM: types => UnicodeType ( -- ) ;
 ] py-test
 
 ! Make callbacks
-PY-QUALIFIED-FROM: __builtin__ =>
+PY-QUALIFIED-FROM: builtins =>
     None ( -- )
     map ( func seq -- seq' )
     reduce ( func seq -- seq' ) ;
 
 { V{ 1 2 3 } } [
-    __builtin__:$None { 1 2 3 } >py __builtin__:map py>
+    builtins:$None { 1 2 3 } >py builtins:map py>
 ] py-test
 
 : double-fun ( -- alien )
@@ -152,7 +152,7 @@ PY-QUALIFIED-FROM: __builtin__ =>
 
 { V{ 2 4 16 2 4 68 } } [
     double-fun [
-        { 1 2 8 1 2 34 } >py __builtin__:map py>
+        { 1 2 8 1 2 34 } >py builtins:map py>
     ] with-quot>py-cfunction
 ] py-test
 
@@ -161,6 +161,6 @@ PY-QUALIFIED-FROM: __builtin__ =>
 
 { 48 } [
     reduce-func [
-        { 1 2 8 1 2 34 } >py __builtin__:reduce py>
+        { 1 2 8 1 2 34 } >py builtins:reduce py>
     ] with-quot>py-cfunction
 ] py-test
index 7e783aba98d28b8b088ac4b950136b7550950c9e..2cf763d32b6b29d4d10b4b3c69fffaa10efa6768 100644 (file)
@@ -1,5 +1,5 @@
-USING: arrays kernel python python.ffi python.modules.__builtin__ python.syntax
-sequences ;
+USING: arrays kernel python python.ffi python.modules.builtins
+python.syntax sequences ;
 IN: python.throwing
 
 PY-FROM: traceback => format_tb ( tb -- seq ) ;