1. 14 Oct, 2020 1 commit
  2. 22 Sep, 2020 2 commits
    • Kirill Smelkov's avatar
      gpython: Fix pymain to properly setup sys.path (take 2) · fb98e594
      Kirill Smelkov authored
      This continues 6b4990f6 (gpython: Fix pymain to properly setup
      sys.path[0]) - now we add test and verify that gpython actually sets
      sys.path in the same way as underlying python does:
      - don't add directory of gpython to sys.path
      - for `gpython file` add to sys.path[0] realpath(dir(file)) instead of
        dir(file)  (see PySys_SetArgvEx for the reference, and else - if we do
        not make this change - added test breaks)
      - for `gpython -m mod` add to sys.path[0] realpath('') instead of ''.
        This exactly matches PY3 behaviour, while PY2 behaviour is to add ''
        However PY3 behaviour
          * is more sane, and
          * fixes test_defer_excchain_traceback on py27-gevent
        -> so we stick to it.
      Now all tests pass again.
    • Kirill Smelkov's avatar
      gpython: Implement -W · a0016938
      Kirill Smelkov authored
      We'll need warnings control in the next patch to fix Pytest integration
      wrt python3-dbg with `-W ignore::DeprecationWarning`.
  3. 30 Jul, 2020 3 commits
    • Kirill Smelkov's avatar
      gpython: Add way to run it with threads runtime · a6b993c8
      Kirill Smelkov authored
      Until now gpython was always activating gevent on startup + adding
      goodness such as "always UTF-8 default encoding"; go, chan, b/u and
      friends available from builtin namespace, etc... While those goodness
      are sometimes useful on their own, it is not always appropriate to force
      a project to switch from threads to gevent.
      For this reason add a flag to select which runtime - either gevent
      or threads - gpython should use.
      	gpython -Xgpython.runtime=gevent	selects gevent,
      	gpython -Xgpython.runtime=threads	selects threads.
      Gevent remains the default.
      It is also possible to specify desired runtime via $GPYTHON_RUNTIME
      environment variable.
      /reviewed-on !5
    • Kirill Smelkov's avatar
      gpython: Add support for -V / --version · 70c4c82f
      Kirill Smelkov authored
      On CPython:
      	$ python -V
      	Python 2.7.18
      	$ gpython -V
      	GPython 0.0.6.post2 [gevent 20.6.2] / CPython 2.7.18
      On PyPy:
      	$ python -V
              Python 3.6.9 (2ad108f17bdb, Apr 07 2020, 02:59:05)
              [PyPy 7.3.1 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
      	$ gpython -V
      	GPython 0.0.6.post2 [gevent 20.5.0] / PyPy 7.3.1 / Python 3.6.9
      /reviewed-on !5
    • Kirill Smelkov's avatar
      gpython: Support -c<command>, not only -c <command> · e6714e49
      Kirill Smelkov authored
      And same for -m<module> - becuase Python supports it this way.
      Before the patch:
      	$ python '-cprint "hello world"'
      	hello world
      	$ gpython '-cprint "hello world"'
      	unknown option: '-cprint "hello world"'
      After the patch:
      	$ python '-cprint "hello world"'
      	hello world
      	$ gpython '-cprint "hello world"'
      	hello world
      /reviewed-on !5
  4. 29 May, 2020 1 commit
    • Kirill Smelkov's avatar
      gpython: Include gevent version into banner · 0e3da017
      Kirill Smelkov authored
      Gevent is major component gpython builds on - it deserves to be included
      into version and is handy to know if one hits a bug with gpython - to
      see in which particular runtime environment the bug was hit.
          $ gpython
          Python 3.7.3 (default, Dec 20 2019, 18:57:59)
          [GCC 8.3.0] [GPython 0.0.6.post2] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          $ gpython
          Python 3.7.3 (default, Dec 20 2019, 18:57:59)
          [GCC 8.3.0] [GPython 0.0.6.post2] [gevent 20.5.1] on linux
          Type "help", "copyright", "credits" or "license" for more information.
      /cc @gabriel, @jerome
      /proposed-for-review-on: !4
  5. 10 Feb, 2020 1 commit
    • Kirill Smelkov's avatar
      golang: Expose error at Py level · 17798442
      Kirill Smelkov authored
      The first step to expose errors and error chaining to Python:
      - Add pyerror that wraps a pyx/nogil C-level error and is exposed as golang.error at py level.
      - py errors must be compared by ==, not by "is"
      - Add (py) errors.New to create a new error from text.
      - a C-level error that has .Unwrap, is exposed with .Unwrap at py level,
        but full py-level chaining will be implemented in a follow-up patch.
      - py error does not support inheritance yet.
      Top-level documentation is TODO.
  6. 04 Feb, 2020 1 commit
    • Kirill Smelkov's avatar
      golang: Provide b, u for strings · bcb95cd5
      Kirill Smelkov authored
      With Python3 I've got tired to constantly use .encode() and .decode();
      getting exception if original argument was unicode on e.g. b.decode();
      getting exception on raw bytes that are invalid UTF-8, not being able to
      use bytes literal with non-ASCII characters, etc.
      So instead of this pain provide two functions that make sure an object
      is either bytes or unicode:
      - b converts str/unicode/bytes s to UTF-8 encoded bytestring.
      	Bytes input is preserved as-is:
      	   b(bytes_input) == bytes_input
      	Unicode input is UTF-8 encoded. The encoding always succeeds.
      	b is reverse operation to u - the following invariant is always true:
      	   b(u(bytes_input)) == bytes_input
      - u converts str/unicode/bytes s to unicode string.
      	Unicode input is preserved as-is:
      	   u(unicode_input) == unicode_input
      	Bytes input is UTF-8 decoded. The decoding always succeeds and input
      	information is not lost: non-valid UTF-8 bytes are decoded into
      	surrogate codes ranging from U+DC80 to U+DCFF.
      	u is reverse operation to b - the following invariant is always true:
      	   u(b(unicode_input)) == unicode_input
      NOTE: encoding _and_ decoding *never* fail nor loose information. This
      is achieved by using 'surrogateescape' error handler on Python3, and
      providing manual fallback that behaves the same way on Python2.
      The naming is chosen with the idea so that b(something) resembles
      b"something", and u(something) resembles u"something".
      This, even being only a part of strings solution discussed in [1],
      should help handle byte- and unicode- strings in more robust and
      distraction free way.
      Top-level documentation is TODO.
      [1] zodbtools!13
  7. 26 Aug, 2019 3 commits
  8. 14 May, 2019 1 commit
    • Kirill Smelkov's avatar
      *: __future__ += absolute_imports; Use unified __future__ everywhere · 81dfefa0
      Kirill Smelkov authored
      - we are going to introduce golang.time, and from inside there without
        `from __future__ import absolute_imports` it won't be possible to import
        needed stdlib's time.
      - we were already doing `from __future__ import print_function`, but
        only in some files.
      -> It makes sense to apply updated __future__ usage uniformly.
  9. 13 Mar, 2019 1 commit
    • Kirill Smelkov's avatar
      gpython: Fix pymain to properly setup sys.path[0] · 6b4990f6
      Kirill Smelkov authored
      Pymain was not adding e.g. directory of executed file to sys.path, and
      as the result if there were e.g. 2 files
      	dir/hello.py	# imports world
      running `gpython dir/hello.py` would fail to import world.
      The case for interactive console was also failing to setup sys.argv as
      empty, so it was containing ['/path/to/gpython']. It was also, contrary
      to standard python, unconditionally showing '>>>' prompt even when stdin
      was not a tty.
      Fix all that and add a test to cover pymain functionality.
  10. 16 Jan, 2019 1 commit