ANN: gcc-python-plugin 0.8
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 Detailed release notes can be seen at: http://gcc-python-plugin.readthedocs.org/en/latest/0.8.html Some highlights of the 0.8 release: * it's much easier than before to emit compilation warnings * initial support for analyzing C++ code from a Python script * gcc-with-cpychecker has gained additional tests. It now has knowledge of which CPython API calls will crash when passed NULL, and will warn you (with details) about code paths that can trigger such a call. It can also now detect certain subtle errors in PyMethodDef tables. * numerous bug fixes and other improvements 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. Thanks to Red Hat for funding their development, and to David Narvaez and Tom Tromey for their contributions to this release. Enjoy! Dave Malcolm -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: eGenix mx Base Distribution 3.2.2 (mxDateTime, mxTextTools, etc.)
ANNOUNCING eGenix.com mx Base Distribution Version 3.2.2 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.2-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.2 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: * mxDateTime seconds rounding is now more careful to not show 60.00 or 61.00 as second value. * mxDateTime will now correctly work with numeric arrays (numpy) again. Thanks to Christian Marquardt for reporting the problem. * mxDateTime's DateTimeFromAbsDateTime() now accepts leap second values (86400.0 - 86401.0) as well. Thanks to Christian Marquardt for reporting the problem. * Enhanced mx.Misc.ConfigFile. Please see the changelog for details (URL listed below). 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
MySQLdb Error
Hello All, I got the below error why trying to create tables of the fly. for item in ['CREATE TABLE AddressTables ( AddressTables_id int (9) unsigned primary key auto_increment not null, city_name char(40) , state_name varchar, street_number int, country_name varchar, street_name char(40) , user_name char(40) references usertables(name))', 'CREATE TABLE UserTables ( age int, UserTables_id int (9) unsigned primary key auto_increment not null, name char(40) , place_of_birth varchar)']: cursor.execute(item) I receive the following errors. File mor.py, line 98, in module cursor.execute(item) File /usr/lib/pymodules/python2.7/MySQLdb/cursors.py, line 166, in execute self.errorhandler(self, exc, value) File /usr/lib/pymodules/python2.7/MySQLdb/connections.py, line 35, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.ProgrammingError: (1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' street_number int, country_name varchar, street_name char(40) , user_name ch' at line 1) * Regards,* *Emeka * -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb Error
On Wed, Jan 11, 2012 at 6:57 PM, Emeka emekami...@gmail.com wrote: CREATE TABLE AddressTables ( AddressTables_id int (9) unsigned primary key auto_increment not null, city_name char(40) , state_name varchar, street_number int, country_name varchar, street_name char(40) , user_name char(40) references usertables(name)) _mysql_exceptions.ProgrammingError: (1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' street_number int, country_name varchar, street_name char(40) , user_name ch' at line 1) You're getting an error back from the database. The message suggests that you look around the place cited for some kind of syntactic error. See if you can find the error; often, in situations like this, the actual error is a little bit before what's pointed to. Have a look, I'll wait. Spoiler alert! Try figuring it out yourself before you scroll down. You've been warned! There are spoilers ahead. Okay. The problem is that MySQL requires varchar to be followed by a length: varchar(255) or varchar(32) or whatever. The use of naked 'varchar' is a PostgreSQL feature only. Hope that helps! Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: open office in another language?
Sean Wolfe, 10.01.2012 22:43: I'm a somewhat-satisfied openoffice.org user. I mean it works, but if it weren't in Java I'd be doing some of my own tweaking. But since it's in Java I stay away... no likey. It's been in C++ ever since the old StarOffice days, others have commented on that already. Java is only one way of extending it, and it's not even required by the installation. Has there been any talk of doing another similar office suite, or maybe just writer + spreadsheet, in a better language eg python? I expect it's a huge undertaking but ... thought I'd ask around at least. OOo has been fully scriptable in Python for ages. It even comes with an embedded Python runtime for that purpose (at least on non-package-management systems like Windows). So, Python is actually a standard component in all installations, whereas Java is not, and is therefore not necessarily available in a deployment. Basically, if you want your scripts to run in all OpenOffice/LibreOffice installations, you either have to write it in StarBasic, or use Python. The OOo extension API is called UNO, so look for the PyUNO bridge. Admittedly, it's somewhat badly documented, but it basically works the same way as the other UNO-API incarnations in other languages, so any UNO documentation will generally apply just fine. Also look for LibreOffice, as Ben Finney hinted. Since Oracle dropped Sun's OOo commitment, many regard it as the future of OOo. It's certainly the place where the development happens these days. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: UnicodeEncodeError in compile
On 11 jan, 01:56, Terry Reedy tjre...@udel.edu wrote: On 1/10/2012 8:43 AM, jmfauth wrote: D:\c:\python32\python.exe Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. '\u5de5'.encode('utf-8') b'\xe5\xb7\xa5' '\u5de5'.encode('mbcs') Traceback (most recent call last): File stdin, line 1, inmodule UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: inval id character D:\c:\python27\python.exe Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. u'\u5de5'.encode('utf-8') '\xe5\xb7\xa5' u'\u5de5'.encode('mbcs') '?' mbcs encodes according to the current codepage. Only the chinese codepage(s) can encode the chinese char. So the unicode error is correct and 2.7 has a bug in that it is doing errors='replace' when it supposedly is doing errors='strict'. The Py3 fix was done inhttp://bugs.python.org/issue850997 2.7 was intentionally left alone because of back-compatibility considerations. (None of this addresses the OP's question.) -- Ok. I was not aware of this. PS Prev. post gets lost. -- http://mail.python.org/mailman/listinfo/python-list
Re: UnicodeEncodeError in compile
On 11 jan, 01:56, Terry Reedy tjre...@udel.edu wrote: On 1/10/2012 8:43 AM, jmfauth wrote: ... mbcs encodes according to the current codepage. Only the chinese codepage(s) can encode the chinese char. So the unicode error is correct and 2.7 has a bug in that it is doing errors='replace' when it supposedly is doing errors='strict'. The Py3 fix was done inhttp://bugs.python.org/issue850997 2.7 was intentionally left alone because of back-compatibility considerations. (None of this addresses the OP's question.) -- win7, cp1252 Ok. I was not aware of this. '\N{CYRILLIC SMALL LETTER A}'.encode('mbcs') Traceback (most recent call last): File eta last command, line 1, in module UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character '\N{GREEK SMALL LETTER ALPHA}'.encode('mbcs') Traceback (most recent call last): File eta last command, line 1, in module UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character jmf -- http://mail.python.org/mailman/listinfo/python-list
ANN: eGenix mx Base Distribution 3.2.2 (mxDateTime, mxTextTools, etc.)
ANNOUNCING eGenix.com mx Base Distribution Version 3.2.2 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.2-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.2 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: * mxDateTime seconds rounding is now more careful to not show 60.00 or 61.00 as second value. * mxDateTime will now correctly work with numeric arrays (numpy) again. Thanks to Christian Marquardt for reporting the problem. * mxDateTime's DateTimeFromAbsDateTime() now accepts leap second values (86400.0 - 86401.0) as well. Thanks to Christian Marquardt for reporting the problem. * Enhanced mx.Misc.ConfigFile. Please see the changelog for details (URL listed below). 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
Re: open office in another language?
Stefan Behnel stefan...@behnel.de writes: OOo has been fully scriptable in Python for ages. It even comes with an embedded Python runtime for that purpose (at least on non-package-management systems like Windows). So, Python is actually a standard component in all installations, whereas Java is not, and is therefore not necessarily available in a deployment. Basically, if you want your scripts to run in all OpenOffice/LibreOffice installations, you either have to write it in StarBasic, or use Python. The OOo extension API is called UNO, so look for the PyUNO bridge. Admittedly, it's somewhat badly documented, but it basically works the same way as the other UNO-API incarnations in other languages, so any UNO documentation will generally apply just fine. Also look for LibreOffice, as Ben Finney hinted. Since Oracle dropped Sun's OOo commitment, many regard it as the future of OOo. It's certainly the place where the development happens these days. I have dabbled with PyUNO in the past. One issue is that the api seems rather unpythonic (to me, at least). -- http://mail.python.org/mailman/listinfo/python-list
ERROR:root:code for hash md5 was not found
Hi, We are running are running Python program on Redhat 5.5. When executing our program we get the following error ( see below). Any ideas what this is due to? br, //mike /pysibelius/lib/common/ DataTypes.py Overwriten ... ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File /python/lib/python2.7/hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /python/lib/python2.7/hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found -- http://mail.python.org/mailman/listinfo/python-list
Re: UnicodeEncodeError in compile
On Wednesday, January 11, 2012 5:50:51 AM UTC+2, Terry Reedy wrote: On 1/10/2012 3:08 AM, Terry Reedy wrote: Is this a filename that could be an actual, valid filename on your system? Yes it is. open works on that file. Good question. I believe this holdover from 2.x should be deleted. I argued that in http://bugs.python.org/issue10114 (which was about a different problem) and now, directly, in http://bugs.python.org/issue13758 Maybe the example of this question can be added to the issue 13785 as a proof that compile fails on valid file names. But I think the real issue is why on modern Windows systems the file system encoding is mbcs. Shouldn't it be utf-16? -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
Le 11/01/2012 12:19, mike a écrit : Hi, We are running are running Python program on Redhat 5.5. When executing our program we get the following error ( see below). Any ideas what this is due to? On my computer hashlib has md5 : Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type help, copyright, credits or license for more information. import hashlib h=hashlib.new(md5) h.update(Hello) h.hexdigest() 'd992641f1b2b9c08b569c0a17c4e7cb8' While if I ask for a hash method that hashlib does not know, I get the same error as you : g=hashlib.new(bla) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.6/hashlib.py, line 101, in __hash_new return __get_builtin_constructor(name)(string) File /usr/lib/python2.6/hashlib.py, line 80, in __get_builtin_constructor raise ValueError, unsupported hash type ValueError: unsupported hash type You should give us a more comprehensive example of your problem. Laurent -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: Looking for code review on my first Python project.
On Tue, 10 Jan 2012 18:17:48 -0700, Ian Kelly wrote: On Tue, Jan 10, 2012 at 4:44 PM, HoneyMonster someone@someplace.invalid wrote: Hi, I'm new to Python and recently completed my first project. I used wxPython with wxGlade to generate the GUI bits.The application seems to work well, but I am entirely self-taught, so have undoubtedly committed a number of howlers in terms of style, design, standards, best practice and so forth. snip constructive and helpful advice Very many thanks to Ian and to all who responded. I really appreciate the guidance. Cheers. WH -- http://mail.python.org/mailman/listinfo/python-list
Re: UnicodeEncodeError in compile
On 01/11/2012 06:27 AM, pyscrip...@gmail.com wrote: SNIP Maybe the example of this question can be added to the issue 13785 as a proof that compile fails on valid file names. But I think the real issue is why on modern Windows systems the file system encoding is mbcs. Shouldn't it be utf-16? Depends what you mean by modern. The following isn't true for Windows 95, 98, nor ME. But they weren't modern when they were first released. NT systems, (which includes Win2k, XP, Vista, and Win7) for at least the last 15 years, have used Unicode for the file system. They also supply an ASCII interface. If Python is using the latter, then it won't be able to access all possible files. Now, it may be the fault of the C library that CPython uses. I haven't looked at any of the code for CPython. This is all from memory, as I haven't actively used Windows for some time now. But I think the DLL name is kernel32.dll, and the entry points have names like CreateFileW() for the unicode open, and CreateFileA() for the ASCII open. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: UnicodeEncodeError in compile
Indeed, on Windows NT the file system encoding should not be mbcs, since it creates UnicodeEncodeErrors on perfectly valid file names. -- http://mail.python.org/mailman/listinfo/python-list
Re: open office in another language?
Paul Rudin, 11.01.2012 11:17: Stefan Behnel writes: OOo has been fully scriptable in Python for ages. It even comes with an embedded Python runtime for that purpose [...] I have dabbled with PyUNO in the past. One issue is that the api seems rather unpythonic (to me, at least). Sure, UNO wasn't designed for Python. It's mostly a 1:1 mapping of the C++ API. I didn't find anything in a quick web search, but I'm pretty sure the wrapper is auto-generated in some way. But still: it's there, it's usable and it's even object oriented. And I estimate that it's much easier to use from Python than from C++ (which I never tried). If you want something better, feel free to write a pythonic Cython wrapper of the C++ UNO API. May take a while, though, and you'll also have to rewrite the entire UNO documentation to match your new wrapper, so that people can actually start using it effectively. Stefan -- http://mail.python.org/mailman/listinfo/python-list
import problems.
I have an import problem I can't figure out. I am using python 2.6.6 on a debian box In one directory (pylib) I have a file misc.py and the file testutil.py. testutil.py -- print in, __name__ from misc import Rec calling this file in that directory gives me this: $ python testutil.py in __main__ In a neighbour directory I have the file ats atst import sys from os.path import join as pj, abspath print abspath(../pylib) sys.path.append(abspath(../pylib)) import testutil --- Now calling this file in its directory gives me the following problem: $ python atst /local/home/apardon/src/projecten/pylib in testutil Traceback (most recent call last): File atst, line 9, in module import testutil File /local/home/apardon/src/projecten/pylib/testutil.py, line 4, in module from misc import Rec ImportError: cannot import name Rec Why can I import Rec from misc in testutil when I call testutil.py directly but not when testutil was imported itself? -- http://mail.python.org/mailman/listinfo/python-list
Re: import problems.
On 01/11/2012 08:21 AM, Antoon Pardon wrote: I have an import problem I can't figure out. I am using python 2.6.6 on a debian box In one directory (pylib) I have a file misc.py and the file testutil.py. testutil.py -- print in, __name__ from misc import Rec calling this file in that directory gives me this: $ python testutil.py in __main__ In a neighbour directory I have the file ats atst import sys from os.path import join as pj, abspath print abspath(../pylib) sys.path.append(abspath(../pylib)) import testutil --- Now calling this file in its directory gives me the following problem: $ python atst /local/home/apardon/src/projecten/pylib in testutil Traceback (most recent call last): File atst, line 9, in module import testutil File /local/home/apardon/src/projecten/pylib/testutil.py, line 4, in module from misc import Rec ImportError: cannot import name Rec Why can I import Rec from misc in testutil when I call testutil.py directly but not when testutil was imported itself? In your first case, Rec.py was in the current directory, which is one of the specs in classpath. In the second case, your current directory was somewhere else. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
How do I tell incomplete input from invalid input?
Hi, I have been trying to figure out a reliable way to determine incomplete Python script input using Python C API. (Apology if it is OT here, I'm not sure where my post belongs, perhaps to cplusplus-sig list.) Apparently, most pointers lead to the Python FAQ [1] question: How do I tell incomplete input from invalid input? Unfortunately, this FAQ is either old or incomplete thus incorrect. First, the proposed testcomplete() function uses internal symbols which are not available to Python C API users. So, whoever wrote that FAQ should be given 20 lashes with a short piece of string [2]. The second solution is incomplete or incorrect. It does not handle correctly multi-line input longer than two lines with more flow control statements. For example: ## n = 10 if n 0: ...if n 100: File stdin, line 2 if n 100: ^ IndentationError: expected an indented block ## or ## for n in range(0, 5): ... if n 2: File stdin, line 2 if n 2: ^ IndentationError: expected an indented block ## I have attached a slightly modified C++ version of the second program from the FAQ question [1], file faq_incomplete_input.cpp which is also available from my GitHub repo [3] In this program, I added several FIX comments with proposed corrections. The idea is to additionally check for PyErr_ExceptionMatches (PyExc_IndentationError) and strcmp (msg, expected an indented block) and prompt is sys.ps2, means more code expected. And, ignore errors until user confirms the input is finished, so the whole input is eventually sent to the Py_CompileString and then all exceptions are not ignored, but considered as real result of compilation. I simply wanted to achieve similar semantic to codeop._maybe_compile() (called by codeop.compile_command) which performs some sort of dirty hack in the following line: if not code1 and repr(err1) == repr(err2): So, the test in action for multi-line multi-statement input gives: ## c = codeop.compile_command(for n in range(0, 3):, test, single) err1 SyntaxError('unexpected EOF while parsing', ('test', 1, 22, 'for n in range(0, 3):\n')) err2 IndentationError('expected an indented block', ('test', 2, 1, '\n')) comparison.err1 SyntaxError('unexpected EOF while parsing', ('test', 1, 22, 'for n in range(0, 3):\n')) comparison.err2 IndentationError('expected an indented block', ('test', 2, 1, '\n')) code None code1 None c = codeop.compile_command(for n in range(0, 3):\n\tif n 0:, test, single) err1 IndentationError('expected an indented block', ('test', 2, 11, '\tif n 0:\n')) err2 IndentationError('expected an indented block', ('test', 3, 1, '\n')) comparison.err1 IndentationError('expected an indented block', ('test', 2, 11, '\tif n 0:\n')) comparison.err2 IndentationError('expected an indented block', ('test', 3, 1, '\n')) code None code1 None ## So, I reckon it make sense to use the same logic to when calling Py_CompileString. Does it sound as reasonable solution? Basically, there seem to be no canonical solution anywhere presented on how to perform incomplete input tests in reliable manner, how to perform parsing/compilation in subsequent steps against Python code given line-by-line. The C API used by Python function compile() is not publicly available. There is PyRun_InteractiveLoop mechanism but it is tightly coupled to FILE-based I/O which is not always available when Python is embedded, so the loop is useless in number of situations. Have I overlooked any other obvious solution? Finally, it would be helpful if the Python FAQ is up to date. [1] http://docs.python.org/py3k/faq/extending.html#how-do-i-tell-incomplete-input-from-invalid-input [2] http://mail.python.org/pipermail/python-list/2004-August/887195.html [3] https://github.com/mloskot/workshop/blob/master/python/ Best regards, -- Mateusz Loskot, http://mateusz.loskot.net // // A quick and dirty C++ version of the C program presented in Python FAQ: // http://docs.python.org/py3k/faq/extending.html#how-do-i-tell-incomplete-input-from-invalid-input // Modifications: // - do not use readline library, but iostream // // Tested using Visual C++ 2010 (10.0) and Python 3.2 (custom Debug build) // // The incomplete input solution presented in the FAQ is incomplete and it does // not allow multi-line scripts with more than 2 lines of flow control statements: // // n = 10 // if n 0: //... if n 100: // File stdin, line 2 //if n 100: // ^ //IndentationError: expected an indented block // // // n = 10 // if n 0: //... if n
Re: import problems.
Antoon Pardon wrote: I have an import problem I can't figure out. I am using python 2.6.6 on a debian box In one directory (pylib) I have a file misc.py and the file testutil.py. from misc import Rec ImportError: cannot import name Rec Why can I import Rec from misc in testutil when I call testutil.py directly but not when testutil was imported itself? Without looking into the details, could it be that you have two misc.py files one with and one without Rec? -- http://mail.python.org/mailman/listinfo/python-list
Re: import problems.
On 01/11/2012 02:57 PM, Peter Otten wrote: Antoon Pardon wrote: I have an import problem I can't figure out. I am using python 2.6.6 on a debian box In one directory (pylib) I have a file misc.py and the file testutil.py. from misc import Rec ImportError: cannot import name Rec Why can I import Rec from misc in testutil when I call testutil.py directly but not when testutil was imported itself? Without looking into the details, could it be that you have two misc.py files one with and one without Rec Well that depends on what you mean with have. This is what turned up when I searched for misc.py $ find /usr/local/lib /usr/lib /local/home/apardon -name misc.py -print 2 /dev/null /usr/lib/python2.6/compiler/misc.py /usr/lib/pymodules/python2.6/PyQt4/uic/Compiler/misc.py /usr/lib/pymodules/python2.6/numpy/oldnumeric/misc.py /usr/lib/pymodules/python2.6/docutils/transforms/misc.py /usr/lib/pymodules/python2.6/docutils/parsers/rst/directives/misc.py /local/home/apardon/src/projecten/pylib/misc.py That last one is my file, the rest doesn't seem to be in sys.path so they shouldn't interfere as far as I understand. Changing the name of my file to miscutil.py resolves the problem though. I'll see if I can figure out more. -- http://mail.python.org/mailman/listinfo/python-list
Re: import problems.
On 01/11/2012 03:45 PM, Antoon Pardon wrote: On 01/11/2012 02:57 PM, Peter Otten wrote: Antoon Pardon wrote: I have an import problem I can't figure out. I am using python 2.6.6 on a debian box In one directory (pylib) I have a file misc.py and the file testutil.py. from misc import Rec ImportError: cannot import name Rec Why can I import Rec from misc in testutil when I call testutil.py directly but not when testutil was imported itself? Without looking into the details, could it be that you have two misc.py files one with and one without Rec Well that depends on what you mean with have. This is what turned up when I searched for misc.py $ find /usr/local/lib /usr/lib /local/home/apardon -name misc.py -print 2 /dev/null /usr/lib/python2.6/compiler/misc.py /usr/lib/pymodules/python2.6/PyQt4/uic/Compiler/misc.py /usr/lib/pymodules/python2.6/numpy/oldnumeric/misc.py /usr/lib/pymodules/python2.6/docutils/transforms/misc.py /usr/lib/pymodules/python2.6/docutils/parsers/rst/directives/misc.py /local/home/apardon/src/projecten/pylib/misc.py That last one is my file, the rest doesn't seem to be in sys.path so they shouldn't interfere as far as I understand. Changing the name of my file to miscutil.py resolves the problem though. I'll see if I can figure out more. It seems there is a directory /usr/lib/pymodules/python2.6/misc in which is an empty __init.py__ file. As far as I understand this makes misc a package on sys.path causing the problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: An alternative to Learning Perl
On Tue, Jan 10, 2012 at 8:25 PM, Sebastian Rooks sebastian_rooks@lavabit.c_o_m wrote: On Mon, 9 Jan 2012 00:55:22 -0300, Sean Wolfe ether@gmail.com wrote: kindle? ipad? tablet? I'm interested in books, not files ... (seriously, now ... I don't have any of those devices) also there is python programming for the absolute beginner, which is agreat book but it's pretty beginner. But well written. At least Iliked it.http://www.amazon.com/Python-Programming-Absolute-Beginner-3rd/dp/1435455002 Also byte of python ... I think there's a hardcover version you can buyhttp://www.swaroopch.com/buybook/ I think I saw that second one somewhere already. I'll check out the first link, also. Thanks! Yeah I hear you, I moved to Argentina from the US this year and my ipad + kindle app has been great. I can buy lots of books which I can't get down here and get access to them immediately, and I can carry a whole library in my backpack. So +1 if you are thinking about it. I like physical books as well but the portability factor is awesome. -- http://mail.python.org/mailman/listinfo/python-list
after application close MS Visual C++ runtime library error occurs
Hello, I am using psycopg2 in windows app, example: import psycopg2 import psycopg2.extras self.con = psycopg2.connect(dbname= host= user= password= port=); self.cur = self.con.cursor(cursor_factory=psycopg2.extras.DictCursor) SELECT = select something self.cur.execute(SELECT) for row in self.cur: ... self.cur.close() self.con.close() But when I click on exit button in application MS Visual C++ runtime library error occurs: This application has requested the runtime to terminate it in unusual way. What am I doing wrong? -- http://mail.python.org/mailman/listinfo/python-list
contextlib.contextmanager and try/finally
I'm trying to write a context manager to handle database connections, under the principle that I should not rely on CPython's reference-counting semantics to clean up scarce resources, like connections. I wrote: @contexlib.contextmanager def ensure_connection(con=None): con_created = False if con is None: con_created, con = True, make_connection() try: yield con finally: if con_created: con.close() However, then I read the following paragraph from PEP-343: Note that we're not guaranteeing that the finally-clause is executed immediately after the generator object becomes unused, even though this is how it will work in CPython. This is similar to auto-closing files: while a reference-counting implementation like CPython deallocates an object as soon as the last reference to it goes away, implementations that use other GC algorithms do not make the same guarantee. This applies to Jython, IronPython, and probably to Python running on Parrot. That suggests that I cannot rely on the contextlib.contextmanager decorator to ensure that the connection is closed and would have to write my own object with __enter__ and __exit__ methods to guarantee this. Is this understanding accurate? If so, could someone illustrate why this is so? Thanks, Johann -- http://mail.python.org/mailman/listinfo/python-list
Re: contextlib.contextmanager and try/finally
On 2012-01-11, joha...@gmail.com joha...@gmail.com wrote: That suggests that I cannot rely on the contextlib.contextmanager decorator to ensure that the connection is closed and would have to write my own object with __enter__ and __exit__ methods to guarantee this. contextmanager wraps your generator in an object with __enter__ and __exit__ methods for you. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: contextlib.contextmanager and try/finally
On 1/11/12 3:45 PM, joha...@gmail.com wrote: I'm trying to write a context manager to handle database connections, under the principle that I should not rely on CPython's reference-counting semantics to clean up scarce resources, like connections. I wrote: @contexlib.contextmanager def ensure_connection(con=None): con_created = False if con is None: con_created, con = True, make_connection() try: yield con finally: if con_created: con.close() However, then I read the following paragraph from PEP-343: Note that we're not guaranteeing that the finally-clause is executed immediately after the generator object becomes unused, even though this is how it will work in CPython. This is similar to auto-closing files: while a reference-counting implementation like CPython deallocates an object as soon as the last reference to it goes away, implementations that use other GC algorithms do not make the same guarantee. This applies to Jython, IronPython, and probably to Python running on Parrot. That suggests that I cannot rely on the contextlib.contextmanager decorator to ensure that the connection is closed and would have to write my own object with __enter__ and __exit__ methods to guarantee this. Is this understanding accurate? If so, could someone illustrate why this is so? Looking at the paragraph before this one, it appears that the PEP is talking about the .close() method on generators, which is really just a general purpose API for closing generators that might not be exhausted yet. It's not really related to the context manager stuff except that it came up during the design process of the context manager along with the related .send() and .throw() methods. __enter__() will call .next() once to execute the code up to the yield statement. Then __exit__() will call .next() once again to execute the code after the yield statement, including the finally: clause. That's the only thing you need to rely on. Your connection-closing code will be called if __exit__() gets called. That will exhaust your generator, so the .close() method will not really do anything helpful or hurtful in such a case. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: contextlib.contextmanager and try/finally
On Wed, Jan 11, 2012 at 8:45 AM, joha...@gmail.com wrote: However, then I read the following paragraph from PEP-343: Note that we're not guaranteeing that the finally-clause is executed immediately after the generator object becomes unused, even though this is how it will work in CPython. This is similar to auto-closing files: while a reference-counting implementation like CPython deallocates an object as soon as the last reference to it goes away, implementations that use other GC algorithms do not make the same guarantee. This applies to Jython, IronPython, and probably to Python running on Parrot. That suggests that I cannot rely on the contextlib.contextmanager decorator to ensure that the connection is closed and would have to write my own object with __enter__ and __exit__ methods to guarantee this. Is this understanding accurate? If so, could someone illustrate why this is so? First, this is just a timing issue. There is no guarantee that the finally clause will be executed immediately, but it is guaranteed to be executed at some point. In the other implementations, it would happen whenever the GC algorithm runs. Second, I believe that passage is not referring to the contextmanager decorator specifically, but more generally to the changes that were made to allow generators to yield from within a try-finally construct (previously this would have been illegal syntax, since there was no way to guarantee the finally block would be performed). Like Neil mentioned, a contextmanager generator is wrapped with an __exit__ method that is guaranteed to be called and that explicitly resumes or closes the generator. So as long as your contextmanager generator is properly written (i.e. it yields exactly once), the finally block will execute in a timely fashion. -- http://mail.python.org/mailman/listinfo/python-list
Re: contextlib.contextmanager and try/finally
On Wednesday, January 11, 2012 11:20:19 AM UTC-6, Ian wrote: Second, I believe that passage is not referring to the contextmanager decorator specifically, but more generally to the changes that were made to allow generators to yield from within a try-finally construct (previously this would have been illegal syntax, since there was no way to guarantee the finally block would be performed). Thanks. You and Robert have shown me the light. That paragraph was talking about the finalization that happens to a suspended generator when it is GC'd. Meanwhile, the contextmanager decorator ensures that its generator is run all the way through, so it would never be left in a suspended state, so its GC/finalization semantics are irrelevant. (Please correct, if wrong.) (Neil: I understood that it created a context manager object, but I had been reading the quoted paragraph to mean that by going through a generator the decorator was re-introducing a dependency on GC time. But I was wrong.) Regards, Johann -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
On 1/11/2012 6:19 AM, mike wrote: Hi, We are running are running Python program on Redhat 5.5. When executing our program we get the following error ( see below). Any ideas what this is due to? br, //mike /pysibelius/lib/common/ DataTypes.py Overwriten ... ERROR:root:code for hash md5 was not found. These 3 lines do not come from the interpreter. It might come from the hashlib module. Traceback (most recent call last): File /python/lib/python2.7/hashlib.py, line 139, inmodule globals()[__func_name] = __get_hash(__func_name) File /python/lib/python2.7/hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type md5 This is a standard traceback from the interpreter. The manual says that md5 should always be available. On the other hand, hashlib depends on the OpenSSL library on your system. Perhaps RedHat removed md5 because it has been broken. I suggest you ask them or check your OpenSSL doc. The Python manual may need to be changed. ERROR:root:code for hash sha1 was not found -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I tell incomplete input from invalid input?
On 1/11/2012 8:50 AM, Mateusz Loskot wrote: Unfortunately, this FAQ is either old or incomplete thus incorrect. If you have a suggested change to the current text, please submit it to the tracker at bugs.python.org -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: your feedback to my first project please
On 12-01-08 02:46 PM, patr...@bierans.de wrote: Thanks for the feedback! You're welcome. D'Arcy wrote: [code examples] But I will keep some of my underscores for private attributes and methods. And I googled: dim was basic. I know too many languages and start mixing the keywords - shame on me. ;) No problem but don't overuse the underscores. It starts to look like Perl. The parameters to the methods and the local variables in the methods will not pollute your namespace. The only area you need to concern yourself with is module level object references. import mymodule print dir(mymodule) that's the list you need to be concerned with. You will see that a lot of names are already private. In the case you present I don't think that anything there was private that is not already private based on what it inherits from object. Good Eye: I wrote the tests after coding - I know that this is the wrong way. I just wanted to start coding and after some time I decided that I shoud have some test cases. This is no real TDD - true. ;) I'll do that right next time. This is the number one lesson you should take to heart from this. After thinking about it: Yupp. You are right. Having written tests to check private attributes really hurts one's pride. ;) And you don't want to. The test cases should make sure that public objects and methods act as specified. That's what allows you to refactor any time you want. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Explanation about for
Thank you All for the detailed examples. I tried them all in IDLE and i finally understood them. Thanks for your patience with me until i understand! 2012/1/10 Nick Dokos nicholas.do...@hp.com Νικόλαος Κούρας nikos.kou...@gmail.com wrote: On 10 Ιαν, 03:11, Ian Kelly ian.g.ke...@gmail.com wrote: 2012/1/9 Íéêüëáïò Êïýñáò nikos.kou...@gmail.com: if the MySQL query was: cursor.execute( '''SELECT host, hits, agent, date FROM visitors WHERE pin = %s ORDER BY date DESC''', pin ) can you help me imagine how the mysql database cursor that holds the query results would look like? I must somehow visualize it in order to understand it! You can think of it as a pointer, traversing over one row of the result set at a time. Hopefully this will come out legibly: --- | HOST | HITS | AGENT | DATE | --- - | foo | 7 | IE6 | 1/1/11 | | cursor | --- - | bar | 42 | Firefox | 2/2/10 | --- | baz| 4 | Chrome | 3/3/09 | Database cursor is the pointer that iterates over the result set one row at a time? I though that it was the name we give to the whole mysql result set returned my cursor.execute. Also what happend if the query was: cursor.execute( '''SELECT host FROM visitors) ? the result would have to be something likelike? - |somehost1| - |somehost2| - |somehost3| - . . |somehost n| - So what values host, hits, agent, date would have in 'for host, hits, agent, date in dataset' ? Every row has one string how can that be split in 4? Why don't you try it and see what happens? But to spare you the suspense, you would get: ValueError: need more than 1 value to unpack Because you can't unpack a 1-length tuple into four variables. The code assumes that the query is selecting exactly 4 columns. --- | HOST| HITS| AGENT | DATE | --- | foo | 7 | IE6 | 1/1/11 | --- | bar | 42 | Firefox | 2/2/10 | --- | baz | 4 | Chrome| 3/3/09 | --- In this line: for host, hits, agent, date in dataset: 'dataset' is one of the rows of the mysql result or the whole mysql result set like the table above? I still have trouble understanding this line :( You can think of it as a list of tuples. Forget about cursors and databases for now. If l is a list [1, 2, 3, 4] you iterate over it like this: for x in l: print x and you get each element of the list[fn:1]. Similarly if l is a list of tuples l = [(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)] you can iterate over the list: for x in l: print x In this case, x is going to be (1,2,3,4) the first time through the loop, (5,6,7,8) the second time and so on. You can break each x apart within the loop: for x in l: t1, t2, t3, t4 = x print x, t1, t2, t3, t4 or you can break it apart like this - it's essentially the same thing: for t1, t2, t3, t4 in l: print t1, t2, t3, t4 You have been encouraged repeatedly to try these things interactively: please do so with the above examples and all will become clear. Going back to cursors and databases: you *can* think of 'dataset' as being a list of tuples - a list of all the query results, but with one proviso. The difference when you use a cursor is that `dataset' may be a lazy list (an iterator): instead of the whole set of results being in memory at the same time, the system will take care of doing whatever is necessary to get more of the results when it needs them. But the behavior is the *same* in the sense that the output that you get is the same (you will only see differences if you are keeping an eye on how much memory and how much time your program is using). Nick Footnotes: [fn:1] ... and, no, you *can't express* this as the first time it is for x in 1: ... and the second time it is for x in 2: ... as you asked in another email. That's arrant nonsense: x takes successive values in the list l for every iteration of the for loop. This is elementary Python (nay, elementary programming, period). -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb Error
Thanks. Regards, Janus On Wed, Jan 11, 2012 at 7:12 PM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote: On Wed, 11 Jan 2012 09:57:43 +0200, Emeka emekami...@gmail.com wrote: _mysql_exceptions.ProgrammingError: (1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' street_number int, country_name varchar, street_name char(40) , user_name ch' at line 1) * Per http://dev.mysql.com/doc/refman/5.1/en/create-table.html and http://dev.mysql.com/doc/refman/5.1/en/char.html VARCHAR fields /require/ the maximum length of the field to be defined. Length appears optional for CHAR -- probably defaulting to 1 character. -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list -- *Satajanus Nig. Ltd * -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: Looking for code review on my first Python project.
On Wed, 11 Jan 2012 11:39:48 +, HoneyMonster wrote: On Tue, 10 Jan 2012 18:17:48 -0700, Ian Kelly wrote: On Tue, Jan 10, 2012 at 4:44 PM, HoneyMonster someone@someplace.invalid wrote: Hi, I'm new to Python and recently completed my first project. I used wxPython with wxGlade to generate the GUI bits.The application seems to work well, but I am entirely self-taught, so have undoubtedly committed a number of howlers in terms of style, design, standards, best practice and so forth. snip constructive and helpful advice Very many thanks to Ian and to all who responded. I really appreciate the guidance. Cheers. I have taken on board the helpful suggestions offered, and looked though the PEP-8 document which has been mentioned. As a result, there are a number of changes to the code. My second attempt is in the same place: http://dl.dropbox.com/u/6106778/bbc.py A couple of points: 1) I'm reluctant to try to improve this bit of code: - self.add = wx.MenuItem(self.file, wx.NewId(), Add to Queue, Add a programme to the queue (for download later), wx.ITEM_NORMAL) self.file.AppendItem(self.add) - since it is generated by wxGlade and so will be overwritten. 2) I was very unsure about the wx.CallAfter, and suspect that I have put it in the wrong place. It seems to pass off well enough in Linux, but on Windows it appears to prevent the widgets on the splash frame being drawn properly. If anyone would be kind enough, further comments would be welcomed. Thanks, WH -- http://mail.python.org/mailman/listinfo/python-list
stable object serialization to text file
Hello All,I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem with it: I want to keep the data in version control, and I would like to use it as efficiently as possible. Is it possible to force pickle to store the otherwise unordered (e.g. dictionary) data in a kind of ordered way, so that if I dump a large dict, then change 1 tiny thing in it and dump again, the diff of the former and the new file will be minimal?If pickle is not the best choice for me, can you suggest anything else? (If there isn't any solution for it so far, I will write the module of course, but first I'd like to look around and make sure it hasn't been created yet.)Thanks,Mate-- http://mail.python.org/mailman/listinfo/python-list
Re: open office in another language?
On Tue, 10 Jan 2012 18:43:09 -0300 Sean Wolfe ether@gmail.com wrote: Has there been any talk of doing another similar office suite, or maybe just writer + spreadsheet, in a better language eg python? I expect it's a huge undertaking but ... thought I'd ask around at least. If you are looking for Python based spreadsheets, you may be interested in ResolverOne (commercial product) http://www.resolversystems.com/products/resolver-one/ or in pyspread (GPL, my own effort) http://manns.github.com/pyspread/ Martin -- http://mail.python.org/mailman/listinfo/python-list
Python lib for creating Database tables
Hello All, I just made something pretty simple that I intend to use while creating database tables. It is still in the basic form, and much needs to be added. However, I use introspection to make it a bit easier and less work on the user. I would want my code to be reviewed by this great group. I look forward to your feedback and comments. https://github.com/janus/cheeta Thanks in advance! Regards, Emeka * * -- http://mail.python.org/mailman/listinfo/python-list
Re: open office in another language?
On Wed, Jan 11, 2012 at 6:35 PM, Martin Manns mma...@gmx.net wrote: or in pyspread (GPL, my own effort) http://manns.github.com/pyspread/ Checking this out now. Do you have text boxes? Cause maybe I will add some ... cool! -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Help
mixolydian mixolydian@postersRUS wrote: I want to get into Python progamming for both local database applications and dynamic web pages. Maybe some QD scripts. There is a ton of excellent language books. I have downloaded and installed 2.7.2 and got it working by pasting samples into IDLE, and uploading to my web server and doing trial CGI samples. So far, so good. I would like some advice on: 1. IDEs 2. GUI tools, tkinter and others 3. An integrated web server package for Win Vista for testing web apps before deploying. Uploading to my ISP to run is a PIA. I've installed VertrigoServ to try, but am chasing my tail around the Apache configuration. Is there something easier? Just pointers to get me started would be fine. More info.I will be migrating data base apps from MSAccess 2000. I know, I know, but it was free on my original Win 95 PC. I've been programming for 50 years and have had to learn (and unlearn) a lot, and I'm eager to learn new stuff. Thanks to all those who replied. I am using Notepad++ and WampServer. My hosting service is Apache/phpMyAdmin/MySQL and I decided it was best to use the same on my Windoze development system. Right now I'm revising my site HTML (much of it is 15 yrs old!). Later it will be upgraded to use server-side scripts. Perhaps then I'll look at Django, Cherrpy; etc. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Explanation about for
On Jan 10, 6:37 am, Νικόλαος Κούρας nikos.kou...@gmail.com wrote: On 10 Ιαν, 12:57, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5- a470-7603bd3aa...@spamschutz.glglgl.de wrote: Am 10.01.2012 10:02 schrieb Νικόλαος Κούρας: --- | HOST | HITS | AGENT | DATE | --- | foo | 7 | IE6 | 1/1/11 | --- | bar | 42 | Firefox | 2/2/10 | --- | baz | 4 | Chrome | 3/3/09 | --- In this line: for host, hits, agent, date in dataset: 'dataset' is one of the rows of the mysql result or the whole mysql result set like the table above? dataset is a cursor, representing the whole result set. Iterating over it produces one row at each iteration step: for row in dataset: ... As each row consists of 4 fields, one iteration result is a tuple of 4 elements. In this case, for host, hits, agent, date in dataset: So that means that for host, hits, agent, date in dataset: is: for host, hits, agent, date in (foo,7,IE6,1/1/11) and then: for host, hits, agent, date in (bar,42,Firefox,2/2/10) and then: for host, hits, agent, date in (baz,4,Chrome,3/3/09) So 'dataset' is one row at each time? but we said that 'dataset' represent the whole result set. So isnt it wrong iam substituting it with one line per time only? It maps naturally to a phrase 'for page in a book'. Book refers to a complete book with all pages, but 'for page in a book' refers to each page, one by one. 'for each page in book: turn it'. The meaning is to turn each page, so your question is equivalent to asking 'so book is one page at each time'? No, it is not and doesn't have to be (unless it's a really short book!) -ak -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I tell incomplete input from invalid input?
Terry Reedy wrote On 1/11/2012 8:50 AM, Mateusz Loskot wrote: Unfortunately, this FAQ is either old or incomplete thus incorrect. If you have a suggested change to the current text, please submit it to the tracker at bugs.python.org Yes, this is quite obvious procedure to me, but first I wanted to discuss the problem and to try to find proper solution worth to be included in the FAQ. Best regards, - -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/How-do-I-tell-incomplete-input-from-invalid-input-tp3585241p3632798.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
On Wed, 11 Jan 2012 05:54:29 -0800, mike wrote: I did some more digging and found that our class imports a yacc.py that uses import re, types, sys, cStringIO, hashlib, os.path so it has hashlib. yacc.py seems to be an old version 1.3 ( I found 2.3 --). Reading about hashlib it seems to be dependent on os installation of OpenSSL but I cannot find out how. It shouldn't be. It will use OpenSSL if available, otherwise it will fall back on its own code. br, //mike yacc.py === #- # ply: yacc.py [snip over TWO THOUSAND lines of code] Mike, what lead you to believe that an error in hashlib could be solved by posting the ENTIRE two thousand lines of yacc.py? Please do not post such huge chunks of code unless asked. It is unnecessary and annoying. Try this. Open a terminal window and enter python at the prompt to start a clean interactive session. Then enter the following commands: import sys print(sys.version) import hashlib print(hashlib.__file__) print(hashlib.md5) import _md5 print(_md5.__file__) and copy and paste (do not retype) the full output of these commands. Thank you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python lib for creating Database tables
Hello All, I just made something pretty simple that I intend to use while creating database tables. It is still in the basic form, and much needs to be added. However, I use introspection to make it a bit easier and less work on the user. I would want my code to be reviewed by this great group. I look forward to your feedback and comments. https://github.com/janus/cheeta Cheeta has similarities to http://www.sqlalchemy.org/. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: Looking for code review on my first Python project.
HoneyMonster於 2012年1月12日星期四UTC+8上午5時09分13秒寫道: On Wed, 11 Jan 2012 11:39:48 +, HoneyMonster wrote: On Tue, 10 Jan 2012 18:17:48 -0700, Ian Kelly wrote: On Tue, Jan 10, 2012 at 4:44 PM, HoneyMonster someone@someplace.invalid wrote: Hi, I'm new to Python and recently completed my first project. I used wxPython with wxGlade to generate the GUI bits.The application seems to work well, but I am entirely self-taught, so have undoubtedly committed a number of howlers in terms of style, design, standards, best practice and so forth. snip constructive and helpful advice Very many thanks to Ian and to all who responded. I really appreciate the guidance. Cheers. I have taken on board the helpful suggestions offered, and looked though the PEP-8 document which has been mentioned. As a result, there are a number of changes to the code. My second attempt is in the same place: http://dl.dropbox.com/u/6106778/bbc.py A couple of points: 1) I'm reluctant to try to improve this bit of code: - self.add = wx.MenuItem(self.file, wx.NewId(), Add to Queue, Add a programme to the queue (for download later), wx.ITEM_NORMAL) self.file.AppendItem(self.add) - since it is generated by wxGlade and so will be overwritten. 2) I was very unsure about the wx.CallAfter, and suspect that I have put it in the wrong place. It seems to pass off well enough in Linux, but on Windows it appears to prevent the widgets on the splash frame being drawn properly. If anyone would be kind enough, further comments would be welcomed. Thanks, WH I haven't tried wxGlade for several years. I checked BOA, WxGlade and Wxpython and pygame 4 years ago. Auto code generators in BOA and WxGlade are more helpful to python programmers. One can develop GUI by python with Tcl/tk or Qt, too. But the license conditions in software packages are not all the same. -- http://mail.python.org/mailman/listinfo/python-list
Re: open office in another language?
Open Office suite software users are most non-programmers. Software to be used by non-programmers are different from most free python packages shared by programmers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Introspecting optparse/argparse objects
On Jan 11, 11:26 am, Evan Driscoll edrisc...@wisc.edu wrote: (For a concrete idea of a use case, suppose that it did not directly support the --help option and I wanted to write code that took its place.) That's a pretty weird definition of 'concrete use case', but anyway... This means that either I need to write my own wrappers around options, option groups, and perhaps even an option parser, or I have to dig into _variables _that _are _not _part _of _the _public _api. Both of those choices are distasteful. If you're wanting to extend the behaviour of the options, won't you need to wrap them anyway? But more to the point, you already have the data: you used it to create the options. Why not just keep a handle on that data and refer to what you need directly? 2) Is there some particular reason that this API *isn't* provided, and if I asked for it I might get it in a future version? Not in optparse, as it's no longer being developed. For argparse, you might want a better use case: adding functionality to support a hypothetical lack of functionality (which is _actually_ provides) seems like a pedantic exercise to me. -- http://mail.python.org/mailman/listinfo/python-list
Two questions about logging
I'm trying to figure out a couple of things with the logging module, and I'm hoping someone can provide some pointers. I've read through the module docs on python.org, the basic and advanced tutorials, and the cookbook post, but a couple of things still elude me. First, I'd like to be able to permit users to do more typical log rotation, based on their OS's log rotation handler, rather than rotating logs from inside an application. This is usually handled by signalling an application with a HUP, whereupon it closes and then re- opens all of its logs, getting new file handles (and new inodes). I don't see anything in the Handler methods (or anywhere else) that would let me tell a logger object to refresh the file handles on a log file. Is there some standard way to deal with this? Second, I'm trying to get a handle on how libraries are meant to integrate with the applications that use them. The naming advice in the advanced tutorial is to use __name__ to name loggers, and to allow log messages to pass back up to the using application's logger for processing, but these two pieces of advice seem contradictory.. since log messages only pass back up to the root if the loggers are named hierarchically. cat foo.py #!/usr/bin/env python import logging import bar logger = logging.getLogger(__name__) fh = logging.FileHandler('foo.log') ch = logging.StreamHandler() logger.addHandler(fh) logger.addHandler(ch) logger.warning('from the first') bar.funct() cat bar.py #!/usr/bin/env python import logging def funct(): logger = logging.getLogger(__name__) logger.warning('from the second') ./foo.py from the first No handlers could be found for logger bar So, given this state of affairs, how is a library author to use loggers, given that he or she can't know how authors who use the library will name their logger objects? In the above example, what would the author of bar.py do to hook up bar's logger with foo's, without knowing in advance what foo's logger will be named? Thanks very much for any suggestions, or pointers to documentation that I've missed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions about logging
In article 7dabf43f-3814-47b6-966a-1439f5654...@i6g2000vbk.googlegroups.com, Matthew Pounsett matt.pouns...@gmail.com wrote: First, I'd like to be able to permit users to do more typical log rotation, based on their OS's log rotation handler, rather than rotating logs from inside an application. This is usually handled by signalling an application with a HUP, whereupon it closes and then re- opens all of its logs, getting new file handles (and new inodes). I don't see anything in the Handler methods (or anywhere else) that would let me tell a logger object to refresh the file handles on a log file. Is there some standard way to deal with this? What I would do is log to syslog (logging.handlers.SysLogHandler) and let syslog worry about rotating log files. Why reinvent the wheel? -- http://mail.python.org/mailman/listinfo/python-list
Re: Introspecting optparse/argparse objects
On 1/11/2012 19:37, alex23 wrote: On Jan 11, 11:26 am, Evan Driscoll edrisc...@wisc.edu wrote: (For a concrete idea of a use case, suppose that it did not directly support the --help option and I wanted to write code that took its place.) That's a pretty weird definition of 'concrete use case', but anyway... It's actually closer to the truth than it might seem. I want to feed a bash-completion-style thing, using the same data structure to both figure out the possible completions and also do the actual parsing. Do the actual parsing = optparse/argparse, while figure out the possible completions = I need to be able to look at a list. If you're wanting to extend the behaviour of the options, won't you need to wrap them anyway? I don't have any need to extend the parsers other than to get the list of options. (Though now that you've brought that up, perhaps looking at the _private fields in a subclass would be the best tradeoff? Hmmm.) But more to the point, you already have the data: you used it to create the options. Why not just keep a handle on that data and refer to what you need directly? But now you're talking about wrapping the parser, because there's no builtin way (at least that I know of) to store the information in such a way that you can call the function, because it uses a mix of positional and keyword arguments. E.g. I can't say just args = ('-f', '--foo', help='do foo') ... parser.add_argument(*args) but would have to say something like args = ( ('-f', '-foo'), {'help': 'do foo'}) ... parser.add_argument(*args[0], *args[1]) or something like that. I'd want to add some function like 'make_option' which wraps all that up, and then provide a nicer interface for add_argument, etc., and it seems like pretty soon I're reimplementing the optparse API. :-) Or at least it might be that way. Evan signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Ctypes compatibility
On 1/10/2012 22:42, Alec Taylor wrote: Use size_t http://en.wikipedia.org/wiki/C_data_types#Size_and_pointer_difference_types Um, perhaps you misunderstand. I don't control the C API, I'm calling a function that just exists in libc (unless I do what I said and write a wrapper). If you're saying I should use c_size_t on the Python side, I think that's outright wrong since I think some of the fields in the dirent struct are 64 bits even on 32-bit systems. (I might be wrong about that though.) And even neglecting that, the types of the fields is only part of the problem. Evan signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Two questions about logging
On Jan 11, 9:34 pm, Roy Smith r...@panix.com wrote: What I would do is log to syslog (logging.handlers.SysLogHandler) and let syslog worry about rotating log files. Why reinvent the wheel? Syslog is fine for an application run by an administrator, but isn't an option for a user. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to install lxml in window xp?
Use Linux! Specially Gentoo Linux! Tamer Am 09.01.2012 10:18, schrieb 水静流深: in my xp ,python26,easy_install installed. i want to install lxml in window xp 1.c:\python26\scripts\easy_install lxml what i get is: Reading http://codespeak.net/lxml Best match: lxml 2.3.3 Downloading http://lxml.de/files/lxml-2.3.3.tgz Processing lxml-2.3.3.tgz Running lxml-2.3.3\setup.py -q bdist_egg --dist-dir c:\windows\temp\easy_install -58e4ap\lxml-2.3.3\egg-dist-tmp-hyg1bg Building lxml version 2.3.3. Building with Cython 0.15.1. ERROR: 'xslt-config' is not recognized as an internal or external command, operable program or batch file. ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt warning: no files found matching 'lxml.etree.c' under directory 'src\lxml' warning: no files found matching 'lxml.objectify.c' under directory 'src\lxml' warning: no files found matching 'lxml.etree.h' under directory 'src\lxml' warning: no files found matching 'lxml.etree_api.h' under directory 'src\lxml' warning: no files found matching 'etree_defs.h' under directory 'src\lxml' Reading http://codespeak.net/lxml Best match: lxml 2.3.3 Downloading http://lxml.de/files/lxml-2.3.3.tgz Processing lxml-2.3.3.tgz Running lxml-2.3.3\setup.py -q bdist_egg --dist-dir c:\windows\temp\easy_install -58e4ap\lxml-2.3.3\egg-dist-tmp-hyg1bg Building lxml version 2.3.3. Building with Cython 0.15.1. ERROR: 'xslt-config' is not recognized as an internal or external command, operable program or batch file. ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt warning: no files found matching 'lxml.etree.c' under directory 'src\lxml' warning: no files found matching 'lxml.objectify.c' under directory 'src\lxml' warning: no files found matching 'lxml.etree.h' under directory 'src\lxml' warning: no files found matching 'lxml.etree_api.h' under directory 'src\lxml' warning: no files found matching 'etree_defs.h' under directory 'src\lxml' warning: no files found matching 'pubkey.asc' under directory 'doc' warning: no files found matching 'tagpython*.png' under directory 'doc' warning: no files found matching 'Makefile' under directory 'doc' error: Setup script exited with error: None how can i install the lxml in my xp?? -- http://mail.python.org/mailman/listinfo/python-list
Re: how to install lxml in window xp?
On Wed, Jan 11, 2012 at 23:01, Tamer Higazi th9...@googlemail.com wrote: Use Linux! Specially Gentoo Linux! Not a useful answer. -- http://mail.python.org/mailman/listinfo/python-list
Re: pipe into preallocated buffer?
On Wed, Jan 4, 2012 at 8:05 PM, Mihai Badoiu mbad...@gmail.com wrote: is there a way to pipe directly into a preallocated buffer? (subprocessing.pipe.stdout) Does io.StringIO fit your needs? http://docs.python.org/py3k/library/io.html#io.StringIO -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
On Jan 12, 12:28 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Wed, 11 Jan 2012 05:54:29 -0800, mike wrote: I did some more digging and found that our class imports a yacc.py that uses import re, types, sys, cStringIO, hashlib, os.path so it has hashlib. yacc.py seems to be an old version 1.3 ( I found 2.3 --). Reading about hashlib it seems to be dependent on os installation of OpenSSL but I cannot find out how. It shouldn't be. It will use OpenSSL if available, otherwise it will fall back on its own code. br, //mike yacc.py === #- # ply: yacc.py [snip over TWO THOUSAND lines of code] Mike, what lead you to believe that an error in hashlib could be solved by posting the ENTIRE two thousand lines of yacc.py? Please do not post such huge chunks of code unless asked. It is unnecessary and annoying. Try this. Open a terminal window and enter python at the prompt to start a clean interactive session. Then enter the following commands: import sys print(sys.version) import hashlib print(hashlib.__file__) print(hashlib.md5) import _md5 print(_md5.__file__) and copy and paste (do not retype) the full output of these commands. Thank you. -- Steven Hi, Sorry for posting huge file. I added your copy-paste snippet. esekilx5030 [7:09am] [roamFroBl/pysibelius/bin] - python Python 2.7.2 (default, Jun 16 2011, 15:05:49) [GCC 4.5.0] on linux2 Type help, copyright, credits or license for more information. import sys print(sys.version) import hashlib print(hashlib.__file__) print(hashlib.md5) import _md5 print(_md5.__file__) 2.7.2 (default, Jun 16 2011, 15:05:49) [GCC 4.5.0] ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha512 /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/hashlib.pyc Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'md5' Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named _md5 Thanks for support! //mike -- http://mail.python.org/mailman/listinfo/python-list
Re: pipe into preallocated buffer?
Am 12.01.2012 06:23 schrieb Kushal Kumaran: On Wed, Jan 4, 2012 at 8:05 PM, Mihai Badoiumbad...@gmail.com wrote: is there a way to pipe directly into a preallocated buffer? (subprocessing.pipe.stdout) Does io.StringIO fit your needs? http://docs.python.org/py3k/library/io.html#io.StringIO Probably not. A file object used in the subprocess context needs a fileno() method. StringIO objects don't have such. Probably it is necessary to use subprocess.communicate() (for rather small data lengths) or to use sp.stdout.read() to read it manually. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Bug in logutils package
Does anyone have any inkling on how to fix this bug? http://code.google.com/p/logutils/issues/detail?id=3 Or any good pointers on how to find out whats wrong and how to fix it would be nice. Thanks, --Ram -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
On Jan 12, 7:13 am, mike mikaelpetters...@gmail.com wrote: On Jan 12, 12:28 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Wed, 11 Jan 2012 05:54:29 -0800, mike wrote: I did some more digging and found that our class imports a yacc.py that uses import re, types, sys, cStringIO, hashlib, os.path so it has hashlib. yacc.py seems to be an old version 1.3 ( I found 2.3 --). Reading about hashlib it seems to be dependent on os installation of OpenSSL but I cannot find out how. It shouldn't be. It will use OpenSSL if available, otherwise it will fall back on its own code. br, //mike yacc.py === #- # ply: yacc.py [snip over TWO THOUSAND lines of code] Mike, what lead you to believe that an error in hashlib could be solved by posting the ENTIRE two thousand lines of yacc.py? Please do not post such huge chunks of code unless asked. It is unnecessary and annoying. Try this. Open a terminal window and enter python at the prompt to start a clean interactive session. Then enter the following commands: import sys print(sys.version) import hashlib print(hashlib.__file__) print(hashlib.md5) import _md5 print(_md5.__file__) and copy and paste (do not retype) the full output of these commands. Thank you. -- Steven Hi, Sorry for posting huge file. I added your copy-paste snippet. esekilx5030 [7:09am] [roamFroBl/pysibelius/bin] - python Python 2.7.2 (default, Jun 16 2011, 15:05:49) [GCC 4.5.0] on linux2 Type help, copyright, credits or license for more information. import sys print(sys.version) import hashlib print(hashlib.__file__) print(hashlib.md5) import _md5 print(_md5.__file__) 2.7.2 (default, Jun 16 2011, 15:05:49) [GCC 4.5.0] ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last): File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 139, in module globals()[__func_name] = __get_hash(__func_name) File /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/ hashlib.py, line 91, in __get_builtin_constructor raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha512 /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/hashlib.pyc Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'md5' Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named _md5 Thanks for support! //mike Hi, I did some more testing. The python 2.7.2 lib is stored in
[issue13754] str.ljust and str.rjust do not exactly describes original string return
Terry J. Reedy tjre...@udel.edu added the comment: The short doc strings do not mention the issue either way. I think it ok to leave them as they are. While the claim is how the functions *should* operate, I verified that it is how they *do* operate in all three branches. -- assignee: docs@python - terry.reedy keywords: +easy, patch nosy: +terry.reedy stage: - needs patch versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13754 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13753] str.join description contains an incorrect reference to argument
Changes by Terry J. Reedy tjre...@udel.edu: -- assignee: docs@python - terry.reedy keywords: +easy, patch nosy: +terry.reedy versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13753 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13748] Allow rb literals as an equivalent to br
Georg Brandl ge...@python.org added the comment: +1 for raw bytes, which reads much nicer to me than bytes raw. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13748 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1692335] Fix exception pickling: Move initial args assignment to BaseException.__new__
Faheem Mitha fah...@faheem.info added the comment: What is the status on this? It contains to be an issue. See http://bugs.python.org/issue13751 and http://bugs.python.org/issue13760 -- nosy: +fmitha ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1692335 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13753] str.join description contains an incorrect reference to argument
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13753 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13759] Python 3.2.2 Mac installer version doesn't accept multibyte character in interactive mode
Ned Deily n...@acm.org added the comment: Can you give the exact steps of what you did to demonstrate the problem? Also, there are two OS X installers for Python 3.2.2. Which one did you install? (The two lines of version information when starting Python is enough to identify which one it is.) -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13759 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13752] add a unicode.casefold() method
Changes by Georg Brandl ge...@python.org: -- stage: - needs patch title: add a casefold() method - add a unicode.casefold() method ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13752 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13761] Add flush keyword to print()
New submission from Georg Brandl ge...@python.org: Add a flush keyword argument to print(), defaulting to False. If true, output will be flushed immediately. See http://mail.python.org/pipermail/python-ideas/2012-January/013340.html -- assignee: georg.brandl components: Interpreter Core keywords: easy messages: 151041 nosy: georg.brandl priority: normal severity: normal stage: needs patch status: open title: Add flush keyword to print() type: enhancement versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13761 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13754] str.ljust and str.rjust do not exactly describes original string return
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 3aed8787ce5c by Terry Jan Reedy in branch '2.7': Closes #13754 String returned if less than *or equal to* x 3 http://hg.python.org/cpython/rev/3aed8787ce5c New changeset 3f2e5fd17b76 by Terry Jan Reedy in branch '3.2': #13754 String returned if less than *or equal to* x 3 http://hg.python.org/cpython/rev/3f2e5fd17b76 New changeset 0df85a2ebe4d by Terry Jan Reedy in branch 'default': Merge with 3.2 http://hg.python.org/cpython/rev/0df85a2ebe4d -- nosy: +python-dev resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13754 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13753] str.join description contains an incorrect reference to argument
Terry J. Reedy tjre...@udel.edu added the comment: See #13754 for commits (not here because 'close' != 'closes' or closed') -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13753 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13761] Add flush keyword to print()
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13761 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13759] Python 3.2.2 Mac installer version doesn't accept multibyte character in interactive mode
Atsushi Shibata shib...@webcore.co.jp added the comment: The procedure is following. 1. type python in the terminal.app to launch interactive mode. 2. type 'あ' in it. And I use Mac OS X 64-bit/32-bit Installer (3.2.2) for Mac OS X 10.6 and 10.7. Here is the first 2 lines of initial message. Python 3.2.2 (v3.2.2:137e45f15c0b, Sep 3 2011, 17:28:59) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin thanks :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13759 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4630] IDLE no longer respects .Xdefaults insertOffTime
Terry J. Reedy tjre...@udel.edu added the comment: The idea and design look good to me. I will test on Windows when I am able to do so in development builds (unless someone beats me ;-). -- nosy: +terry.reedy versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4630 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4630] IDLE: add cursor noblink option
Changes by Terry J. Reedy tjre...@udel.edu: -- title: IDLE no longer respects .Xdefaults insertOffTime - IDLE: add cursor noblink option ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4630 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13759] Python 3.2.2 Mac installer version doesn't accept multibyte character in interactive mode
Ned Deily n...@acm.org added the comment: I am not familiar with the Japanese input methods available in OS X. But using copy and paste with an US UTF-8 locale, it seems to work. Perhaps there is a different locale in effect? Python 3.2.2 (v3.2.2:137e45f15c0b, Sep 3 2011, 17:28:59) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type help, copyright, credits or license for more information. x = 'あ' print(x) あ print(ord(x)) 12354 import unicodedata unicodedata.name(x) 'HIRAGANA LETTER A' print('%x' % ord(x)) 3042 import locale locale.getlocale() ('en_US', 'UTF-8') -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13759 ___ ___ 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: Patch version 5 fixes test_unicode for 64-bit system. Victor, I don't think the randomization idea is going anywhere. The code has many issues: * it is exceedingly complex * the method would need to be implemented for all hashable Python types * it causes startup time to increase (you need urandom data for every single hashable Python data type) * it causes run-time to increase due to changes in the hash algorithm (more operations in the tight loop) * causes different processes in a multi-process setup to use different hashes for the same object * doesn't appear to work well in embedded interpreters that regularly restarted interpreters (AFAIK, some objects persist across restarts and those will have wrong hash values in the newly started instances) The most important issue, though, is that it doesn't really protect Python against the attack - it only makes it less likely that an adversary will find the init vector (or a way around having to find it via crypt analysis). OTOH, the collision counting patch is very simple, doesn't have the performance issues and provides real protection against the attack. Even better still, it can detect programming errors in hash method implementations. IMO, it would be better to put efforts into refining the collision detection patch (perhaps adding support for the universal hash method slot I mentioned) and run some real life tests with it. -- ___ 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
[issue13472] devguide doesn’t list all build dependencies
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13472 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13440] Explain the status quo wins a stalemate principle in the devguide
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13440 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12907] Update test coverage devguide page
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12907 ___ ___ 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: * it is exceedingly complex Which part exactly? For hash(str), it just add two extra XOR. * the method would need to be implemented for all hashable Python types It was already discussed, and it was said that only hash(str) need to be modified. * it causes startup time to increase (you need urandom data for every single hashable Python data type) My patch reads 8 or 16 bytes from /dev/urandom which doesn't block. Do you have a benchmark showing a difference? I didn't try my patch on Windows yet. * it causes run-time to increase due to changes in the hash algorithm (more operations in the tight loop) I posted a micro-benchmark on hash(str) on python-dev: the overhead is nul. Did you have numbers showing that the overhead is not nul? * causes different processes in a multi-process setup to use different hashes for the same object Correct. If you need to get the same hash, you can disable the randomized hash (PYTHONHASHSEED=0) or use a fixed seed (e.g. PYTHONHASHSEED=42). * doesn't appear to work well in embedded interpreters that regularly restarted interpreters (AFAIK, some objects persist across restarts and those will have wrong hash values in the newly started instances) test_capi runs _testembed which restarts a embedded interpreters 3 times, and the test pass (with my patch version 5). Can you write a script showing the problem if there is a real problem? In an older version of my patch, the hash secret was recreated at each initiliazation. I changed my patch to only generate the secret once. The most important issue, though, is that it doesn't really protect Python against the attack - it only makes it less likely that an adversary will find the init vector (or a way around having to find it via crypt analysis). I agree that the patch is not perfect. As written in the patch, it just makes the attack more complex. I consider that it is enough. Perl has a simpler protection than the one proposed in my patch. Is Perl vulnerable to the hash collision vulnerability? -- ___ 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
[issue12296] Minor clarification in devguide
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12296 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13762] missing section: how to contribute to devguide
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: I struggled to find how to contribute to the devguide. I even struggled to find where the VCS is. I think it would be kool if there was a section for this info (it's not always fun to search the intertubes). -- components: Devguide messages: 151049 nosy: ezio.melotti, tshepang priority: normal severity: normal status: open title: missing section: how to contribute to devguide type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13762 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13124] Add Running a Build Slave page to the devguide
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12409] Moving Documenting Python to Devguide
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12409 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13275] Recommend xml.etree for XML processing
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13275 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13275] Recommend xml.etree for XML processing
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: @Araujo bit offtopic, but which XML library have you found most elegant? Is it available in the stdlib? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13275 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13763] rm obsolete reference in devguide
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: this line: commonly abbreviated svn, after the program name was once changed to: commonly abbreviated hg, after the program name and it no longer makes sense -- components: Devguide files: rm-obsolete-reference.patch keywords: patch messages: 151051 nosy: ezio.melotti, tshepang priority: normal severity: normal status: open title: rm obsolete reference in devguide Added file: http://bugs.python.org/file24200/rm-obsolete-reference.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13763 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13764] Misc/build.sh is outdated... talks about svn
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: I am wondering what else is outdated in that file. Is it still useful? -- components: Build messages: 151052 nosy: tshepang priority: normal severity: normal status: open title: Misc/build.sh is outdated... talks about svn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13764 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13759] Python 3.2.2 Mac installer version doesn't accept multibyte character in interactive mode
Atsushi Shibata shib...@webcore.co.jp added the comment: Thank you for testing on your environment :-). I'll make sure the difference that caused the issue. I changed the status to pending. I'll come back to this issue when I find the crue. Thanks anyway ! -- status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13759 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13765] Distutils does not put quotes around paths that contain spaces when compiling with MSVC
New submission from Almar Klein almar.kl...@gmail.com: I found an easy to solve bug in distutils, which is causing problems with compiling Cython code on Windows. I have reproduced this on Python 2.6 and Python 3.2 (32 bit). The problem occurs with the native msvc compiler. Using gcc (MinGW) works fine. The problem is that the command to link the libraries does not put double quotes around paths that have spaces in them. Unfortunately, the path where I have Python installed has spaces in it (c:/program files/python26). Small example of part of a link command: /LIBPATH:C:\Program Files (x86)\python32\libs. Note that the include_dirs DO have double quotes around them. The problem is easily solved (I confirmed this) by a small change in msvc9compiler.py and msvccompiler.py (see also the patch): def library_dir_option(self, dir): # OLD VERSION return /LIBPATH: + dir def library_dir_option(self, dir): # FIXED VERSION if ' ' in dir and not dir.startswith(''): dir = '%s' % dir return /LIBPATH: + dir I tried to see if it would be nicer to apply a change elsewhere, e.g. where library_dir_option() is called. However, it is called nowhere from within the distutils package. In my case I suspect numpy.distutils or a part of Cython calls it. Anyway, in my opinion you should be able to pass this function a dirname that has a space in it, and get the right (partial) command. For the record, this change is quite safe because it checks whether quotes are already present. = Below follows a minimal Cython example and traceback = = test_.pyx def foo(): print('hello') = setup.py import os, sys from Cython.Distutils import build_ext from distutils.core import setup from distutils.extension import Extension from numpy.distutils.misc_util import get_numpy_include_dirs # Ugly hack so I can run setup.py in my IDE sys.argv = ['setup.py', 'build_ext', '--inplace'] # Init include dirs include_dirs = ['.'] include_dirs.extend(get_numpy_include_dirs()) # Creat Extensions ext_modules = [ Extension('test_', ['test_.pyx'], include_dirs=include_dirs, ), ] # Compile setup( cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules, ) print('Successfully compiled cython file: test_') = output when running setup.py running build_ext No module named msvccompiler in numpy.distutils; trying from distutils cythoning test_.pyx to test_.c building 'test_' extension C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I. -IC:\Program Files (x86)\python32\lib\site-packages\numpy\core\include -IC:\Program Files (x86)\python32\include -IC:\Program Files (x86)\python32\PC /Tctest_.c /Fobuild\temp.win32-3.2\Release\test_.obj Found executable C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Program Files (x86)\python32\libs /LIBPATH:C:\Program Files (x86)\python32\PCbuild /EXPORT:PyInit_test_ build\temp.win32-3.2\Release\test_.obj /OUT:C:\almar\projects\py\cmu1394\test_.pyd /IMPLIB:build\temp.win32-3.2\Release\test_.lib /MANIFESTFILE:build\temp.win32-3.2\Release\test_.pyd.manifest Found executable C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe LINK : fatal error LNK1181: cannot open input file 'Files.obj' -- assignee: tarek components: Distutils files: distutils_spaces_in_libdir.patch keywords: patch messages: 151054 nosy: almar, eric.araujo, mhammond, tarek priority: normal severity: normal status: open title: Distutils does not put quotes around paths that contain spaces when compiling with MSVC type: behavior versions: Python 2.6, Python 3.2 Added file: http://bugs.python.org/file24201/distutils_spaces_in_libdir.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13766] explain the relationship between Lib/lib2to3/Grammar.txt and Grammar/Grammar
New submission from Tshepang Lekhonkhobe tshep...@gmail.com: Lib/lib2to3/Grammar.txt seems like a modified copy of Grammar/Grammar. Can you state so somewhere, maybe in the beginning of Lib/lib2to3/Grammar.txt (the Note section). One problem with the way it is now, is that there are changes done to Grammar/Grammar that are not put into Lib/lib2to3/Grammar.txt. Maybe they are minor, but I think we don't want them diverging too much. Another problem is that the Note on Lib/lib2to3/Grammar.txt maybe irrelevant, since this is not the authoritative Grammar file. -- assignee: docs@python components: Documentation messages: 151055 nosy: docs@python, tshepang priority: normal severity: normal status: open title: explain the relationship between Lib/lib2to3/Grammar.txt and Grammar/Grammar type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13766 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13762] missing section: how to contribute to devguide
Sandro Tosi sandro.t...@gmail.com added the comment: Hello Tshepang, The current section is at: http://docs.python.org/devguide/docquality.html#helping-with-the-developer-s-guide reachable from the mainpage looking for helping with documentation. it may be a little to condense but it is a good start (and it seems to cover the points you made in the issue): do you find it useful as it is? would you like to add something? -- nosy: +sandro.tosi ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13762 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13762] missing section: how to contribute to devguide
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: I guess I should have looked more carefully. Thanks and sorry for the noise. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13762 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2175] Expat sax parser silently ignores the InputSource protocol
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12779] Update packaging documentation
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12779 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1975] signals not always delivered to main thread, since other threads have the signal unmasked
Changes by Floris Bruynooghe floris.bruynoo...@gmail.com: -- nosy: +flub ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1975 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13767] Would be nice to have a future import that turned off old except style
New submission from Zaheer Merali zaheermer...@gmail.com: It would be nice to have a future import to be able to prevent people in code doing: try: except Exception, e: and make people do: try: except Exception as e: -- components: Interpreter Core messages: 151058 nosy: Zaheer.Merali priority: normal severity: normal status: open title: Would be nice to have a future import that turned off old except style type: enhancement versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13767 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13762] missing section: how to contribute to devguide
Changes by Sandro Tosi sandro.t...@gmail.com: -- resolution: - invalid ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13762 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13767] Would be nice to have a future import that turned off old except style
Ezio Melotti ezio.melo...@gmail.com added the comment: If you run python with the -3 flag you should get a warning about that. If you combine it with -We you should be able to get an error instead of a warning. Note however that both the flags are not specific for the except but also generate/affect other warnings as well. -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13767 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13767] Would be nice to have a future import that turned off old except style
Benjamin Peterson benja...@python.org added the comment: Unfortunately, that would be a new feature, so it is not acceptable to Python 2.7. -- nosy: +benjamin.peterson resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13767 ___ ___ 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: * it is exceedingly complex Which part exactly? For hash(str), it just add two extra XOR. I'm not talking specifically about your patch, but the whole idea and the needed changes in general. * the method would need to be implemented for all hashable Python types It was already discussed, and it was said that only hash(str) need to be modified. Really ? What about the much simpler attack on integer hash values ? You only have to send a specially crafted JSON dictionary with integer keys to a Python web server providing JSON interfaces in order to trigger the integer hash attack. The same goes for the other Python data types. * it causes startup time to increase (you need urandom data for every single hashable Python data type) My patch reads 8 or 16 bytes from /dev/urandom which doesn't block. Do you have a benchmark showing a difference? I didn't try my patch on Windows yet. Your patch only implements the simple idea of adding an init vector and a fixed suffix vector (which you don't need since it doesn't prevent hash collisions). I don't think that's good enough, since it doesn't change how the hash algorithm works on the actual data, but instead just shifts the algorithm to a different sequence. If you apply the same logic to the integer hash function, you'll see that more clearly. Paul's algorithm is much more secure in this respect, but it requires more random startup data. * it causes run-time to increase due to changes in the hash algorithm (more operations in the tight loop) I posted a micro-benchmark on hash(str) on python-dev: the overhead is nul. Did you have numbers showing that the overhead is not nul? For the simple solution, that's an expected result, but if you want more safety, then you'll see a hit due to the random data getting XOR'ed in every single loop. * causes different processes in a multi-process setup to use different hashes for the same object Correct. If you need to get the same hash, you can disable the randomized hash (PYTHONHASHSEED=0) or use a fixed seed (e.g. PYTHONHASHSEED=42). So you have the choice of being able to work in a multi-process environment and be vulnerable to the attack or not. I think we can do better :-) Note that web servers written in Python tend to be long running processes, so an attacker has lots of time to test various seeds. * doesn't appear to work well in embedded interpreters that regularly restarted interpreters (AFAIK, some objects persist across restarts and those will have wrong hash values in the newly started instances) test_capi runs _testembed which restarts a embedded interpreters 3 times, and the test pass (with my patch version 5). Can you write a script showing the problem if there is a real problem? In an older version of my patch, the hash secret was recreated at each initiliazation. I changed my patch to only generate the secret once. Ok, that should fix the case. Two more issue that I forgot: * enabling randomized hashing can make debugging a lot harder, since it's rather difficult to reproduce the same state in a controlled way (unless you record the hash seed somewhere in the logs) and even though applications should not rely on the order of dict repr()s or str()s, they do often enough: * randomized hashing will result in repr() and str() of dictionaries to be random as well The most important issue, though, is that it doesn't really protect Python against the attack - it only makes it less likely that an adversary will find the init vector (or a way around having to find it via crypt analysis). I agree that the patch is not perfect. As written in the patch, it just makes the attack more complex. I consider that it is enough. Wouldn't you rather see a fix that works for all hash functions and Python objects ? One that doesn't cause performance issues ? The collision counting idea has this potential. Perl has a simpler protection than the one proposed in my patch. Is Perl vulnerable to the hash collision vulnerability? I don't know what Perl did or how hashing works in Perl, so cannot comment on the effect of their fix. FWIW, I don't think that we should use Perl or Java as reference here. -- ___ 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