Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'scripts': 0.03; 'example:': 0.03; 'programmer': 0.03; '21,': 0.07; 'importerror:': 0.07; 'none,': 0.07; 'lines.': 0.09; 'null,': 0.09; 'subject:files': 0.09; 'subject:modules': 0.09; '__builtin__': 0.16; 'filename:fname piece:signature': 0.16; 'invisible': 0.16; 'received:192.168.1.20': 0.16; 'renamed': 0.16; 'sane': 0.16; 'url:ch': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'wed,': 0.18; 'module': 0.19; 'example': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; '(or': 0.24; 'switch': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'that.': 0.31; 'too.': 0.31; 'url:wiki': 0.31; '"",': 0.31; 'breaking': 0.31; 'yields': 0.31; 'file': 0.32; 'there.': 0.32; 'worked': 0.33; '(most': 0.33; 'guess': 0.33; 'totally': 0.33; 'comment': 0.34; 'skip:_ 10': 0.34; 'there,': 0.34; 'subject:from': 0.34; 'created': 0.35; 'something': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'adjust': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'recent': 0.39; 'does': 0.39; '(from': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'und': 0.40; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'from:charset:utf-8': 0.61; 'providing': 0.61; 'simply': 0.61; 'simple': 0.61; 'sincerely': 0.63; 'map': 0.64; 'anything.': 0.68; 'export': 0.74; 'tossing': 0.84; 'url:php': 0.85; 'yours': 0.88; 'serious': 0.97 Date: Thu, 22 May 2014 00:09:55 +0200 From: =?UTF-8?B?Um9sYW5kIFBsw7xzcw==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Loading modules from files through C++ References: <5376ACE7.8030706@rptd.ch> <53775D68.2010009@rptd.ch> <537768FB.7060303@rptd.ch> <53778005.8030105@rptd.ch> <53778E22.3040701@rptd.ch> <53790CCF.1070905@rptd.ch> <537B8E31.7000607@rptd.ch> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Wip5n1jweiXtmmAgjbjVRumouJs7Gd78m" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 81 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1400710205 news.xs4all.nl 2969 [2001:888:2000:d::a6]:34912 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71871 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Wip5n1jweiXtmmAgjbjVRumouJs7Gd78m Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/20/2014 07:55 PM, Chris Angelico wrote: > On Wed, May 21, 2014 at 3:17 AM, Roland Pl=C3=BCss wro= te: >> The important part are the last two lines. An important module is >> lacking the __builtins__ dictionary member so I had to add it. >> >> Hopefully this works also in Py3 should I switch some time later. But = I >> guess it should seeing how simple the import now became. > An interesting omission, I'm a little surprised at that. But if your > switch to Py3 is a serious (or even half-serious) possibility, I > recommend tossing a quick comment against that line of code. Check to > see if you actually need it, and if you still do, see if there's a > change there. The module has been renamed (from __builtin__ to > builtins, although the global reference to it is still __builtins__), > so you may need to adjust something there, too. But mainly, see if you > can drop that line of code in Py3. That has been a huge mess. Py3 totally messes things up there. Even the most simply code doesn't work. Take this example: # CODE # PyModuleDef moduledef =3D { PyModuleDef_HEAD_INIT, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL }; moduledef.m_name =3D "MyModule"; moduledef.m_doc =3D "MyModule"; pModule =3D PyModule_Create( &moduledef ); PyState_AddModule( pModule, &moduledef ); PyRun_SimpleString( "print( globals() )\n" ); PyRun_SimpleString( "import MyModule\nprint( globals() )\n" ); # CODE # yields this: {'__name__': '__main__', '__builtins__': , '__doc__': None, '__loader__': , '__package__': None} Traceback (most recent call last): File "", line 1, in ImportError: No module named 'MyModule' This worked in Py2 and in Py3 created modules are invisible breaking anything. Why is there no sane documentation providing a working example for something that elementary. Any ideas what Py3 requires that it does not write into the docs as one should do? --=20 Yours sincerely Pl=C3=BCss Roland Leader and Head Programmer - Game: Epsylon ( http://www.indiedb.com/games/epsylon ) - Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine , http://dragengine.rptd.ch/wiki ) - Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php = ) - As well as various Blender export scripts und game tools --Wip5n1jweiXtmmAgjbjVRumouJs7Gd78m Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlN9JD8ACgkQjKGu9ysRWfqvSQCeKw6Ih3OStJyq/eOfpC/Nuup7 BnQAn0c+vD05enkcEkIyvOBTJ8apNDWB =1Tme -----END PGP SIGNATURE----- --Wip5n1jweiXtmmAgjbjVRumouJs7Gd78m--