From nikkej at gmail.com Mon Mar 4 06:14:31 2019 From: nikkej at gmail.com (Juha Nikkanen) Date: Mon, 4 Mar 2019 13:14:31 +0200 Subject: [Python-porting] six does not work with pypy3 Message-ID: I'm running pypy3 on Fedora 29 and I found that modules depending on six does not work. For example, I can't say: Python 3.5.3 (7cafdf4fca72, Aug 27 2018, 22:02:53) [PyPy 6.0.0 with GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>>> import six >>>> import six.moves as s Traceback (most recent call last): File "", line 1, in ImportError: No module named 'six.moves' while in python 3.7.2 environment: Python 3.7.2 (default, Jan 16 2019, 19:49:22) [GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import six >>> import six.moves as s >>> print( six ) >>> print( s ) )> I think this is because it seems import lib is frozen builtin on pypy3 installation on Fedora: >>>> import sys >>>> print( sys.builtin_module_names ) ('__exceptions__', '__pypy__', '__pypy__._pypydatetime', '__pypy__.builders', '__pypy__.intop', '__pypy__.os', '__pypy__.thread', '__pypy__.time', '_ast', '_bz2', '_cffi_backend', '_codecs', '_collections', '_continuation', '_crypt', '_csv', '_frozen_importlib', '_imp', '_io', '_jitlog', '_locale', '_lsprof', '_md5', '_minimal_curses', '_multibytecodec', '_multiprocessing', '_operator', '_pickle_support', '_posixsubprocess', '_pypyjson', '_random', '_rawffi', '_rawffi.alt', '_signal', '_socket', '_sre', '_string', '_struct', '_testing', '_thread', '_vmprof', '_warnings', '_weakref', 'array', 'atexit', 'binascii', 'builtins', 'cmath', 'cpyext', 'errno', 'faulthandler', 'fcntl', 'gc', 'itertools', 'marshal', 'math', 'mmap', 'parser', 'posix', 'pwd', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'pypyjit', 'select', 'symbol', 'sys', 'termios', 'time', 'token', 'unicodedata', 'zipimport', 'zlib') -------------- next part -------------- An HTML attachment was scrubbed... URL: From brett at python.org Tue Mar 12 14:10:46 2019 From: brett at python.org (Brett Cannon) Date: Tue, 12 Mar 2019 11:10:46 -0700 Subject: [Python-porting] six does not work with pypy3 In-Reply-To: References: Message-ID: importlib is frozen in Python as well. I would file a bug with pypy3 (and I'm sure they would appreciate verification it does work with CPython 3.5). On Tue, Mar 12, 2019 at 8:38 AM Juha Nikkanen wrote: > I'm running pypy3 on Fedora 29 and I found that modules depending on six > does not work. For example, I can't say: > Python 3.5.3 (7cafdf4fca72, Aug 27 2018, 22:02:53) > [PyPy 6.0.0 with GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>>> import six > >>>> import six.moves as s > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named 'six.moves' > > while in python 3.7.2 environment: > Python 3.7.2 (default, Jan 16 2019, 19:49:22) > [GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import six > >>> import six.moves as s > >>> print( six ) > > >>> print( s ) > )> > > I think this is because it seems import lib is frozen builtin on pypy3 > installation on Fedora: > >>>> import sys > >>>> print( sys.builtin_module_names ) > ('__exceptions__', '__pypy__', '__pypy__._pypydatetime', > '__pypy__.builders', '__pypy__.intop', '__pypy__.os', '__pypy__.thread', > '__pypy__.time', '_ast', '_bz2', '_cffi_backend', '_codecs', > '_collections', '_continuation', '_crypt', '_csv', '_frozen_importlib', > '_imp', '_io', '_jitlog', '_locale', '_lsprof', '_md5', '_minimal_curses', > '_multibytecodec', '_multiprocessing', '_operator', '_pickle_support', > '_posixsubprocess', '_pypyjson', '_random', '_rawffi', '_rawffi.alt', > '_signal', '_socket', '_sre', '_string', '_struct', '_testing', '_thread', > '_vmprof', '_warnings', '_weakref', 'array', 'atexit', 'binascii', > 'builtins', 'cmath', 'cpyext', 'errno', 'faulthandler', 'fcntl', 'gc', > 'itertools', 'marshal', 'math', 'mmap', 'parser', 'posix', 'pwd', > 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'pypyjit', 'select', > 'symbol', 'sys', 'termios', 'time', 'token', 'unicodedata', 'zipimport', > 'zlib') > _______________________________________________ > Python-porting mailing list > Python-porting at python.org > https://mail.python.org/mailman/listinfo/python-porting > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tekberg at uw.edu Mon Mar 25 11:08:39 2019 From: tekberg at uw.edu (Tom Ekberg) Date: Mon, 25 Mar 2019 15:08:39 +0000 Subject: [Python-porting] co_names behavior change Message-ID: I'm using the roundup program which has been ported from Python 2.7 to Python 3.x. My group uses this program internally to track progress and document issues. Roundup is written in Python and has a templating language (TAL) that allows one to define a Python expression. This is implemented by constructing a function: d = {} exec('def f():\n return %s\n' % expr.strip(), d) self._f = d['f'] where expr contains the Python expression. To reference variables defined in the templating language it constructs a list of variable names using the names in self.__code__.co_names: self._f_varnames = vnames = [] for vname in self._f.__code__.co_names: if vname[0] not in '$_': This works fine for Python 2.7. However for Python 3.5, the value of self._f.__code__.co_names does not always contain all names referenced in the expression. When the function is executed it generates an exception saying that a variable being referenced is undefined. Some expression work correctly, some do not. I have documented an example that fails in the roundup bug tracking database: https://issues.roundup-tracker.org/issue2551026. I came up with a roundup patch that implements variation that works for both Python 2.7 and Python 3.5. My question to this group: Do you have knowledge of the different contents of __code__.co_names between Python 2.7 and Python 3.5? I'm expecting that this is a difference that is documented somewhere. I have attached an example that illustrates this problem. Tom Ekberg Senior Computer Specialist, Lab Medicine 4th Floor, Pat Steel Building Department of Laboratory Medicine Work: (206) 520-4856 Email: tekberg at uw.edu -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: python_bug.py Type: application/octet-stream Size: 1050 bytes Desc: python_bug.py URL: