ANN: eGenix mx Base Distribution 3.2.3 (mxDateTime, mxTextTools, etc.)
ANNOUNCING eGenix.com mx Base Distribution Version 3.2.3 for Python 2.4 - 2.7 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.3-GA.html ABOUT The eGenix.com mx Base Distribution for Python is a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. Contents of the distribution: * mxDateTime - Easy to use Date/Time Library for Python * mxTextTools - Fast Text Parsing and Processing Tools for Python * mxProxy - Object Access Control for Python * mxBeeBase - On-disk B+Tree Based Database Kit for Python * mxURL - Flexible URL Data-Type for Python * mxUID - Fast Universal Identifiers for Python * mxStack - Fast and Memory-Efficient Stack Type for Python * mxQueue - Fast and Memory-Efficient Queue Type for Python * mxTools - Fast Everyday Helpers for Python The package also include a number of helpful smaller modules in the mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing or mx.Misc.CommandLine to quickly write command line applications in Python. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. For more information, please see the distribution page: http://www.egenix.com/products/python/mxBase/ NEWS The 3.2.3 release of the eGenix mx Base Distribution is the latest release of our open-source Python extensions. The new patch-level version includes a few important fixes: * Fixed a possible segfault when using the .pydate(), .pydatetime() and .pytime() methods. Thanks to Daniel Szoska for reporting this. If you are upgrading from eGenix mx Base 3.1.x, please also see the eGenix mx Base Distribution 3.2.0 release notes for details on what has changed and which new features are available: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html As always, we are providing pre-built binaries for all common platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac OS X 32/64-bit. Source code archives are available for installation on all other Python platforms, such as Solaris, AIX, HP-UX, etc. To simplify installation in Zope/Plone and other egg-based systems, we have also precompiled egg distributions for all platforms. These are available on our own PyPI-style index server for easy and automatic download. Whether you are using a pre-built package or the source distribution, installation is a simple python setup.py install command in all cases. The only difference is that the pre-built packages do not require a compiler or the Python development packages to be installed. For a full list of changes, please refer to the eGenix mx Base Distribution change log at http://www.egenix.com/products/python/mxBase/changelog.html and the change logs of the various included Python packages. DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ LICENSE The eGenix mx Base package is distributed under the eGenix.com Public License 1.1.0 which is an Open Source license similar to the Python license. You can use the packages in both commercial and non-commercial settings without fee or charge. The package comes with full source code SUPPORT Commercial support for this product is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 06 2012) Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ ::: Try our new
pytest-2.2.2: bug fixes, collectonly improvements
pytest-2.2.2 is a minor backward-compatible release of the py.test testing tool. It contains bug fixes and a few refinements particularly to reporting with --collectonly, see below for betails. For general information see here: http://pytest.org/ To install or upgrade pytest: pip install -U pytest # or easy_install -U pytest Special thanks for helping on this release to Ronny Pfannschmidt and Ralf Schmitt and the contributors of issues. best, holger krekel Changes between 2.2.1 and 2.2.2 - fix issue101: wrong args to unittest.TestCase test function now produce better output - fix issue102: report more useful errors and hints for when a test directory was renamed and some pyc/__pycache__ remain - fix issue106: allow parametrize to be applied multiple times e.g. from module, class and at function level. - fix issue107: actually perform session scope finalization - don't check in parametrize if indirect parameters are funcarg names - add chdir method to monkeypatch funcarg - fix crash resulting from calling monkeypatch undo a second time - fix issue115: make --collectonly robust against early failure (missing files/directories) - -qq --collectonly now shows only files and the number of tests in them - -q --collectonly now shows test ids - allow adding of attributes to test reports such that it also works with distributed testing (no upgrade of pytest-xdist needed) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: gcc-python-plugin 0.9
gcc-python-plugin is a plugin for GCC 4.6 onwards which embeds the CPython interpreter within GCC, allowing you to write new compiler warnings in Python, generate code visualizations, etc. It ships with gcc-with-cpychecker, which implements static analysis passes for GCC aimed at finding bugs in CPython extensions. In particular, it can automatically detect reference-counting errors: http://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html This release (0.9) is mostly about internal fixes: * support for gcc 4.7 prereleases * the plugin is now properly integrated with GCC's garbage collector, fixing segfaults that could happen when compiling large files (the Python wrapper objects no longer have their underlying GCC objects swept away from under them) * gcc-with-cpychecker's analysis logic has been reworked, fixing numerous bugs, and extending the scope of the checker enough to find 8 previously-missed memory-leak bugs when run upon itself. There are many other improvements. Detailed release notes can be seen at: http://gcc-python-plugin.readthedocs.org/en/latest/0.9.html Tarball releases are available at: https://fedorahosted.org/releases/g/c/gcc-python-plugin/ Prebuilt-documentation can be seen at: http://gcc-python-plugin.readthedocs.org/en/latest/index.html The project's homepage is: https://fedorahosted.org/gcc-python-plugin/ The plugin and checker are Free Software, licensed under the GPLv3 or later. Enjoy! Dave Malcolm -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: difference between random module in python 2.6 and 3.2?
On Mon, 06 Feb 2012 02:27:14 -0500, Terry Reedy wrote: [...] and should be treated as a bug. Raymond made a strong case arguing for repeatability, and then approved a bug fix that broke repeatability. I doubt that was deliberate. It was deliberate that randrange was changed to an even distribution from a slightly uneven distribute. That implies a change in the pattern. Okay, granted. That was known and the main subject of discussion. As Antoine said, making functions exactly repeatable across versions means not fixing bugs or otherwise improving them. This statement is not limited to the random module. You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations can be changed if improvements are needed or thought sufficiently desirable. A more explicit note will help, but the basic problem applies: how do you write deterministic tests given that the random.methods (apart from random.random itself) can be changed without warning? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: difference between random module in python 2.6 and 3.2?
On 6.2.2012 09:05, Steven D'Aprano wrote: You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations can be changed if improvements are needed or thought sufficiently desirable. A more explicit note will help, but the basic problem applies: how do you write deterministic tests given that the random.methods (apart from random.random itself) can be changed without warning? Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Could we get some hint in the release notes? Thanks for the help, Matěj -- http://mail.python.org/mailman/listinfo/python-list
Re: PyCrypto builds neither with MSVC nor MinGW
On Mon, Feb 6, 2012 at 6:39 PM, Terry Reedy tjre...@udel.edu wrote: On 2/6/2012 1:53 AM, Chris Angelico wrote: I suppose there's no chance of moving to a free compiler? VC express is free-as-in-beer. The whole V. Studio is free to core developers. MS may not *like* open-source software, but they have decided they would like it even less if everyone compiled it with non-MS compilers. Oh, that's something at least. I wasn't aware of what exactly they charge for and what they don't. Windows work, I've generally used the Open Watcom compiler; that's not to say it's the best, but it does the job, and it's free software. Would it build CPython, including the +- dependent libraries like tcl/tk? How would the speed compare? I can't answer that question without grabbing the sources, going through the whole work of porting makefiles etc, and finding out whether there's failures - in other words, doing the whole job. It's entirely possible that there'll be some dependency failure; but I would posit that, on balance, it's more likely there won't be. As to speed - I've not done a lot of compiler benchmarking. (Not sure whether you mean compilation speed or the efficiency of the resulting code; either way, I've not tried.) Never actually had multiple compilers on any one platform for long enough to do serious testing. It's hardly fair to compare Borland C++ for Windows 3.1, icc on OS/2 32-bit, Open Watcom on XP, and gcc on Debian 64-bit! It's probably not worth the hassle of changing compilers, although I do wonder whether changing compiler _versions_ isn't sometimes nearly as much work. (What? All that legacy code doesn't compile any more? Ohh... it doesn't like #include iostream.h any more...) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: difference between random module in python 2.6 and 3.2?
On 6.2.2012 09:45, Matej Cepl wrote: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Matěj -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and TAP
On 06.02.12 01:58, Matej Cepl wrote: Hi, I have just finished listening to the FLOSS Weekly podcast #200 (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned about the existence of TAP (http://testanything.org/). A standardization of testing seems to be so obviously The Right Thing™, that it is strange that I don't see much related movement in the Python world (I know only about http://git.codesimply.com/?p=PyTAP.git;a=summary or git://git.codesimply.com/PyTAP.git, which seems to be very very simple and only producer). What am I missing? Why nobody seems to care about joining TAP standard? Not sure. Probably it comes down to what you need depending on your tool chain. But there are alternatives. Most prominent to my knowledge is subunit [0]. Here is a comparison between the two [1]. One warning when you jump on the TAP train: Using the Python YAML module PyYAML you will have to find out that TAP uses a YAML subset called YAMLish [3]. It's not the same and pretty much defined by the Perl implementation. [0] https://launchpad.net/subunit [1] http://www.kinoshita.eti.br/2011/06/04/a-comparison-of-tap-test-anything-protocol-and-subunit/ [2] http://pyyaml.org/ [3] http://testanything.org/wiki/index.php/YAMLish Bye, Frank -- Frank Becker f...@alien8.de (jabber|mail) | http://twitter.com/41i3n8 GnuPG: 0xADC29ECD | F01B 5E9C 1D09 981B 5B40 50D3 C80F 7459 ADC2 9ECD signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
ANN: eGenix mx Base Distribution 3.2.3 (mxDateTime, mxTextTools, etc.)
ANNOUNCING eGenix.com mx Base Distribution Version 3.2.3 for Python 2.4 - 2.7 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.3-GA.html ABOUT The eGenix.com mx Base Distribution for Python is a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. Contents of the distribution: * mxDateTime - Easy to use Date/Time Library for Python * mxTextTools - Fast Text Parsing and Processing Tools for Python * mxProxy - Object Access Control for Python * mxBeeBase - On-disk B+Tree Based Database Kit for Python * mxURL - Flexible URL Data-Type for Python * mxUID - Fast Universal Identifiers for Python * mxStack - Fast and Memory-Efficient Stack Type for Python * mxQueue - Fast and Memory-Efficient Queue Type for Python * mxTools - Fast Everyday Helpers for Python The package also include a number of helpful smaller modules in the mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing or mx.Misc.CommandLine to quickly write command line applications in Python. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. For more information, please see the distribution page: http://www.egenix.com/products/python/mxBase/ NEWS The 3.2.3 release of the eGenix mx Base Distribution is the latest release of our open-source Python extensions. The new patch-level version includes a few important fixes: * Fixed a possible segfault when using the .pydate(), .pydatetime() and .pytime() methods. Thanks to Daniel Szoska for reporting this. If you are upgrading from eGenix mx Base 3.1.x, please also see the eGenix mx Base Distribution 3.2.0 release notes for details on what has changed and which new features are available: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html As always, we are providing pre-built binaries for all common platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac OS X 32/64-bit. Source code archives are available for installation on all other Python platforms, such as Solaris, AIX, HP-UX, etc. To simplify installation in Zope/Plone and other egg-based systems, we have also precompiled egg distributions for all platforms. These are available on our own PyPI-style index server for easy and automatic download. Whether you are using a pre-built package or the source distribution, installation is a simple python setup.py install command in all cases. The only difference is that the pre-built packages do not require a compiler or the Python development packages to be installed. For a full list of changes, please refer to the eGenix mx Base Distribution change log at http://www.egenix.com/products/python/mxBase/changelog.html and the change logs of the various included Python packages. DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ LICENSE The eGenix mx Base package is distributed under the eGenix.com Public License 1.1.0 which is an Open Source license similar to the Python license. You can use the packages in both commercial and non-commercial settings without fee or charge. The package comes with full source code SUPPORT Commercial support for this product is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 06 2012) Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ ::: Try our new
nested embedding of interpreter
Hello, I work with a 3rd party tool that provides a C API for customization. I created Python bindings for this C API so my customizations are nothing more than this example wrapper code almost verbatim: http://docs.python.org/extending/embedding.html#pure-embedding I have many .c files just like that only differing by the module and function that they load and execute. This has been working fine for a long time. Now, as we add more and more customizations that get triggered at various events we have come to a problem. If some of the Python customization code gets triggered from inside another Python customization I get a segfault. I thought this might have something to do with the nesting which is the equivalent of calling Py_Initialize() twice followed by Py_Finalize() twice. I went into the C wrapper code for the inner-most customization and commented out the Py_Initialize and Py_Finalize calls and it worked nicely. Further testing showed that I only needed to remove the Py_Finalize call and that calling Py_Initialize twice didn't cause a segfault. So, now that I think I verified that this is what was causing the segfault, I'd like to ask some questions. 1) Is calling Py_Initialize twice correct, or will I run into other problems down the road? 2) Another option I have is that I can remove all Py_Initialize / Py_Finalize calls from the individual customizations and just call Py_Initialize once when a user first starts the program. I am not sure if there is a mechanism to get something called at the end of the user's session with the program though, so is it a problem if I don't call Py_Finalize at the end? 3) Is there a proper way to nest these things? I imagine not since Py_Finalize doesn't take any arguments. If I could do... int session = Py_Initialize() Py_Finalize(session) But obviously, CPython is not coded that way so it is not supported. Thanks, ~Eric -- http://mail.python.org/mailman/listinfo/python-list
Re: difference between random module in python 2.6 and 3.2?
Steven D'Aprano wrote: A more explicit note will help, but the basic problem applies: how do you write deterministic tests given that the random.methods (apart from random.random itself) can be changed without warning? Biting the bullet would mean supplying your own PRNG, under your control. Jon Bentley somewhere, sometime, published a portable PRNG for that exact reason. (I wish I could find that article.) Specifically he wanted portability across various manufacturer's O/Ss. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: difference between random module in python 2.6 and 3.2?
On 02/06/2012 09:57 AM, Matej Cepl wrote: On 6.2.2012 09:45, Matej Cepl wrote: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Matěj Is the above actually a good idea though? What I understand you're doing is embedding the source from the Python2.6 random.py file, /into/ your project files? Regards, A -- http://mail.python.org/mailman/listinfo/python-list
Re: difference between random module in python 2.6 and 3.2?
On 02/06/12 12:48, Aaron France wrote: On 02/06/2012 09:57 AM, Matej Cepl wrote: Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Matěj Is the above actually a good idea though? What I understand you're doing is embedding the source from the Python2.6 random.py file, /into/ your project files? In an ideal world, the code wouldn't have broken backwards compat. However, given the conditions, if Matej is willing to forgo bug-fixes, it's a reasonable solution. The alternate might be to try moving the recent/fixed version into the old project and updating tests/data to work with it. I have some 2.4 production code in which I've pulled 2.6's zipfile module in to give access to the iterator access (rather than the .read() method which tries to read in umpteen gigs of data that I just want to spool out to a file on disk). -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: nested embedding of interpreter
Hello, Eric Frederich eric.frederich at gmail.com writes: 1)Is calling Py_Initialize twice correct, or will I run into other problems down the road? It's fine in practice (spurious calls are ignored). I am not sure if there is a mechanism to get something called at the end of the user's session with the program though, so is it a problem if I don't call Py_Finalize at the end? Yes, it's a problem. If you don't call Py_Finalize, atexit handlers, object destructors and the like will not be called. These include destructors of file objects (including stdout): any buffering in a still-open file opened for writing can be lost. Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and TAP
On 2/6/2012 7:24 AM, Frank Becker wrote: On 06.02.12 01:58, Matej Cepl wrote: I have just finished listening to the FLOSS Weekly podcast #200 (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned about the existence of TAP (http://testanything.org/). A standardization of testing seems to be so obviously The Right Thing™, that it is strange that I don't see much related movement in the Python world (I know only TAP is not about 'standardization of testing' but standardized communication of test results between test modules and test harness. Python's two stdlib test packages include both test-writing methods and a test harness. They are compatible in the sense that doctests can be run within the unittest framework. about http://git.codesimply.com/?p=PyTAP.git;a=summary or git://git.codesimply.com/PyTAP.git, which seems to be very very simple and only producer). I presume PyTAP does something like converting (or rather, wrapping) output from unittests to (or rather, within) the TAP format, which includes wrapping in YAMLish. Or it provides alternate versions of the numerous AssertXxx functions in unittest. This is useful for someone running Python tests within a TAP harness, but not otherwise. What am I missing? Why nobody seems to care about joining TAP standard? The 'TAP standard' is what the Perl TAP module does. There is a pre-draft for an IETF standard. You could ask why Perl people don't care about joining the unittest 'standard'. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and TAP
On 6.2.2012 21:51, Terry Reedy wrote: The 'TAP standard' is what the Perl TAP module does. There is a pre-draft for an IETF standard. You could ask why Perl people don't care about joining the unittest 'standard'. I don't think it is fair: http://en.wikipedia.org/wiki/Test_Anything_Protocol#External_links (or http://testanything.org/wiki/index.php/TAP_Producers and http://testanything.org/wiki/index.php/TAP_Consumers) shows a lot of producers and consumers in various programming languages. Matěj -- http://mail.python.org/mailman/listinfo/python-list
Re: difference between random module in python 2.6 and 3.2?
On 6.2.2012 20:26, Tim Chase wrote: In an ideal world, the code wouldn't have broken backwards compat. However, given the conditions, if Matej is willing to forgo bug-fixes, it's a reasonable solution. The alternate might be to try moving the recent/fixed version into the old project and updating tests/data to work with it. I have some 2.4 production code in which I've pulled 2.6's zipfile module in to give access to the iterator access (rather than the .read() method which tries to read in umpteen gigs of data that I just want to spool out to a file on disk). Given I really don't care that much about distribution of my choice, this function def _choice(self, seq): Choose a random element from a non-empty sequence. Embedding random.choice from 2.6 in order to get an uniform results between 2.6 and 3.2, where random module has been changed because of http://bugs.python.org/issue9025. See also http://groups.google.com/group/comp.lang.python\ /browse_thread/thread/2b000b8ca8c5e98e Raises IndexError if seq is empty return seq[int(random.random() * len(seq))] doesn't seem like something so terrible (and maintenance intense). :) Thanks for the help though Matěj -- http://mail.python.org/mailman/listinfo/python-list
ctypes pointer
Hi, I wish to call a function in c++ dll which returns a unicode array from python. extern c { __declspec(dllexport) int test(wchar_t** ppText) { *ppText = new wchar_t[30]; wcscpy(*ppText, Lthis is a test); return 0; } __declspec(dllexport) int FreeString(wchar_t** ppText) { delete [] *ppText; return 0; } } In python I'm doing this import ctypes dll = ctypes.cdll.LoadLibrary(rx) func = dll.test func.argtypes = [ ctypes.POINTER(ctypes.c_wchar_p)] funcDel = dll.FreeString funcDel.argtypes = [ctypes.POINTER(ctypes.c_wchar_p)] a = ctypes.c_wchar_p('') z = ctypes.pointer(a) n= func(z) print a /* displays this is a test */ /* is this correct way to return charater array */ /* will memory allocated in c++ function be freed by python */ /* or should I call */ n = funcDel(z) thanks, Nitin. -- http://mail.python.org/mailman/listinfo/python-list
Re: SnakeScript? (CoffeeScript for Python)
See the link I attached. Ruby-like blocks would be nice too. Implicit returns. Better strings like My name is #{name}. -- http://mail.python.org/mailman/listinfo/python-list
convert perl-script for voltcraft voltmeter to python [newbie]
I'd like to read in the output of a voltcraft vc960 voltmeter connected to a usb-port. I found the perl-script below but I'd like to accomplish the same with python: I guess I have to use the module serial but I don't know how I should set the serial parameters so they are the same as in the perl-script. Could someone supply me the command for setting the serial-parameters correctly in Python? thanks Jean #!/usr/bin/perl use strict; use warnings; use Device::SerialPort; die(Usage: $0 /dev/ttyS0\n) unless $#ARGV == 0; my ($devicepath) = @ARGV; my $port = new Device::SerialPort($devicepath); die Couldn't open serial port if ! defined $port; $port-baudrate(2400); $port-databits(8); $port-parity(none); $port-stopbits(1); $port-handshake(none); $port-rts_active(0); $port-dtr_active(1); #$port-read_char_time(5); # wait 5ms per character $port-read_const_time(200); # 0.2 second per unfulfilled read call $| = 1; # autoflush STDOUT while(1) { my ($nin, $in) = $port-read(255); print $in; } $port-close; -- http://mail.python.org/mailman/listinfo/python-list
Re: SnakeScript? (CoffeeScript for Python)
On Feb 3, 8:42 pm, Matej Cepl mc...@redhat.com wrote: Ask anybody developing in CoffeeScript/Vala how much they love debugging when they have to go through different styles of errors, bugs in the intermediate processes, etc. I develop in CoffeeScript. I love debugging it because _it's just javascript_. CS doesn't replace JS in any way. It just provides some convenience to cover a lot of the regular heavy lifting. If you're trying to write CS without any understanding of JS at all, well, I can see how that might be a problem, but that's hardly CoffeeScript's failing. -- http://mail.python.org/mailman/listinfo/python-list
Help with COM_error
I am not a programmer, but this past week I have had a crash course in python scripting am have been rather impressed with myself for having written a fairly complicated script that among many other processes reads a database table via SearchCursor, populates a word template via Bookmarks, then saves the document out as a PDF. The only problem is that it only works on my computer. When I move the script to another computer with the same setup, I continue to receive a Com_error. The script fails at my SaveAs(out_TOC, FileFormat=wdFormatPDF) statement. I have tried both win32com.client and comtypes.client and receive a similar error for both. win32.client: com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', u'Command failed', u'C:\\Program Files\\Microsoft Office\\Office12\ \1033\\WDMAIN11.CHM', 36966, ), None) comtypes.client: COMError: (-2146824090, None, (u'Command failed', u'Microsoft Word', u'C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM', 36966, None)) It has been suggested that I try python-docx, but I have not been able to get the module to work for me and I have been unable to find any documentation on it. Can anyone help with the com errors? What do they mean? How do I resolve them? Any help would be appreciated. John -- http://mail.python.org/mailman/listinfo/python-list
Re: SnakeScript? (CoffeeScript for Python)
On Feb 2, 9:23 pm, Michal Hantl michal.ha...@gmail.com wrote: See the link I attached. Ruby-like blocks would be nice too. Implicit returns. Better strings like My name is #{name}. Uhu... Looks like you want Ruby, not Python g -- http://mail.python.org/mailman/listinfo/python-list
Re: convert perl-script for voltcraft voltmeter to python [newbie]
As my request might have been too much asked, I have started doing some coding myself. I'm in doubt about the readline statement -which doesn't show anything received- as the meter sends continuously streams of 11 bytes Is there a way to just monitor with python what is arriving at a serial port? #!/usr/bin/python #version 1-2-2012, script to read data from voltcraft vc940-meter import serial, time, os voltport='/dev/ttyUSB2' print Be sure the Voltcraft is connected to ttyUSB2 print Enter a filename:, filename = raw_input() voltdata = open(filename,'w') ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, timeout=15) print rs-232 parameters of Voltcraft: , ser2 print Opening + ser2.portstr received=ser2.readline() print received print Goodbye, data logged in file: print filename ser2.close() # Close file voltdata.close() On 2 feb, 21:57, Jean Dupont jeandupont...@gmail.com wrote: I'd like to read in the output of a voltcraft vc960 voltmeter connected to a usb-port. I found the perl-script below but I'd like to accomplish the same with python: I guess I have to use the module serial but I don't know how I should set the serial parameters so they are the same as in the perl-script. Could someone supply me the command for setting the serial-parameters correctly in Python? thanks Jean #!/usr/bin/perl use strict; use warnings; use Device::SerialPort; die(Usage: $0 /dev/ttyS0\n) unless $#ARGV == 0; my ($devicepath) = @ARGV; my $port = new Device::SerialPort($devicepath); die Couldn't open serial port if ! defined $port; $port-baudrate(2400); $port-databits(8); $port-parity(none); $port-stopbits(1); $port-handshake(none); $port-rts_active(0); $port-dtr_active(1); #$port-read_char_time(5); # wait 5ms per character $port-read_const_time(200); # 0.2 second per unfulfilled read call $| = 1; # autoflush STDOUT while(1) { my ($nin, $in) = $port-read(255); print $in; } $port-close; -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE not setting current directory in its path
On Jan 31, 6:12 pm, Terry Reedy tjre...@udel.edu wrote: On 1/31/2012 11:27 AM, gujax wrote: Thanks Terry, I see that the issue has been closed by you. However, I do not know how to run the patch on my Windows. Do I reinstall IDLE? Please suggest. I am using Python2.7 Thank you Terry, The patch suggested by you has worked for me, gujax Choices: 1. Wait for the next 2.7 release, which should be within a month. Easiest ;-). Will get you all other patches too. 2. Edit the files by hand, deleting lines marked - in the patch and adding lines marked +. Or change lines so they match the + lines. Harder, but you get the one change now instead of later. 3. Download and install TortoiseHG, turn your python installation (or just the idlelib directory) into a repository, apply the patch (or an edited version thereof), and perhaps delete the repository stuff. I would only do this if you want to learn to use (Tortoise)HG anyway, perhaps so you can apply other patches too, without waiting. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE not setting current directory in its path
On Jan 31, 6:12 pm, Terry Reedy tjre...@udel.edu wrote: On 1/31/2012 11:27 AM,gujaxwrote: Thanks Terry, I see that the issue has been closed by you. However, I do not know how to run the patch on my Windows. Do I reinstall IDLE? Please suggest. I am using Python2.7 Hi Terry, I changed the two files as suggested in your patch and it worked. Thank you, gujax Choices: 1. Wait for the next 2.7 release, which should be within a month. Easiest ;-). Will get you all other patches too. 2. Edit the files by hand, deleting lines marked - in the patch and adding lines marked +. Or change lines so they match the + lines. Harder, but you get the one change now instead of later. 3. Download and install TortoiseHG, turn your python installation (or just the idlelib directory) into a repository, apply the patch (or an edited version thereof), and perhaps delete the repository stuff. I would only do this if you want to learn to use (Tortoise)HG anyway, perhaps so you can apply other patches too, without waiting. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: copy on write
On Feb 2, 11:28 pm, Chris Angelico ros...@gmail.com wrote: On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: No matter what Python did, somebody would complain. +1 This is, I think, the ultimate truth of the matter. People would not complain if they did not care. The only useless complaint is people complaining about other people complaining. And the only thing worse than that is rabid fanboi brown-nosing! -- http://mail.python.org/mailman/listinfo/python-list
Re: convert perl-script for voltcraft voltmeter to python [newbie]
On 2/2/2012 3:57 PM, Jean Dupont wrote: I'd like to read in the output of a voltcraft vc960 voltmeter connected to a usb-port. I found the perl-script below but I'd like to accomplish the same with python: The script below is for an old-fashioned, slow, multiple-pin serial port, not usb. I don't know anything about interfacing through usb. Recheck what the voltmeter actually connects to. I guess I have to use the module serial but I don't know how I should set the serial parameters so they are the same as in the perl-script. Could someone supply me the command for setting the serial-parameters correctly in Python? Last I know, pyserial is also for old serial ports. Setting the properties should be pretty obvious from the manual or code. There are also python usb modules. http://sourceforge.net/projects/mysql-python/?source=directory #!/usr/bin/perl use strict; use warnings; use Device::SerialPort; die(Usage: $0 /dev/ttyS0\n) unless $#ARGV == 0; my ($devicepath) = @ARGV; my $port = new Device::SerialPort($devicepath); die Couldn't open serial port if ! defined $port; $port-baudrate(2400); $port-databits(8); $port-parity(none); $port-stopbits(1); $port-handshake(none); $port-rts_active(0); $port-dtr_active(1); #$port-read_char_time(5); # wait 5ms per character $port-read_const_time(200); # 0.2 second per unfulfilled read call $| = 1; # autoflush STDOUT while(1) { my ($nin, $in) = $port-read(255); print $in; } $port-close; -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
undefined symbol: PyUnicodeUCS4_AsUTF8String
I'm attempting to run a python script in Blender (blender3d.org) which is generating an error 8 ~~ File /home/dave/Apps/blender-2.49b-linux-glibc236-py26- x86_64/.blender/scripts/pantographLib.py, line 1941, in Pen MITER = cairo.LINE_JOIN_MITER NameError: name 'cairo' is not defined 8 ~~ When I type import cairo from within the blender python console, I get the following error which (I am presuming) is why the Cairo libraries are not being loaded. 8 ~~ type 'exceptions.ImportError': /usr/lib/python2.6/dist-packages/ cairo/_cairo.so: undefined symbol: PyUnicodeUCS4_AsUTF8String 8 ~~ The machine has three versions of python installed, 2.6 (which is the version that Blender has been compiled against and is using), 2.7 and 3.2. Presumably, there is an unicode conflict which needs to be resolved. Can anyone offer any suggestions on resolving this? Kind regards, Dave Coventry -- http://mail.python.org/mailman/listinfo/python-list
pySerial question, setting certain serial parameters [newbie]
I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): $port-handshake(none); $port-rts_active(0); $port-dtr_active(1); I have thus far the following statements but I think it does not set the above parameters correctly: import serial voltport='/dev/ttyUSB2' ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) thanks Jean -- http://mail.python.org/mailman/listinfo/python-list
building a dictionary dynamically
How do you build a dictionary dynamically? Doesn't seem to be an insert object or anything. So I need an empty dictionary that I then want to populate with values I get from looping through a list and grabbing some properties. So simply, I have (fyi, arcpy = module for interacting with gis data) inDict = {} for inFC in inFClist: print inFC inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) where I want to make a dictionary like {inFC: inCount, inFC: inCount, } How do I build this??? And, is dictionaries the best route go about doing a comparison, such that in the end I will have two dictionaries, one for IN and one for OUT, as in I'm moving data files and want to verify that the count in each file matches between IN and OUT. Thanks for any help! -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin debugger holds onto global logging objects too long
On Jan 24, 2:52 pm, Rob Richardson rdrichard...@rad-con.com wrote: I use PythonWin to debug the Python scripts we write. Our scripts often use the log2pyloggingpackage. When running the scripts inside the debugger, we seem to get oneloggingobject for every time we run the script. The result is that after running the script five times, the log file contains five copies of every message. The only way I know to clean this up and get only a single copy of each message is to close PythonWin and restart it. What do I have to do in my scripts to clean up theloggingobjects so that I never get more than one copy of each message in my log files? I don't know what log2py is - Google didn't show up anything that looked relevant. If you're talking about the logging package in the Python standard library, I may be able to help: but a simple script that I ran in PythonWin didn't show any problems, so you'll probably need to post a short script which demonstrates the problem when run in PythonWin. Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
os.stat last accessed attribute updating last accessed value
I am trying to obtain the last accessed date. About 50% of the files' attributes were updated such that the file was last accessed when this script touches the file. I was not opening the files Anyone have a thought of why this happened. Python 2.6 on windows xp -- http://mail.python.org/mailman/listinfo/python-list
Re: building a dictionary dynamically
On Feb 4, 6:13 pm, noydb jenn.du...@gmail.com wrote: How do you build a dictionary dynamically? Doesn't seem to be an insert object or anything. So I need an empty dictionary that I then want to populate with values I get from looping through a list and grabbing some properties. So simply, I have (fyi, arcpy = module for interacting with gis data) inDict = {} for inFC in inFClist: print inFC inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) where I want to make a dictionary like {inFC: inCount, inFC: inCount, } How do I build this??? And, is dictionaries the best route go about doing a comparison, such that in the end I will have two dictionaries, one for IN and one for OUT, as in I'm moving data files and want to verify that the count in each file matches between IN and OUT. Thanks for any help! Dictionaries are mutable, you can modify them in place: myDict = {} for myKey in myList: ... myDict[myKey] = doSomething(myKey) Dictionaries sound like a good way to go. You only need the one dictionary though, the IN one. When processing the outCount values you can just check them against the inDict at that point. Regards, Chard. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.stat last accessed attribute updating last accessed value
On Feb 4, 9:33 pm, Python_Junkie software.buy.des...@gmail.com wrote: I am trying to obtain the last accessed date. About 50% of the files' attributes were updated such that the file was last accessed when this script touches the file. I was not opening the files Anyone have a thought of why this happened. Python 2.6 on windows xp Read up on NTFS - but on some file systems - to check a file access time is, well umm, is accessing it. Also possible that listing a directory is considered an access. It's the least useful of all records - I've only ever possibly wanted modification or creation times. hth, Jon. -- http://mail.python.org/mailman/listinfo/python-list
Re: building a dictionary dynamically
On 02/04/2012 01:13 PM, noydb wrote: How do you build a dictionary dynamically? Doesn't seem to be an insert object or anything. So I need an empty dictionary that I then want to populate with values I get from looping through a list and grabbing some properties. So simply, I have (fyi, arcpy = module for interacting with gis data) inDict = {} for inFC in inFClist: print inFC inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) where I want to make a dictionary like {inFC: inCount, inFC: inCount, } How do I build this??? And, is dictionaries the best route go about doing a comparison, such that in the end I will have two dictionaries, one for IN and one for OUT, as in I'm moving data files and want to verify that the count in each file matches between IN and OUT. Thanks for any help! A dictionary is a mapping from key to value. So each entry consists of a key and a value, where the key is unique. As soon as you add another item with the same key, it overwrites the earlier one. The only other important constraint is that the key has to be of an immutable type, such as int or string. So you want to add the current inFC:inCount as an item in the dictionary? Put the following in your loop. inDict[inFC] = inCount You might also want to check if the key is a duplicate, so you could warn your user, or something. Easiest way to do that is if inFC in inDict: -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: copy on write
On 3 Feb., 11:47, John O'Hagan resea...@johnohagan.com wrote: But isn't it equally true if we say that z = t[1], then t[1] += x is syntactic sugar for z = z.__iadd__(x)? Why should that fail, if z can handle it? It's more like syntactic sugar for y = t; z = y.__getitem__(1); z.__iadd__(x); y.__setitem__(1, z) It's clear that only the last expression fails, after the mutation has taken place. Just in case you wonder about the y: you need it for more complicated cases. t[1][1] += [4] is syntactic sugar for y = t.__getitem__(1); z = y.__getitem__(1); z.__iadd__([4]); y.__setitem__(1, z) That makes clear why there's no exception in this code: t = (0, [1, [2, 3]]) t[1][1] += [4] t (0, [1, [2, 3, 4]]) -- http://mail.python.org/mailman/listinfo/python-list
Visual Studio 2010 Support
PIL, PyCrypto and many other modules require a C compiler and linker. Unfortunately neither install on my computer, with a PATH with the following: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC C:\libraries\MinGW\msys\1.0\bin C:\libraries\MinGW C:\Python27\Scripts Output from G:\pycryptovcvarsall.bat Setting environment for using Microsoft Visual Studio 2010 x86 tools. Error output from G:\pycryptopython setup.py build --compiler msvc http://pastebin.com/nBsuXDGg Error output from G:\pycryptopython setup.py build --compiler mingw32 1 log1 2 log2 Log1: http://pastebin.com/yG3cbdZv Log2: http://pastebin.com/qvnshPeh Will there ever be support for newer MSVC versions? - Also, why doesn't even MinGW install PyCrypto for me? Thanks for all suggestions, Alec Taylor -- http://mail.python.org/mailman/listinfo/python-list
Re: Common LISP-style closures with Python
On Feb 3, 6:27 pm, Antti J Ylikoski antti.yliko...@tkk.fi wrote: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: [...] do my eyes not see nor my ears not hear? a thread about common Lisp and Xan Lee is not near? would someone please him wake up and tell him all about, the thread titled Common LISP-style closures with Python and that he has been left out! -- http://mail.python.org/mailman/listinfo/python-list
Re: pySerial question, setting certain serial parameters [newbie]
On Sat, Feb 4, 2012 at 4:47 AM, Jean Dupont jeandupont...@gmail.com wrote: I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): $port-handshake(none); $port-rts_active(0); $port-dtr_active(1); I have thus far the following statements but I think it does not set the above parameters correctly: import serial voltport='/dev/ttyUSB2' ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) A link to the Perl library's documentation would be helpful. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Help about dictionary append
On Feb 5, 4:29 pm, Andrew Berg bahamutzero8...@gmail.com wrote: This has nothing to do with dictionaries. If you want to add, delete, or change items, use a list (or a set if there aren't supposed to be any duplicates). AND you don't care about ordering... -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie socket help
OS is Red hat enterprise linux 5.5 and python version is 2.6 On Feb 2, 4:34 pm, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Thu, 2 Feb 2012 05:53:22 -0800 (PST), loial jldunn2...@gmail.com wrote: I am trying to write a python script to read data from a printer port using python sockets, but it seems I am locking up the port. Is there a way to ensure that I do not block the port to other applications? My knowledge of python sockets is minimal, so any help would be appreciated. OS and Python version might be of interest... However, parallel ports are typically unshared devices (which is why any multitasking system has things like print spooling -- so multiple tasks and print to the spool, and the spool driver is the only process actually accessing the printer port). I still have nightmares over one assignment I had some 8 years ago: Reading a clock signal (square wave) on one of the parallel port's signal pins, in order to time a three-bit /balanced/ (using 6-pins of the output) data stream. Done on a W98 laptop (since W98 didn't have the protected ports of WinXP) using Visual C++ -- and on the laptop as the eventual plan had been to send red GPS decryption keys to satellites; contact with red keys makes the hardware it passes through highly classified, and the main hardware had to stay open for uncleared developers working on flight software. Unfortunately, even with the program running at the highest available Windows priority, the OS still did something every few milliseconds, which led to glitches in the output stream. (The good news: by the time the DTD with the keys became available, the CONOPS had changed to use black keys, which did not infect the computer system -- so the regular command formatter could be used for uploading). -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: undefined symbol: PyUnicodeUCS4_AsUTF8String
IIRC it means that cairo was compiled against a Python compiled with --enable-unicode=ucs4. But the version of Python you have was not (default is ucs2). Maybe you can find a different version/packaging of cairo that matches this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with COM_error
Unfortunately this just means that Word threw an error and it's not giving many details about what that might be. Are you sure out_TOC is valid on the other computer? eg, http://stackoverflow.com/questions/3730428/why-cant-i-save-as-an-excel-file-from-my-python-code indicates Office fails in that way when the path isn't valid... Mark On 4/02/2012 12:10 AM, John Lay wrote: I am not a programmer, but this past week I have had a crash course in python scripting am have been rather impressed with myself for having written a fairly complicated script that among many other processes reads a database table via SearchCursor, populates a word template via Bookmarks, then saves the document out as a PDF. The only problem is that it only works on my computer. When I move the script to another computer with the same setup, I continue to receive a Com_error. The script fails at my SaveAs(out_TOC, FileFormat=wdFormatPDF) statement. I have tried both win32com.client and comtypes.client and receive a similar error for both. win32.client: com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', u'Command failed', u'C:\\Program Files\\Microsoft Office\\Office12\ \1033\\WDMAIN11.CHM', 36966, ), None) comtypes.client: COMError: (-2146824090, None, (u'Command failed', u'Microsoft Word', u'C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM', 36966, None)) It has been suggested that I try python-docx, but I have not been able to get the module to work for me and I have been unable to find any documentation on it. Can anyone help with the com errors? What do they mean? How do I resolve them? Any help would be appreciated. John -- http://mail.python.org/mailman/listinfo/python-list
Re: PyCrypto builds neither with MSVC nor MinGW
On Feb 5, 6:40 am, Alec Taylor alec.tayl...@gmail.com wrote: PIL, PyCrypto and many other modules require a C compiler and linker. Unfortunately neither install on my computer, with a PATH with the following: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC C:\libraries\MinGW\msys\1.0\bin C:\libraries\MinGW C:\Python27\Scripts Output from G:\pycryptovcvarsall.bat Setting environment for using Microsoft Visual Studio 2010 x86 tools. Error output from G:\pycryptopython setup.py build --compiler msvc http://pastebin.com/nBsuXDGg A couple of comments. You will need to complile either GMP or MPIR first. MPIR is a windows friendly fork of GMP and I use it create Windows binaries for gmpy. Error output from G:\pycryptopython setup.py build --compiler mingw32 1 log1 2 log2 Log1:http://pastebin.com/yG3cbdZv Log2:http://pastebin.com/qvnshPeh Will there ever be support for newer MSVC versions? - Also, why Python 2.7 uses VS2008. I use the command line compiler included with in Microsoft's SDK 7.0 which is still available for download. I have step- by-step build instructions included in gmpy's source download. I would try to build MPIR and gmpy first and then adapt/modify the process for PyCrypto. MPIR home page: www.mpir.org gmpy source: gmpy.googlecode.com/files/gmpy-1.15.zip doesn't even MinGW install PyCrypto for me? Thanks for all suggestions, Alec Taylor Hope these comments help... casevh -- http://mail.python.org/mailman/listinfo/python-list
Re: Http post and http get
Cookies work because I am able to login on website and GET other pages. -- http://mail.python.org/mailman/listinfo/python-list
how to read serial stream of data [newbie]
I'd like to read in a stream of data which looks like this: the device sends out a byte-string of 11 bytes roughly every second: B0B0B0B0B03131B0B50D8A B0B0B0B0B03131B0B50D8A B0B0B031B63131B0310D8A B0B034B3323432B3310D8A B0B03237B53432B3310D8A . . . As you see every string is ended by 0D8A How can this be accomplished in Python? thanks Jean -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and TAP
On Feb 6, 10:58 am, Matej Cepl mc...@redhat.com wrote: I have just finished listening to the FLOSS Weekly podcast #200 (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned about the existence of TAP (http://testanything.org/). [...] What am I missing? Experience? Are you seriously advocating something for which you've done nothing more than watch a podcast? Why nobody seems to care about joining TAP standard? You just discovered it, why do you assume that everyone else is familiar with it? Use it, document your successes and failures, and then if it _has value to you_ come back and tell us about your experiences. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and TAP
On Feb 7, 8:03 am, Matej Cepl mc...@redhat.com wrote: On 6.2.2012 21:51, Terry Reedy wrote: The 'TAP standard' is what the Perl TAP module does. There is a pre-draft for an IETF standard. You could ask why Perl people don't care about joining the unittest 'standard'. I don't think it is fair:http://en.wikipedia.org/wiki/Test_Anything_Protocol#External_links(orhttp://testanything.org/wiki/index.php/TAP_Producersandhttp://testanything.org/wiki/index.php/TAP_Consumers) shows a lot of producers and consumers in various programming languages. That doesn't really disprove Terry's point. A lot of languages support Perl's regular expression syntax too: http://en.wikipedia.org/wiki/Regular_expression#Perl-derived_regular_expressions -- http://mail.python.org/mailman/listinfo/python-list
Re: building a dictionary dynamically
On Feb 5, 4:13 am, noydb jenn.du...@gmail.com wrote: How do you build a dictionary dynamically? inDict = {} for inFC in inFClist: print inFC inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) where I want to make a dictionary like {inFC: inCount, inFC: inCount, } How do I build this??? The easiest way is to use the standard dictionary constructor. dict() can accept a list of key/value pairs: pairs = [('a',1), ('b',2), ('c',3)] dict(pairs) {'a': 1, 'c': 3, 'b': 2} And one way to build a list is with a list comprehension: pairs = [(key, i+1) for i, key in enumerate(['a','b','c'])] pairs [('a', 1), ('b', 2), ('c', 3)] So you can combine the two, using a list comprehension to build the list that is passed into dict(): dict([(key, i+1) for i, key in enumerate(['a','b','c'])]) {'a': 1, 'c': 3, 'b': 2} As a convenience, you don't need the square brackets: dict((key, i+1) for i, key in enumerate(['a','b','c'])) {'a': 1, 'c': 3, 'b': 2} For your example, I'd go with something like this: getCount = lambda x: int(arcpy.GetCount_management(x).getOutput(0)) inDict = dict( (inFC, getCount(inFC)) for inFC in inFClist ) Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to read serial stream of data [newbie]
In article e84f3af4-da6d-4ae9-8974-54354ec16...@b18g2000vbz.googlegroups.com, Jean Dupont jeandupont...@gmail.com wrote: I'd like to read in a stream of data which looks like this: the device sends out a byte-string of 11 bytes roughly every second: B0B0B0B0B03131B0B50D8A B0B0B0B0B03131B0B50D8A B0B0B031B63131B0310D8A B0B034B3323432B3310D8A B0B03237B53432B3310D8A . . . As you see every string is ended by 0D8A How can this be accomplished in Python? The basic idea would be to open your datastream in binary mode (http://docs.python.org/library/functions.html#open), then use read(11) to read exactly 11 bytes into a string. Depending on what the 11 bytes are, you might want to use the struct module (http://docs.python.org/library/struct.html) to extract the data in a more useful form. -- http://mail.python.org/mailman/listinfo/python-list
Re: building a dictionary dynamically
On 2/6/2012 11:10 AM, noydb wrote: Adding to dictionaries just isn't obvious... if it's not dict.Add or dict.Appaned or the like, not obvious to inexperienced me! Have you read section 4.8-mapping types, of the library manual? Or help(dict) at the interactive prompt? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
[issue13948] rm needless use of set function
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: I assume that the set() function was used to get rid of duplicates from self.versions, but there aren't any and the test would pass even if there were. -- assignee: tarek components: Distutils2 files: rm-needless-use-of-set-function.patch keywords: patch messages: 152725 nosy: alexis, eric.araujo, tarek, tshepang priority: normal severity: normal status: open title: rm needless use of set function type: behavior Added file: http://bugs.python.org/file24430/rm-needless-use-of-set-function.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13948 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13949] rm needless use of pass statement
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: I found the use of the pass statement redundant. -- assignee: tarek components: Distutils2 files: rm-needless-use-of-pass-keyword.patch keywords: patch messages: 152726 nosy: alexis, eric.araujo, tarek, tshepang priority: normal severity: normal status: open title: rm needless use of pass statement type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file24431/rm-needless-use-of-pass-keyword.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13949 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13950] rm commented-out code
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: It does not appear that the commented-out code adds any value. If anything, it's maybe just a distraction. -- assignee: tarek components: Distutils2 files: rm-commented-out-code.patch keywords: patch messages: 152727 nosy: alexis, eric.araujo, tarek, tshepang priority: normal severity: normal status: open title: rm commented-out code versions: Python 3.3 Added file: http://bugs.python.org/file24432/rm-commented-out-code.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13950 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13889] str(float) and round(float) issues with FPU precision
Stefan Krah stefan-use...@bytereef.org added the comment: I can run the tests on win64, but it I think it would be nice to have a patch with exactly the same logic as the gcc-asm version (Mark already mentioned _MCW_PC | _MCW_RC). Another thing: _WIN32 might be defined on MinGW, but I'm not sure. If that's the case, it would be nice to guard the VS specific passage with _MSC_VER. -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13889 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4709] Mingw-w64 and python on windows x64
Ralf Schmitt python-b...@systemexit.de added the comment: Marting, this issue is about building python extensions with mingw-w64 not about building python itself. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4709 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
STINNER Victor victor.stin...@haypocalc.com added the comment: In a security fix release, we shouldn't change the linkage procedures, so I recommend that the LoadLibrary dance remains. So the overhead in startup time is not an issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: In a security fix release, we shouldn't change the linkage procedures, so I recommend that the LoadLibrary dance remains. So the overhead in startup time is not an issue? It is an issue. Not only in terms of startup time, but also because randomization per default makes Python behave in non-deterministc ways - which is not what you want from a programming language or interpreter (unless you explicitly tell it to behave like that). I think it would be much better to just let the user define a hash seed using environment variables for Python to use and then forget about how this variable value is determined. If it's not set, Python uses 0 as seed, thereby disabling the seeding logic. This approach would have Python behave in a deterministic way per default and still allow users who wish to use a different seed, set this to a different value - even on a case by case basis. If you absolutely want to add a feature to have the seed set randomly, you could make a seed value of -1 trigger the use of a random number source as seed. I also still firmly believe that the collision counting scheme should be made available via an environment variable as well. The user could then set the variable to e.g. 1000 to have it enabled with limit 1000, or leave it undefined to disable the collision counting. With those two tools, users could then choose the method they find most attractive for their purposes. By default, they would be disabled, but applications which are exposed to untrusted user data and use dictionaries for managing such data could check whether the protections are enabled and trigger a startup error if needed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13590] exension module builds fail with python.org OS X installers on OS X 10.7 and 10.6 with Xcode 4.2
Changes by Ned Deily n...@acm.org: -- assignee: ronaldoussoren - ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13590 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Antoine Pitrou pit...@free.fr added the comment: It is an issue. Not only in terms of startup time, but also because randomization per default makes Python behave in non-deterministc ways - which is not what you want from a programming language or interpreter (unless you explicitly tell it to behave like that). That's debatable. For example id() is fairly unpredictable accross runs (except for statically-allocated instances). I think it would be much better to just let the user define a hash seed using environment variables for Python to use and then forget about how this variable value is determined. If it's not set, Python uses 0 as seed, thereby disabling the seeding logic. This approach would have Python behave in a deterministic way per default and still allow users who wish to use a different seed, set this to a different value - even on a case by case basis. If you absolutely want to add a feature to have the seed set randomly, you could make a seed value of -1 trigger the use of a random number source as seed. Having both may indeed be a good idea. I also still firmly believe that the collision counting scheme should be made available via an environment variable as well. The user could then set the variable to e.g. 1000 to have it enabled with limit 1000, or leave it undefined to disable the collision counting. With those two tools, users could then choose the method they find most attractive for their purposes. It's not about being attractive, it's about fixing the security problem. The simple collision counting approach leaves a gaping hole open, as demonstrated by Frank. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13931] os.path.exists inconsistent between 32 bit and 64 bit
zxw eeyore@gmail.com added the comment: I've posted the code to http://code.activestate.com/recipes/578035-disable-file-system-redirector/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13931 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Marc-Andre Lemburg m...@egenix.com added the comment: Antoine Pitrou wrote: The simple collision counting approach leaves a gaping hole open, as demonstrated by Frank. Could you elaborate on this ? Note that I've updated the collision counting patch to cover both possible attack cases I mentioned in http://bugs.python.org/issue13703#msg150724. If there's another case I'm unaware of, please let me know. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13951] Seg Fault in .so called by ctypes causes the interpreter to Seg Fault
New submission from Graeme Glass graemegl...@gmail.com: When doing something obviously incorrect (read, wrong/stupid) while calling libX11.so.6 via ctypes, it causes a Segmentation fault, which in turn cause the python interpreter to fall over with a Segmentation fault. My question is, is this the correct behaviour? Should it seg fault or just throw an exception? Details below. graeme@roger:~$ uname -a Linux roger 3.0.0-15-generic-pae #26-Ubuntu SMP Fri Jan 20 17:07:31 UTC 2012 i686 i686 i386 GNU/Linux graeme@roger:~$ python Python 2.7.2+ (default, Oct 4 2011, 20:03:08) [GCC 4.6.1] on linux2 graeme@roger:~$ python2.6 Python 2.6.7 (r267:88850, Aug 11 2011, 12:16:10) [GCC 4.6.1] on linux2 ## The example code graeme@roger:~$ cat xtest.py from ctypes import cdll dll = cdll.LoadLibrary('libX11.so.6') d = dll.XOpenDisplay(None) root = dll.XDefaultRootWindow(d) dll.XWarpPointer(d,None,root,0,0,0,0,20,39) dll.XCloseDisplay(d) dll.XCloseDisplay(d) #2nd call, should not be called, is not needed. Causes seg fault. ##The results graeme@roger:~$ pdb2.7 xtest.py /home/graeme/xtest.py(1)module() - from ctypes import cdll (Pdb) c Segmentation fault graeme@roger:~$ python2.7 xtest.py Segmentation fault graeme@roger:~$ ipython-2.7 xtest.py Segmentation fault graeme@roger:~$ ipython-2.6 xtest.py Segmentation fault graeme@roger:~$ gdb python2.7 (gdb) set args xtest.py (gdb) run Starting program: /usr/bin/python xtest.py [Thread debugging using libthread_db enabled] Program received signal SIGSEGV, Segmentation fault. __GI___libc_free (mem=0x151) at malloc.c:3709 3709malloc.c: No such file or directory. in malloc.c graeme@roger:~$ python2.6 xtest.py *** glibc detected *** python2.6: double free or corruption (!prev): 0x083533a0 *** === Backtrace: = /lib/i386-linux-gnu/libc.so.6(+0x6ebc2)[0xb7402bc2] /lib/i386-linux-gnu/libc.so.6(+0x6f862)[0xb7403862] /lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0xb740694d] /usr/lib/i386-linux-gnu/libX11.so.6(+0x9232b)[0xb6ff732b] /usr/lib/i386-linux-gnu/libX11.so.6(_XFreeDisplayStructure+0x16f)[0xb6f8bddf] /usr/lib/i386-linux-gnu/libX11.so.6(XCloseDisplay+0xd9)[0xb6f78179] /usr/lib/python2.6/lib-dynload/_ctypes.so(ffi_call_SYSV+0x1a)[0xb70c548a] /usr/lib/python2.6/lib-dynload/_ctypes.so(ffi_call+0x6f)[0xb70c51bf] /usr/lib/python2.6/lib-dynload/_ctypes.so(_CallProc+0x2c2)[0xb70bfd12] /usr/lib/python2.6/lib-dynload/_ctypes.so(+0x61ed)[0xb70b71ed] python2.6(PyObject_Call+0x4d)[0x80648cd] python2.6(PyEval_EvalFrameEx+0x3984)[0x80d6514] python2.6(PyEval_EvalCodeEx+0x882)[0x80d96e2] python2.6(PyEval_EvalCode+0x57)[0x80d97e7] python2.6(PyRun_FileExFlags+0xa6)[0x80f8b26] python2.6(PyRun_SimpleFileExFlags+0xc6)[0x80f98b6] python2.6(Py_Main+0xa49)[0x805be59] python2.6(main+0x1b)[0x805affb] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb73ad113] python2.6[0x805b021] === Memory map: 08048000-08255000 r-xp 08:06 4459238/usr/bin/python2.6 08255000-08256000 r--p 0020c000 08:06 4459238/usr/bin/python2.6 08256000-082a5000 rw-p 0020d000 08:06 4459238/usr/bin/python2.6 082a5000-082ae000 rw-p 00:00 0 082d2000-08374000 rw-p 00:00 0 [heap] b6e0-b6e21000 rw-p 00:00 0 b6e21000-b6f0 ---p 00:00 0 b6f28000-b6f44000 r-xp 08:06 2097174 /lib/i386-linux-gnu/libgcc_s.so.1 b6f44000-b6f45000 r--p 0001b000 08:06 2097174 /lib/i386-linux-gnu/libgcc_s.so.1 b6f45000-b6f46000 rw-p 0001c000 08:06 2097174 /lib/i386-linux-gnu/libgcc_s.so.1 b6f46000-b6f63000 r-xp 08:06 4458588 /usr/lib/i386-linux-gnu/libxcb.so.1.1.0 b6f63000-b6f64000 r--p 0001c000 08:06 4458588 /usr/lib/i386-linux-gnu/libxcb.so.1.1.0 b6f64000-b6f65000 rw-p 0001d000 08:06 4458588 /usr/lib/i386-linux-gnu/libxcb.so.1.1.0 b6f65000-b7096000 r-xp 08:06 4458582 /usr/lib/i386-linux-gnu/libX11.so.6.3.0 b7096000-b7097000 ---p 00131000 08:06 4458582 /usr/lib/i386-linux-gnu/libX11.so.6.3.0 b7097000-b7098000 r--p 00131000 08:06 4458582 /usr/lib/i386-linux-gnu/libX11.so.6.3.0 b7098000-b709a000 rw-p 00132000 08:06 4458582 /usr/lib/i386-linux-gnu/libX11.so.6.3.0 b709a000-b709b000 rw-p 00:00 0 b70b1000-b70c8000 r-xp 08:06 3634 /usr/lib/python2.6/lib-dynload/_ctypes.so b70c8000-b70cb000 r--p 00017000 08:06 3634 /usr/lib/python2.6/lib-dynload/_ctypes.so b70cb000-b70ce000 rw-p 0001a000 08:06 3634 /usr/lib/python2.6/lib-dynload/_ctypes.so b70ce000-b710f000 rw-p 00:00 0 b711-b7111000 r--p 00299000 08:06 4464349/usr/lib/locale/locale-archive b7111000-b7311000 r--p 08:06 4464349/usr/lib/locale/locale-archive b7311000-b7394000 rw-p 00:00 0 b7394000-b750a000 r-xp 08:06 2097561 /lib/i386-linux-gnu/libc-2.13.so b750a000-b750c000 r--p 00176000 08:06 2097561 /lib/i386-linux-gnu/libc-2.13.so b750c000-b750d000 rw-p 00178000 08:06 2097561 /lib/i386-linux-gnu/libc-2.13.so
[issue13590] extension module builds fail with python.org OS X installers on OS X 10.7 and 10.6 with Xcode 4.2
Changes by Éric Araujo mer...@netwok.org: -- title: exension module builds fail with python.org OS X installers on OS X 10.7 and 10.6 with Xcode 4.2 - extension module builds fail with python.org OS X installers on OS X 10.7 and 10.6 with Xcode 4.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13590 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13950] rm commented-out code
Éric Araujo mer...@netwok.org added the comment: Before Tarek started the distutils2 project, the version code lived standalone and its README file served as doctest. Most of its text was moved to PEP 386 and the tests themselves to test_verlib (and now test_version): https://bitbucket.org/tarek/distutilsversion/changeset/140170ef3896#chg-README.txt So you’re right, the lines that your patch removes are indeed unneeded, but I’d just like to check that all tests were moved into test_version before applying it. -- assignee: tarek - eric.araujo versions: +3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13950 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13949] rm needless use of pass statement
Éric Araujo mer...@netwok.org added the comment: Sure, I’ll apply this. -- assignee: tarek - eric.araujo versions: +3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13949 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13948] rm needless use of set function
Éric Araujo mer...@netwok.org added the comment: Yes, this test method could be a little clearer. I’ll do this. -- assignee: tarek - eric.araujo versions: +3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13948 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13951] Seg Fault in .so called by ctypes causes the interpreter to Seg Fault
Ramchandra Apte maniandra...@gmail.com added the comment: It is the correct behaviour for an invalid usage to segfault and is also mentioned in the documentation. Can somebody close this bug as invalid? -- nosy: +ramchandra.apte ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13951 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Jim Jewett jimjjew...@gmail.com added the comment: On Mon, Feb 6, 2012 at 8:12 AM, Marc-Andre Lemburg rep...@bugs.python.org wrote: Marc-Andre Lemburg m...@egenix.com added the comment: Antoine Pitrou wrote: The simple collision counting approach leaves a gaping hole open, as demonstrated by Frank. Could you elaborate on this ? Note that I've updated the collision counting patch to cover both possible attack cases I mentioned in http://bugs.python.org/issue13703#msg150724. If there's another case I'm unaware of, please let me know. The problematic case is, roughly, (1) Find out what N will trigger collision-counting countermeasures. (2) Insert N-1 colliding entries, to make it as slow as possible. (3) Keep looking up (or updating) the N-1th entry, so that the slow-as-possible-without-countermeasures path keeps getting rerun. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13938] 2to3 fails to convert types.StringTypes appropriately
Changes by Éric Araujo mer...@netwok.org: -- assignee: - benjamin.peterson nosy: +benjamin.peterson versions: +Python 2.7 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13938 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1040439] Missing documentation on how to link with libpython
Éric Araujo mer...@netwok.org added the comment: Is there still work to do on this issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1040439 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13951] please close - Seg Fault in .so called by ctypes causes the interpreter to Seg Fault
Changes by Ramchandra Apte maniandra...@gmail.com: -- title: Seg Fault in .so called by ctypes causes the interpreter to Seg Fault - please close - Seg Fault in .so called by ctypes causes the interpreter to Seg Fault ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13951 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1040439] Missing documentation on how to link with libpython
Antoine Pitrou pit...@free.fr added the comment: Is there still work to do on this issue? Not for Unix, no. I don't if it's applicable to Windows. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1040439 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4709] Mingw-w64 and python on windows x64
John Pye j...@curioussymbols.com added the comment: Martin, Ralf is right and my as previously linked is about building a python extension. I should have been more explicit about that. FWIW I found that the configure scripts on MinGW-w64 generally work fine if you add a --build=x86_64-w64-mingw32 argument on the ./configure command line. Then you should only add /mingw/bin to your path (and edit /etc/fstab to map c:/mingw64 to /mingw). Adding those subdirectories to the PATH doesn't seem to be successful; I suspect that those binaries are off the standard path for some reason, eg internal use by GCC only, or something (GCC seems to do some clever tricks with relative paths, so I'm sure it's important that you use the correct starting executable). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4709 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13951] Seg Fault in .so called by ctypes causes the interpreter to Seg Fault
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: [Please do not change issue titles - your recommendation was enough] Indeed, incorrect usage of ctypes can crash the program, and there is nothing Python can do. But I could not find any warning about this in the documentation, except maybe this sentence: There are, however, enough ways to crash Python with ctypes, so you should be careful anyway. Let's turn this into a doc issue, then. -- assignee: - docs@python components: +Documentation nosy: +amaury.forgeotdarc, docs@python title: please close - Seg Fault in .so called by ctypes causes the interpreter to Seg Fault - Seg Fault in .so called by ctypes causes the interpreter to Seg Fault ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13951 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13903] New shared-keys dictionary implementation
Changes by Mark Shannon m...@hotpy.org: -- hgrepos: -109 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13903 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11805] package_data only allows one glob per-package
Éric Araujo mer...@netwok.org added the comment: (I forgot that distutils2’s setup.py has its own fork of the conversion functions, for bootstrapping reasons, so I need to port the fix there.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11805 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5302] Allow package_data specs/globs to match directories
Éric Araujo mer...@netwok.org added the comment: One implementation by George Sakkis is found in this thread: http://bugs.python.org/issue2279#msg82213 There are subtle issues with this feature. For example, a glob pattern could match both package data files and Python submodules, leading to the same .py files being included as modules and data. I’ll see how far I want to specify the behavior in tests and docs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5302 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Marc-Andre Lemburg m...@egenix.com added the comment: Jim Jewett wrote: Jim Jewett jimjjew...@gmail.com added the comment: On Mon, Feb 6, 2012 at 8:12 AM, Marc-Andre Lemburg rep...@bugs.python.org wrote: Marc-Andre Lemburg m...@egenix.com added the comment: Antoine Pitrou wrote: The simple collision counting approach leaves a gaping hole open, as demonstrated by Frank. Could you elaborate on this ? Note that I've updated the collision counting patch to cover both possible attack cases I mentioned in http://bugs.python.org/issue13703#msg150724. If there's another case I'm unaware of, please let me know. The problematic case is, roughly, (1) Find out what N will trigger collision-counting countermeasures. (2) Insert N-1 colliding entries, to make it as slow as possible. (3) Keep looking up (or updating) the N-1th entry, so that the slow-as-possible-without-countermeasures path keeps getting rerun. Since N is constant, I don't see how such an attack could be used to trigger the O(n^2) worst-case behavior. Even if you can create n sets of entries that each fill up N-1 positions, the overall performance will still be O(n*N*(N-1)/2) = O(n). So in the end, we're talking about a regular brute force DoS attack, which requires different measures than dictionary implementation tricks :-) BTW: If you set the limit N to e.g. 100 (which is reasonable given Victor's and my tests), the time it takes to process one of those sets only takes 0.3 ms on my machine. That's hardly usable as basis for an effective DoS attack. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5411] add xz compression support to shutil
Éric Araujo mer...@netwok.org added the comment: This not-so-bad patch adds lzma compression support to the shutil functions, under the 'xztar' name. Please review. -- Added file: http://bugs.python.org/file24433/shutil-xz.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5411 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5411] add xz compression support to shutil
Éric Araujo mer...@netwok.org added the comment: I should add that a doc update will be part of the next patch. In parallel, I’ve also started updating packaging to add lzma support to the bdist command, but the situation is very disappointing: tarfile knows what format it supports, shutil has its own list, and packaging has a few duplicates too! Ideally, tarfile should have an attribute to expose what compression formats are available, then shutil would reuse that, and packaging would just call shutil. (I’m not even talking about the duplication in the doc.) If you agree with the general idea, I’ll open reports to a) add the attribute to tarfile b) rework the (luckily internal) registries in shutil to stop being hard-coded c) remove packaging’s registries. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5411 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12703] Improve error reporting for packaging.util.resolve_name
Éric Araujo mer...@netwok.org added the comment: In the absence of feedback, I’m going to apply my find_object idea as described in my previous message. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13952] mimetypes doesn't recognize .csv
New submission from Ian Davis iwd32...@yahoo.com: The mimetypes module does not respond with text/csv for files that end in .csv, and I think it should :) For goodness sake, text/tab-delimited-values is in there as .tsv, and that seems much less used (to me). -- components: Library (Lib) messages: 152751 nosy: iwd32900 priority: normal severity: normal status: open title: mimetypes doesn't recognize .csv type: behavior versions: Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13952] mimetypes doesn't recognize .csv
R. David Murray rdmur...@bitdance.com added the comment: Yes, but text/tab-delimited-values/.tsv is older. .tsv dates from the days of Gopher, but text/csv was formalized only in October of 2005. Presumably nobody has asked for it before, for some odd reason. Now we get to debate again whether updating mimetypes with a registered type can be considered a bug fix. We've gone both ways in the past, as far as I can tell. This one has the advantage of actually having a formal IANA registration, unlike the last couple. -- nosy: +r.david.murray stage: - needs patch versions: +Python 3.2, Python 3.3 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8255] Packaging step-by-step tutorial
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8255 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Jim Jewett jimjjew...@gmail.com added the comment: On Mon, Feb 6, 2012 at 12:07 PM, Marc-Andre Lemburg rep...@bugs.python.org wrote: Marc-Andre Lemburg m...@egenix.com added the comment: Jim Jewett wrote: The problematic case is, roughly, (1) Find out what N will trigger collision-counting countermeasures. (2) Insert N-1 colliding entries, to make it as slow as possible. (3) Keep looking up (or updating) the N-1th entry, so that the slow-as-possible-without-countermeasures path keeps getting rerun. Since N is constant, I don't see how such an attack could be used to trigger the O(n^2) worst-case behavior. Agreed; it tops out with a constant, but if it takes only 16 bytes of input to force another run through a 1000-long collision, that may still be too much leverage. BTW: If you set the limit N to e.g. 100 (which is reasonable given Victor's and my tests), Agreed. Frankly, I think 5 would be more than reasonable so long as there is a fallback. the time it takes to process one of those sets only takes 0.3 ms on my machine. That's hardly usable as basis for an effective DoS attack. So it would take around 3Mb to cause a minute's delay... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Frank Sievertsen pyt...@sievertsen.de added the comment: Agreed; it tops out with a constant, but if it takes only 16 bytes of input to force another run through a 1000-long collision, that may still be too much leverage. You should prepare the dict so that you have the collisions-run with a one-byte string or better with an even empty string, not a 16 bytes string. BTW: If you set the limit N to e.g. 100 (which is reasonable given Victor's and my tests), 100 is probably hard to exploit for a DoS attack. However it makes it much easier to cause unwanted (future?) exceptions in other apps. So it would take around 3Mb to cause a minute's delay... How did you calculate that? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Marc-Andre Lemburg m...@egenix.com added the comment: Jim Jewett wrote: BTW: If you set the limit N to e.g. 100 (which is reasonable given Victor's and my tests), Agreed. Frankly, I think 5 would be more than reasonable so long as there is a fallback. the time it takes to process one of those sets only takes 0.3 ms on my machine. That's hardly usable as basis for an effective DoS attack. So it would take around 3Mb to cause a minute's delay... I'm not sure how you calculated that number. Here's what I get: tale a dictionary with 100 integer collisions: d = dict((x*(2**64 - 1), 1) for x in xrange(1, 100)) The repr(d) has 2713 bytes, which is a good approximation of how much (string) data you have to send in order to trigger the problem case. If you can create distinct integer sequences, you'll get a processing time of about 1 second on my slow dev machine. The resulting dict will likely have a repr() of around 60**2713 = 517MB. So you need to send 517MB to cause my slow dev machine to consume 1 minute of CPU time. Today's servers are at least 10 times as fast as my aging machine. If you then take into account that the integer collision dictionary is a very efficient collision example (size vs. effect), the attack doesn't really sound practical anymore. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13953] test_packaging: unused test?
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: I'm not sure what's happening here (not sure how doctest works), but I suspect that there is no test at all. Perhaps it was forgotten: http://hg.python.org/cpython/file/567767a6df02/Lib/packaging/tests/test_version.py#l68. I say this because it whatever change I make to that long string, I always get a successful test. -- assignee: tarek components: Distutils2 messages: 152756 nosy: alexis, eric.araujo, tarek, tshepang priority: normal severity: normal status: open title: test_packaging: unused test? versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13953 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13952] mimetypes doesn't recognize .csv
Antoine Pitrou pit...@free.fr added the comment: I would argue the embedded mime-types dictionary should at least mirror current IANA assignments, which are already present in up-to-date Unix systems: mimetypes.guess_type(foo.csv) ('text/csv', None) So not having text/csv is IMHO a bug. Also it would be nice if there were an easy way to keep the mime-types dictionary up-to-date wrt. a system's mime-types file. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13952] mimetypes doesn't recognize .csv
R. David Murray rdmur...@bitdance.com added the comment: As far as I know having it mirror the IANA registry is the intent (there's a comment in the module that can be read as implying that). So I'd be inclined to treat this one as a bug and fix it in 2.7 and 3.2 as well as 3.3. I'm not sure what you mean by your final comment, since by default the system mime types are read on both Unix and Windows and merged with the built in table. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Dave Malcolm dmalc...@redhat.com added the comment: On Mon, 2012-02-06 at 10:20 +, Marc-Andre Lemburg wrote: Marc-Andre Lemburg m...@egenix.com added the comment: STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: In a security fix release, we shouldn't change the linkage procedures, so I recommend that the LoadLibrary dance remains. So the overhead in startup time is not an issue? It is an issue. Not only in terms of startup time, but also msg152362 indicated that there was negligible impact on startup time when randomization is disabled. The impact when it *is* enabled is unclear, but reported there as isn't crippling. because randomization per default makes Python behave in non-deterministc ways - which is not what you want from a programming language or interpreter (unless you explicitly tell it to behave like that). The release managers have pronounced: http://mail.python.org/pipermail/python-dev/2012-January/115892.html Quoting that email: 1. Simple hash randomization is the way to go. We think this has the best chance of actually fixing the problem while being fairly straightforward such that we're comfortable putting it in a stable release. 2. It will be off by default in stable releases and enabled by an envar at runtime. This will prevent code breakage from dictionary order changing as well as people depending on the hash stability. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13952] mimetypes doesn't recognize .csv
Antoine Pitrou pit...@free.fr added the comment: I'm not sure what you mean by your final comment, since by default the system mime types are read on both Unix and Windows and merged with the built in table. I mean to have our built-in table mirror a recent Unix system's mime-types table. There could be a special switch to mimetypes.py, which would output the Python code of a dict mirroring /etc/mime.types (or /etc/mime.types + the current built-in table) when run. Then it would be easy to integrate the changes back into the code. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13952] mimetypes doesn't recognize .csv
R. David Murray rdmur...@bitdance.com added the comment: Ah, analagous to the way keyword.py regenerates its embedded table based on the actual python grammar? Yes, that would be nice. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13952 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Jim Jewett jimjjew...@gmail.com added the comment: On Mon, Feb 6, 2012 at 1:53 PM, Frank Sievertsen rep...@bugs.python.org wrote: BTW: If you set the limit N to e.g. 100 (which is reasonable given Victor's and my tests), So it would take around 3Mb to cause a minute's delay... How did you calculate that? 16 bytes/entry * 3300 entries/second * 60 seconds/minute But if there is indeed a way to cut that 16 bytes/entry, that is worse. Switching dict implementations at 5 collisions is still acceptable, except from a complexity standpoint. -jJ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Marc-Andre Lemburg m...@egenix.com added the comment: Dave Malcolm wrote: So the overhead in startup time is not an issue? It is an issue. Not only in terms of startup time, but also ... because randomization per default makes Python behave in non-deterministc ways - which is not what you want from a programming language or interpreter (unless you explicitly tell it to behave like that). The release managers have pronounced: http://mail.python.org/pipermail/python-dev/2012-January/115892.html Quoting that email: 1. Simple hash randomization is the way to go. We think this has the best chance of actually fixing the problem while being fairly straightforward such that we're comfortable putting it in a stable release. 2. It will be off by default in stable releases and enabled by an envar at runtime. This will prevent code breakage from dictionary order changing as well as people depending on the hash stability. Right, but that doesn't contradict what I wrote about adding env vars to fix a seed and optionally enable using a random seed, or adding collision counting as extra protection for cases that are not addressed by the hash seeding, such as e.g. collisions caused by 3rd types or numbers. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10811] sqlite segfault with generators
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 631e99961c5f by Petri Lehtinen in branch '2.7': Issue #10811: Fix recursive usage of cursors. Instead of crashing, raise a ProgrammingError now. http://hg.python.org/cpython/rev/631e99961c5f New changeset d51ceef4b62f by Petri Lehtinen in branch '3.2': Issue #10811: Fix recursive usage of cursors. Instead of crashing, raise a ProgrammingError now. http://hg.python.org/cpython/rev/d51ceef4b62f -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10811] sqlite segfault with generators
Petri Lehtinen pe...@digip.org added the comment: It's now fixed in all branches. Thanks for reporting! -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13703] Hash collision security issue
Marc-Andre Lemburg m...@egenix.com added the comment: Marc-Andre Lemburg wrote: Dave Malcolm wrote: The release managers have pronounced: http://mail.python.org/pipermail/python-dev/2012-January/115892.html Quoting that email: 1. Simple hash randomization is the way to go. We think this has the best chance of actually fixing the problem while being fairly straightforward such that we're comfortable putting it in a stable release. 2. It will be off by default in stable releases and enabled by an envar at runtime. This will prevent code breakage from dictionary order changing as well as people depending on the hash stability. Right, but that doesn't contradict what I wrote about adding env vars to fix a seed and optionally enable using a random seed, or adding collision counting as extra protection for cases that are not addressed by the hash seeding, such as e.g. collisions caused by 3rd types or numbers. ... at least I hope not :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13703 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com