ANN: eGenix ThreadLock Distribution 2.13.0.1
ANNOUNCING eGenix.com ThreadLock Distribution Version 2.13.0.1 eGenix is making a ThreadLock binary distribution available to simplify the setup for users of our mxODBC Plone/Zope database adapter. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-ThreadLock-Distribution-2.13.0.1.html INTRODUCTION Several people have approached us about a problem they are facing with installing our mxODBC database adapter for Plone and Zope: http://www.egenix.com/products/zope/mxODBCZopeDA/ The adapter product has dependencies on * ThreadLock * Products.ZSQLMethods The Products.ZSQLMethods package is a pure Python package, so it installs fine on all platforms. ThreadLock comes with a Python C extension, so buildout needs to either find egg files for the platforms or have a compiler installed to build the C extensions. On Unix platforms, installing a compiler is fairly straight forward, but on Windows setting up compilers for Python is difficult and the ThreadLock entry on PyPI only comes with egg files for Python 2.6 on Windows. SOLUTION To overcome this problem, we have taken the ThreadLock package and created an internal setup to have it compiled by our build farm. You can now use these buildout configuration settings to pull the egg files from our indexes. For UCS2 Python builds (16-bit Unicode on Unix, Python for Windows): [buildout] ... find-links = ... https://downloads.egenix.com/python/index/ucs2/ eggs = ... ThreadLock [versions] ... ThreadLock = 2.13.0.1 For UCS4 Python builds (32-bit Unicode on Unix): [buildout] ... find-links = ... https://downloads.egenix.com/python/index/ucs4/ eggs = ... ThreadLock [versions] ... ThreadLock = 2.13.0.1 Available binaries -- We provide egg files for Linux x86 and x64, Windows x86 and x64 as well as the source package as fallback solution. The binaries were compiled with Python 2.4, 2.5, 2.6 and 2.7. Version number -- Note that we have added a build number to the package version. This allows us to issue updates to the package builds should these be necessary and also makes sure that your buildout will use the packages from our indexes instead of PyPI or other indexes. ABOUT THE EGENIX MXODBC PLONE/ZOPE DATABASE ADAPTER The eGenix mxODBC Zope DA allows you to easily connect your Zope or Plone CMS installation to just about any database backend on the market today, giving you the reliability of the commercially supported eGenix product mxODBC and the flexibility of the ODBC standard as middle-tier architecture. The mxODBC Zope Database Adapter is highly portable, just like Zope itself and provides a high performance interface to all your ODBC data sources, using a single well-supported interface on Windows, Linux, Mac OS X, FreeBSD and other platforms. This makes it ideal for deployment in ZEO Clusters and Zope hosting environments where stability and high performance are a top priority, establishing an excellent basis and scalable solution for your Plone CMS. Product page: http://www.egenix.com/products/zope/mxODBCZopeDA/ MORE INFORMATION For more information on the eGenix ThreadLock distribution, the eGenix mxODBC Zope DA, licensing and download instructions, please write to sa...@egenix.com. Enjoy, -- -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 06 2014) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2014-10-24: Released eGenix pyOpenSSL 0.13.5 ... http://egenix.com/go63 : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: I need algorithm for my task
Denis McMahon writes: On Thu, 06 Nov 2014 15:14:05 +1100, Chris Angelico wrote: On Thu, Nov 6, 2014 at 3:00 PM, Denis McMahon wrote: def baseword(s): find shortest sequence which repeats to generate s return s[0:[.join([s[0:x]for k in range(int(len(s)/x)+1)])[0:len (s)]for x in range(1,len(s)+1)].index(s)+1] That's hardly a PEP-8 compliant line, but I can help out a bit. return s[0:[(s[0:x]*(len(s)//x+1))[0:len(s)]for x in range(1,len(s)+1)].index(s)+1] That's still 83 characters without indentation, but it's close now. l = len r = range but technically then it's no longer a one liner. I love the algorithm. Took me a bit of analysis (and inspection of partial results) to understand what your code's doing, but it's stupidly elegant and elegantly stupid. :) Well yes, building that list is a stupid way to solve the problem, but I can't see another way to do it in one line. It's an implementation of my algorithm 3 (which I think you described) but working from the other end as it were. 70-character expression, even with the spaces: x = 'tästäkötästäkötästä' x[:min(k for k in range(len(x) + 1) if x == (x[:k] * len(x))[:len(x)])] 'tästäkö' -- https://mail.python.org/mailman/listinfo/python-list
RE: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?
Yeah, the 11 was mesmerizing. You didn't need no stinkin' program to see how busy the system was, you just checked the lights. You could really tell when somebody was compiling or link/loading. As I've done many times since those days, I am amazed how many users could be using the system simultaneously (yes, general editing, but still...) and it wasn't a quick machine by any stretch. We had a whopping 384K memory and big multi-platter disks with a whopping 65MB. Still think in terms of PIP sometimes... Clayton -Original Message- From: Python-list [mailto:python-list- bounces+crk=godblessthe...@python.org] On Behalf Of Cameron Simpson Sent: Wednesday, November 05, 2014 2:28 PM To: python-list@python.org Subject: Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code? On 05Nov2014 15:38, Denis McMahon denismfmcma...@gmail.com wrote: On Tue, 04 Nov 2014 21:30:06 -0500, Dennis Lee Bieber wrote: If you have an old system with front-panel toggle switches, you set the switches for binary values, and then push the enter switch. You've booted a PDP-8 then ;) Not me, but I have booted a PDP-11. Same deal:-) Our kernels had a patch in the idle loop that updated a specific memory address with a regularly changing bit pattern (therefore the change rate slowed down when the machine was busy). Post boot we'd set the memory view toggle swithces to that address and be treated to a beautiful Cylon-like shuttling pattern of red lights indiciating business. Cheers, Cameron Simpson c...@zip.com.au The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. - Nathaniel Borenstein -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Moving a window on the screen
Hi Why the following program doesn't work ? for x in range(0, 100, 10): fen.geometry(200x200+%d+10 % x) time.sleep(0.5) where fen is a window (fen = Tk()) The fen window goes from it's initial location to the last one but we dont see all the intermediate steps thx -- https://mail.python.org/mailman/listinfo/python-list
Re: Moving a window on the screen
On Thu, Nov 6, 2014 at 7:32 PM, ast nom...@invalid.com wrote: The fen window goes from it's initial location to the last one but we dont see all the intermediate steps You usually don't want to use time.sleep() in a GUI program. Try doing the same thing, but with an event loop delay call instead; often, the display won't update until you go back to the main loop. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Moving a window on the screen
ast wrote: Why the following program doesn't work ? for x in range(0, 100, 10): fen.geometry(200x200+%d+10 % x) time.sleep(0.5) where fen is a window (fen = Tk()) The fen window goes from it's initial location to the last one but we dont see all the intermediate steps As Chris says, using sleep() with a gui program usually doesn't work. While the script is sleeping the event loop doesn't run and consequently the user will not see any updates of the program's state. Instead of sleeping you have to schedule events that trigger a callback and then go back to the event loop. Such a callback may schedule another invocation of itself, thus giving you the desired effect: import tkinter as tk root = tk.Tk() xpositions = iter(range(0, 100, 10)) def move_next(): try: x = next(xpositions) except StopIteration: pass else: root.geometry(200x200+%d+10 % x) root.after(500, move_next) # have tkinter call move_next again # in about 500 milliseconds root.after_idle(move_next) root.mainloop() -- https://mail.python.org/mailman/listinfo/python-list
Re: Moving a window on the screen
Chris Angelico ros...@gmail.com a écrit dans le message de news:mailman.15536.1415264262.18130.python-l...@python.org... You usually don't want to use time.sleep() in a GUI program. Try doing the same thing, but with an event loop delay call instead; often, the display won't update until you go back to the main loop. Ok, thx, it works now with: import tkinter fen = tkinter.Tk() x=0 def moveW(): global x fen.geometry(200x200+%d+10 % x) x = x + 10 if (x 1200): fen.after(50, moveW) moveW() -- https://mail.python.org/mailman/listinfo/python-list
Re: Moving a window on the screen
On 11/6/2014 3:57 AM, Chris Angelico wrote: On Thu, Nov 6, 2014 at 7:32 PM, ast nom...@invalid.com wrote: The fen window goes from it's initial location to the last one but we dont see all the intermediate steps You usually don't want to use time.sleep() in a GUI program. Try doing the same thing, but with an event loop delay call instead; often, the display won't update until you go back to the main loop. import tkinter as tk root = tk.Tk() x = 0 def march(): global x print(x) root.geometry(200x200+%d+%d % (x,x)) x += 10 if x 200: root.after(300, march) march() root.mainloop() -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
wxPython Boxsizers
Hello, I am new to Python. I am learning boxsizer. I want to put two buttons on my panel. One at top right corner and one at bottom right corner. How do I achieve this? Thanks -- https://mail.python.org/mailman/listinfo/python-list
ANN: eGenix ThreadLock Distribution 2.13.0.1
ANNOUNCING eGenix.com ThreadLock Distribution Version 2.13.0.1 eGenix is making a ThreadLock binary distribution available to simplify the setup for users of our mxODBC Plone/Zope database adapter. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-ThreadLock-Distribution-2.13.0.1.html INTRODUCTION Several people have approached us about a problem they are facing with installing our mxODBC database adapter for Plone and Zope: http://www.egenix.com/products/zope/mxODBCZopeDA/ The adapter product has dependencies on * ThreadLock * Products.ZSQLMethods The Products.ZSQLMethods package is a pure Python package, so it installs fine on all platforms. ThreadLock comes with a Python C extension, so buildout needs to either find egg files for the platforms or have a compiler installed to build the C extensions. On Unix platforms, installing a compiler is fairly straight forward, but on Windows setting up compilers for Python is difficult and the ThreadLock entry on PyPI only comes with egg files for Python 2.6 on Windows. SOLUTION To overcome this problem, we have taken the ThreadLock package and created an internal setup to have it compiled by our build farm. You can now use these buildout configuration settings to pull the egg files from our indexes. For UCS2 Python builds (16-bit Unicode on Unix, Python for Windows): [buildout] ... find-links = ... https://downloads.egenix.com/python/index/ucs2/ eggs = ... ThreadLock [versions] ... ThreadLock = 2.13.0.1 For UCS4 Python builds (32-bit Unicode on Unix): [buildout] ... find-links = ... https://downloads.egenix.com/python/index/ucs4/ eggs = ... ThreadLock [versions] ... ThreadLock = 2.13.0.1 Available binaries -- We provide egg files for Linux x86 and x64, Windows x86 and x64 as well as the source package as fallback solution. The binaries were compiled with Python 2.4, 2.5, 2.6 and 2.7. Version number -- Note that we have added a build number to the package version. This allows us to issue updates to the package builds should these be necessary and also makes sure that your buildout will use the packages from our indexes instead of PyPI or other indexes. ABOUT THE EGENIX MXODBC PLONE/ZOPE DATABASE ADAPTER The eGenix mxODBC Zope DA allows you to easily connect your Zope or Plone CMS installation to just about any database backend on the market today, giving you the reliability of the commercially supported eGenix product mxODBC and the flexibility of the ODBC standard as middle-tier architecture. The mxODBC Zope Database Adapter is highly portable, just like Zope itself and provides a high performance interface to all your ODBC data sources, using a single well-supported interface on Windows, Linux, Mac OS X, FreeBSD and other platforms. This makes it ideal for deployment in ZEO Clusters and Zope hosting environments where stability and high performance are a top priority, establishing an excellent basis and scalable solution for your Plone CMS. Product page: http://www.egenix.com/products/zope/mxODBCZopeDA/ MORE INFORMATION For more information on the eGenix ThreadLock distribution, the eGenix mxODBC Zope DA, licensing and download instructions, please write to sa...@egenix.com. Enjoy, -- -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 06 2014) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2014-10-24: Released eGenix pyOpenSSL 0.13.5 ... http://egenix.com/go63 : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- https://mail.python.org/mailman/listinfo/python-list
Re: wxPython Boxsizers
On Thu, Nov 6, 2014 at 5:13 AM, Jaydip Chakrabarty c.joyd...@gmail.com wrote: Hello, I am new to Python. I am learning boxsizer. I want to put two buttons on my panel. One at top right corner and one at bottom right corner. How do I achieve this? Thanks First, what version of python. What is boxsizer? Show some code of what you have tried. -- https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: wxPython Boxsizers
On 06/11/2014 10:13, Jaydip Chakrabarty wrote: Hello, I am new to Python. I am learning boxsizer. I want to put two buttons on my panel. One at top right corner and one at bottom right corner. How do I achieve this? Thanks Probably best asked here https://groups.google.com/forum/#!forum/wxpython-users also available as http://news.gmane.org/gmane.comp.python.wxpython -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Understanding help command description syntax - explanation needed
On 2014-11-06 04:05, Gene Heskett wrote: On Wednesday 05 November 2014 21:52:42 Mark Lawrence did opine And Gene did reply: On 06/11/2014 02:37, Dave Angel wrote: Chris Angelico ros...@gmail.com Wrote in message: On Thu, Nov 6, 2014 at 2:56 AM, Larry Martell larry.mart...@gmail.com wrote: And I don't think Larry was actually offended; it's just that some questions don't really have easy answers - imagine someone asking a great mathematician But how do you KNOW that 2 + 2 is 4? Where's it written down?... all he can say is It is. Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not a programmer, but I want to write code and I need someone to tell me how. Gets to you after a while. Too true. Those same people are unlikely to go to a gathering of civil engineers and say I'm no expert, but I want to build a bridge and I need someone to tell me how, yet somehow it's expected to be possible with software. ChrisA Or I'm no expert but I need someone to show me how; build me one here in my front yard. Against a requirements specification that changes on a daily basis, I want it delivered yesterday and no you can't have any more resources to help out, so don't ask :) With, or without a toll booth and operator? Both, make it configurable. In fact, make the length configurable too, in case I want to use it across another river. -- https://mail.python.org/mailman/listinfo/python-list
Re: wxPython Boxsizers
I am using Python 2.7.6 Here is the code I am trying: import wx class MyFrame(wx.Frame): def __init__(self, *args, **kid's): wx.Frame.__init__(self, *args, **kwds) self.button_1 = wx.Button(self, wx.ID_ANY, button_1) self.button_2 = wx.Button(self, wx.ID_ANY, button_2) sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer_1.Add(self.button_1, 0, wx.ALL | wx.ALIGN_RIGHT, 1) sizer_1.Add(self.button_2, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM, 1) self.SetSizer(sizer_1) sizer_1.Fit(self) self.Layout() if __name__ == __main__: app = wx.PySimpleApp(0) frame_1 = MyFrame(None, wx.ID_ANY, ) frame_1.Show() app.MainLoop() Thanks. On Thursday, November 6, 2014 4:01:53 PM UTC+5:30, Joel Goldstick wrote: On Thu, Nov 6, 2014 at 5:13 AM, Jaydip Chakrabarty c.joyd...@gmail.com wrote: Hello, I am new to Python. I am learning boxsizer. I want to put two buttons on my panel. One at top right corner and one at bottom right corner. How do I achieve this? Thanks First, what version of python. What is boxsizer? Show some code of what you have tried. -- https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.4.2 + PyQt4 + PyCharm 3.4.1
On Saturday, November 1, 2014 3:11:54 PM UTC+3:30, Juan Christian wrote: No one here uses PyCharm and Qt? =/ On Wed, Oct 29, 2014 at 8:45 PM, Juan Christian juan0ch...@gmail.com wrote: It only occurs whule using PyCharm I tried it via pure terminal and everything works... =/ On Tue, Oct 28, 2014 at 7:45 PM, Juan Christian juan0ch...@gmail.com wrote: Python 3.4.2 Windows x64 PyQt4 4.11.2 Py3.4 Qt4.8.6 (x64) PyCharm 3.4.1 Pro Edition So, PyCharm works 100% with everything here but PyQt. I have this folder structure: Disk C: PyQt4 Lib/site-packages/PyQt4/(tons of files here) Python34 (normal/default installation) --- I tried copying the 'PyQt4' folder to my 'Python34/Lib/site-packages' folder but when I try to code something Qt related on PyCharm I get this issue: Some skeletons failed to generate: 19 modules failed in 1 interpreter. Details... Failed modules Python 3.4.2 PyQt4.QAxContainer PyQt4.Qsci PyQt4.QtCore PyQt4.QtDeclarative PyQt4.QtDesigner PyQt4.QtGui PyQt4.QtHelp PyQt4.QtMultimedia PyQt4.QtNetwork PyQt4.QtOpenGL PyQt4.QtScript PyQt4.QtScriptTools PyQt4.QtSql PyQt4.QtSvg PyQt4.QtTest PyQt4.QtWebKit PyQt4.QtXml PyQt4.QtXmlPatterns PyQt4.phonon Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available. And PyCharm tells me that my 'import PyQt4.ANYTHING_HERE import *' has 'Unresolved references'. --- When I try to install the PyQt4 via the installer, in the default location (C:/Python34) I get an even 'worse' error, whenever PyCharm try to update the skeletons or something like that (that is, whenever I open a file there...), I get tons and tons of the same error, 'Error while accessing memory at address ', and 'python.exe' stops working. i have this problem too, and it's so annoying. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.4.2 + PyQt4 + PyCharm 3.4.1
Resolved, kinda. Just use PySide instead of PyQt. Remove everything PyQt related from PyCharm and install PySide using the PyCharm plugins window. PySide has access to all modules and packages that PyQt has, but now you need to import like from PySide.** import *. On Thu, Nov 6, 2014 at 12:50 farshad akbari akbari.fars...@gmail.com wrote: On Saturday, November 1, 2014 3:11:54 PM UTC+3:30, Juan Christian wrote: No one here uses PyCharm and Qt? =/ On Wed, Oct 29, 2014 at 8:45 PM, Juan Christian juan0ch...@gmail.com wrote: It only occurs whule using PyCharm I tried it via pure terminal and everything works... =/ On Tue, Oct 28, 2014 at 7:45 PM, Juan Christian juan0ch...@gmail.com wrote: Python 3.4.2 Windows x64 PyQt4 4.11.2 Py3.4 Qt4.8.6 (x64) PyCharm 3.4.1 Pro Edition So, PyCharm works 100% with everything here but PyQt. I have this folder structure: Disk C: PyQt4 Lib/site-packages/PyQt4/(tons of files here) Python34 (normal/default installation) --- I tried copying the 'PyQt4' folder to my 'Python34/Lib/site-packages' folder but when I try to code something Qt related on PyCharm I get this issue: Some skeletons failed to generate: 19 modules failed in 1 interpreter. Details... Failed modules Python 3.4.2 PyQt4.QAxContainer PyQt4.Qsci PyQt4.QtCore PyQt4.QtDeclarative PyQt4.QtDesigner PyQt4.QtGui PyQt4.QtHelp PyQt4.QtMultimedia PyQt4.QtNetwork PyQt4.QtOpenGL PyQt4.QtScript PyQt4.QtScriptTools PyQt4.QtSql PyQt4.QtSvg PyQt4.QtTest PyQt4.QtWebKit PyQt4.QtXml PyQt4.QtXmlPatterns PyQt4.phonon Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available. And PyCharm tells me that my 'import PyQt4.ANYTHING_HERE import *' has 'Unresolved references'. --- When I try to install the PyQt4 via the installer, in the default location (C:/Python34) I get an even 'worse' error, whenever PyCharm try to update the skeletons or something like that (that is, whenever I open a file there...), I get tons and tons of the same error, 'Error while accessing memory at address ', and 'python.exe' stops working. i have this problem too, and it's so annoying. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?
On Nov 5, 2014, at 6:14 PM, Clayton Kirkwood c...@godblessthe.us wrote: Yeah, the 11 was mesmerizing. You didn't need no stinkin' program to see how busy the system was, you just checked the lights. You could really tell when somebody was compiling or link/loading. As I've done many times since those days, I am amazed how many users could be using the system simultaneously (yes, general editing, but still...) and it wasn't a quick machine by any stretch. We had a whopping 384K memory and big multi-platter disks with a whopping 65MB. Still think in terms of PIP sometimes… And TECO. . . Clayton -- https://mail.python.org/mailman/listinfo/python-list
Python has arrived!
According to http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots: Attacks occur in two phases. Hackers first infect a targeted machine via simple malware that installs Python onto the device, [...] -- Grant Edwards grant.b.edwardsYow! I always have fun at because I'm out of my gmail.commind!!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Real-world use of Counter
On Nov 6, 2014 1:06 AM, Rustom Mody rustompm...@gmail.com wrote: In studying (somewhat theoretically) the general world of collection data structures we see - sets -- neither order nor repetition - bags -- no order, repetition significant - lists -- both order and repetition Sometimes 'bag' is called 'multiset' However counter is a weird non-standard name that overloads an already overloaded term -- 'Counter' has a very standard meaning in programming and in hardware design. Bag is also nonstandard. Other nonstandard names for the same type include list, heap, bunch, sample, weighted set, occurrence set and fireset. Knuth uses multiset, so let's stick with that. As for Counter already having meanings in CS, the Python Counter is compatible with those. Calling a bag as counter is inappropriate for an analogous reason to why calling a dictionary as a 'hash' is inappropriate -- it confuses an implementation detail for fundamental semantics. I've never liked the term bag. In addition to being nonstandard it's also very nonintuitive. Multiset is fine, except that it implies the collection is a type of set, which the Python Counter is not. The name Counter describes the intended use case, not the implementation, so I think it's fine. -- https://mail.python.org/mailman/listinfo/python-list
help with creating dict from string
hi, I have strings coming in with this format: '[one=two, three=four five, six, seven=eight]' and I want to create from that string, this dictionary: {'one':'two', 'three':'four five', 'six':True, 'seven':'eight'} These are option strings, with each key-value pair separated by commas. Where there is a value, the key-value pair is separated by '='. This is how I started (where s is the string): s = s.replace('[','').replace(']','') s = [x.split('=') for x in s.split(',')] [['one', 'two'], [' three', 'four five'], [' six'], [' seven', 'eight']] I know I can iterate and strip each item, fixing single-element keys as I go. I just wondered if I'm missing something more elegant. If it wasn't for the leading spaces and the boolean key, the dict() constructor would have been sweet. thanks for any ideas, --Tim -- https://mail.python.org/mailman/listinfo/python-list
Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?
On Tuesday, 4 November 2014 16:49:36 UTC, françai s wrote: I intend to write in lowest level of computer programming as a hobby. It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code? What is the lowest level of programming computers that you can write ? Is binary code? Is hex code? Is another machine code? Honestly do not know if it is true that there is another machine code beyond the binary and hex code. Is Assembly? If you want a really brilliant (and simple) book about the process of designing, structuring and building programs in assembly language, I'd recommend finding a copy of a book called A Programmer's Notebook written by David M Cortesi. The context is out of date (8080/Z-80 assembly programs for CP/M), but the overall structure of each chapter is brilliant: the development of decent designs, followed by a discussion of possible approaches to programming, followed by a detailed discussion of the development of the assembly language, and finally a final assembly code listing. One advantage of this book is that the 8080/Z-80 instruction set and the interface to CP/M are both relatively simple to grasp (compared with modern CPUs and modern OSs). That said, the lessons from this book translate to any assembly programming task. Good luck. -- https://mail.python.org/mailman/listinfo/python-list
Re: help with creating dict from string
Tim wrote: hi, I have strings coming in with this format: '[one=two, three=four five, six, seven=eight]' and I want to create from that string, this dictionary: {'one':'two', 'three':'four five', 'six':True, 'seven':'eight'} These are option strings, with each key-value pair separated by commas. Where there is a value, the key-value pair is separated by '='. This is how I started (where s is the string): s = s.replace('[','').replace(']','') s = [x.split('=') for x in s.split(',')] [['one', 'two'], [' three', 'four five'], [' six'], [' seven', [['eight']] I know I can iterate and strip each item, fixing single-element keys as I go. I just wondered if I'm missing something more elegant. If it wasn't for the leading spaces and the boolean key, the dict() constructor would have been sweet. Not everything has to be a one-liner ;) If it works I don't think something s = '[one=two, three=four five, six, seven=eight]' def fix(pair): ... key, eq, value = pair.partition(=) ... return key.strip(), value if eq else True ... dict(fix(t) for t in s.strip([]).split(,)) {'three': 'four five', 'seven': 'eight', 'one': 'two', 'six': True} is particularly inelegant. Are you sure that your grammar is not more complex than your example, e. g. that , cannot occur in the values? -- https://mail.python.org/mailman/listinfo/python-list
Re: help with creating dict from string
On Thursday, November 6, 2014 12:41:10 PM UTC-5, Peter Otten wrote: Tim wrote: hi, I have strings coming in with this format: '[one=two, three=four five, six, seven=eight]' and I want to create from that string, this dictionary: {'one':'two', 'three':'four five', 'six':True, 'seven':'eight'} snip Not everything has to be a one-liner ;) If it works I don't think something s = '[one=two, three=four five, six, seven=eight]' def fix(pair): ... key, eq, value = pair.partition(=) ... return key.strip(), value if eq else True ... dict(fix(t) for t in s.strip([]).split(,)) {'three': 'four five', 'seven': 'eight', 'one': 'two', 'six': True} is particularly inelegant. Are you sure that your grammar is not more complex than your example, e. g. that , cannot occur in the values? hi Peter, I definitely wouldn't say that is inelegant :-) I had never used the partition method and I didn't realize (or maybe remember) that strip could take a string of characters, not just one. Oh yes, I am positive about the grammar--no commas are allowed in the values. I think your solution is pretty elegant. Thanks for your help! --Tim -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] Dinamically set __call__ method
On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote: If you really absolutely positively have to have the signature be correct for each instance, you may to either look at a function creating factory, a class creating factory, or a meta-class. +1. Overriding __call__() within the class definition, over and over again, with different function, looks awkward to me. -- https://mail.python.org/mailman/listinfo/python-list
Re: help with creating dict from string
On Thursday, November 6, 2014 12:41:10 PM UTC-5, Peter Otten wrote: Tim wrote: hi, I have strings coming in with this format: '[one=two, three=four five, six, seven=eight]' and I want to create from that string, this dictionary: {'one':'two', 'three':'four five', 'six':True, 'seven':'eight'} snip Not everything has to be a one-liner ;) If it works I don't think something s = '[one=two, three=four five, six, seven=eight]' def fix(pair): ... key, eq, value = pair.partition(=) ... return key.strip(), value if eq else True ... dict(fix(t) for t in s.strip([]).split(,)) {'three': 'four five', 'seven': 'eight', 'one': 'two', 'six': True} is particularly inelegant. Are you sure that your grammar is not more complex than your example, e. g. that , cannot occur in the values? hi Peter, I definitely wouldn't say that is inelegant :-) I had never used the partition method and I didn't realize (or maybe remember) that strip could take a string of characters, not just one. Oh yes, I am positive about the grammar--no commas are allowed in the values. I think your solution is pretty elegant. Thanks for your help! --Tim -- This is a very clever solution. I just came across the need for something similar. Good question, excellent solution. Thank you!-- https://mail.python.org/mailman/listinfo/python-list
Re: I need algorithm for my task
Probably homework, you are a good man ! -- https://mail.python.org/mailman/listinfo/python-list
Re: Python has arrived!
Grant Edwards invalid@invalid.invalid wrote: According to http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots: Attacks occur in two phases. Hackers first infect a targeted machine via simple malware that installs Python onto the device, [...] A virus that runs on Python. It had to happen sooner or later. -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] Dinamically set __call__ method
Roberto Martínez wrote: Yikes, I didn't realize the difference in inheritance. The thing with this is tricky. I need the change in the instance, not in the class, because I have multiple instances and all of them must have different implementations of __call__. The workaround of calling a different method inside __call__ is not valid for my case because I want to change the *signature* of the function also -for introspection reasons. This is somewhat of a code smell. It's a bit whiffy, which doesn't *necessarily* mean it is off, only that it could be. You should think hard about your use-case and consider alternative strategies. Like, the strategy design pattern :-) The real problem here is that the individual functions have different signatures. If they had the same signature, then you could bake that into the __call__ method and simply call a per-instance method: class X: # Variation on the strategy design pattern. def __call__(self, spam, eggs=12): method = getattr(self, 'my_custom_method', None) if method is None: # Default behaviour. ... else: return method(self, spam, eggs) Then simply add a `my_custom_method` function to the individual instances. The different functions would provide different algorithms (implementations) for the same task, with the same interface. This is exactly the problem with the Strategy design pattern is supposed to solve. But the smelly part here is that your custom functions take different signatures, which suggests that they aren't providing different algorithms for the same task. Different signatures means that they are *not* interchangeable, that they have different calling conventions and presumably do different things: # This only works in Python 2 with classic (old-style) classes a, b, c = [X() for i in range(3)] a.__call__ = lambda self: self.spam + 1 b.__call__ = lambda self, x, y: (self.eggs or x)*y c.__call__ = lambda self, value: setattr(self, spam, value) That's a strong violation of the expectation that any two instances of the same class should be more or less interchangeable, with at most a few exceptional cases (e.g. you can't swap the int instance 0 for the instance 2 in the expression x/2). But it's not *always* wrong, functions themselves are all instances of FunctionType, and every instance does something different when called. E.g. while you could swap math.sin for math.cos, since both take the same parameters, you cannot swap math.sin for len. Nevertheless, I urge you strongly to think hard about what problem you are really trying to solve. Dynamically override __call__ is just a means to an end. Perhaps there is something less magically you can do to solve the problem? Is there some way to ensure that all the instances have the same interface? This might be easy, given that they can store per-instance state. If instance a needs an extra parameter that other instances don't, perhaps it can take it from an instance attribute instead of an argument. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python has arrived!
On Nov 6, 2014 10:47 PM, Sturla Molden sturla.mol...@gmail.com wrote: Grant Edwards invalid@invalid.invalid wrote: According to http://www.theregister.co.uk/2014/11/06/hackers_use_gmail_drafts_as_dead_drops_to_control_malware_bots : Attacks occur in two phases. Hackers first infect a targeted machine via simple malware that installs Python onto the device, [...] A virus that runs on Python. It had to happen sooner or later. It's not a Python virus. The infection vector can be anything. The interesting part is that they're using browser automation to open a real-time, encrypted, virtually undetectable and untraceable channel to the malware over a port (443) that is frequently used and very rarely blocked, via a host (gmail.com) that is also frequently used and rarely blocked (and there would likely be plenty of alternatives to choose from if it were), and without needing to create any sort of server on the target machine. The fact that Python is involved is incidental. -- https://mail.python.org/mailman/listinfo/python-list
Re: Real-world use of Counter
On Nov 6, 2014 10:51 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Nov 6, 2014 1:06 AM, Rustom Mody rustompm...@gmail.com wrote: Calling a bag as counter is inappropriate for an analogous reason to why calling a dictionary as a 'hash' is inappropriate -- it confuses an implementation detail for fundamental semantics. I've never liked the term bag. In addition to being nonstandard it's also very nonintuitive. Multiset is fine, except that it implies the collection is a type of set, which the Python Counter is not. I was thinking about this today, and it seems to me that the Python Counter is not really even a multiset. * The size of a multiset would be the count of all the elements; the len of a Counter is only the number of keys. * The multiplicity of an element in a multiset is restricted to the natural numbers; the count of an element in a Counter can be any integer, even negative. * In a Counter, a key with a count of 0 is a distinct state from a key not being present at all; in the latter case the element is not in the Counter, while in the former case it *is* in the Counter. These states are also distinct for the purpose of equality. -- https://mail.python.org/mailman/listinfo/python-list
Re: Understanding help command description syntax - explanation needed
Chris Angelico wrote: On Wed, Nov 5, 2014 at 11:31 PM, Ivan Evstegneev webmailgro...@gmail.com wrote: That's what I'm talking about (asking actually), where do you know it from? I know it because I've been a programmer for 39 years. I didn't intend to offence anyone here. Just asked a questions ^_^ Don't worry about offending people. Even if you do annoy one or two, there'll be plenty of us who know to be patient :) And I don't think Larry was actually offended; it's just that some questions don't really have easy answers - imagine someone asking a great mathematician But how do you KNOW that 2 + 2 is 4? Where's it written down?... all he can say is It is. An ordinary mathematician will say: Hold up two fingers. Count them, and you get one, two. Now hold up another two fingers. Count them, and you will get two again. Hold them together, count the lot, and you get one, two, three, four. Therefore, 2+2 = 4. A good mathematician might start with the empty set, ∅ = {}. [Aside: if the symbol looks like a small box, try changing your font -- it is supposed to be a circle with a slash through it. Lucinda Typewriter has the glyph for '\N{EMPTY SET}'.] That empty set represents zero. Take the set of all empty sets, {∅} = {{}}, which represents one. Now we know how to count: after any number, represented by some set, the *next* number is represented by the simplest set containing the previous set. Having defined counting, the good mathematician can define addition, and go on to prove that 2+2 = 4. This is, essentially, a proof of Peano Arithmetic (PA), which one can take as effectively the basic arithmetic of counting fingers, sheep or sticks. But a *great* mathematician will say, Hmmm, actually, we don't *know* that 2+2 equals 4, because we cannot prove that arithmetic is absolutely consistent. If arithmetic is not consistent, then we might simultaneously prove that 2+2 = 4 and 2+2 ≠ 4, which is unlikely but not inconceivable. Fields medallist Vladimir Voevodsky is a great mathematician, and he apparently believes that the consistency of Peano Arithmetic is still an open question. http://m-phi.blogspot.com.au/2011/05/voevodsky-consistency-of-pa-is-open.html Another way to look at this, not necessarily Voevodsky's approach, is to note that the existing proofs of PA's consistency are *relative* proofs of PA. E.g. they rely on the consistency of some other formal system, such as the Zermelo-Frankel axioms (ZF). If ZF is consistent, so is PA, but we don't know that ZF is consistent... -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Understanding help command description syntax - explanation needed
On Fri, Nov 7, 2014 at 4:47 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: But a *great* mathematician will say, Hmmm, actually, we don't *know* that 2+2 equals 4, because we cannot prove that arithmetic is absolutely consistent. If arithmetic is not consistent, then we might simultaneously prove that 2+2 = 4 and 2+2 ≠ 4, which is unlikely but not inconceivable. And the mother of a young child will say It just is. Now eat your greens. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Understanding help command description syntax - explanation needed
在 2014年11月5日星期三UTC+8下午8时17分11秒,larry@gmail.com写道: On Wed, Nov 5, 2014 at 7:13 AM, Ivan Evstegneev webmailgro...@gmail.com wrote: Firtst of all thanks for reply. brackets [] means that the argument is optional. That's what I'm talking about (asking actually), where do you know it from? I know it because I've been a programmer for 39 years. that's awesome!! -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] Dinamically set __call__ method
John Ladasky john_lada...@sbcglobal.net writes: On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote: If you really absolutely positively have to have the signature be correct for each instance, you may to either look at a function creating factory, a class creating factory, or a meta-class. +1. Overriding __call__() within the class definition, over and over again, with different function, looks awkward to me. A possibility to get the original approach implemented looks like: make __call__ a descriptor on the class which looks up the real method on the instance. -- https://mail.python.org/mailman/listinfo/python-list
[issue22735] Fix various crashes exposed through mro() customization
Antoine Pitrou added the comment: I think forbidding reentrancy would indeed be a good idea. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22735 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22789] Compress the marshalled data in PYC files
Antoine Pitrou added the comment: FWIW, I personally doubt this would actually reduce startup time. Disk I/O cost is in the first access, not in the transfer size (unless we're talking hundreds of megabytes). But in any case, someone interested has to do measurements :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22789 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20220] TarFile.list() outputs wrong time
Serhiy Storchaka added the comment: May be issue6478 is related. -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20220 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22804] Can't run Idle in Windows 8 or windows 64
New submission from nx u: Hi, I have just downloaded and installed python34. When I run the short cut IDLE python gui nothing happens ( I think a command window appears briefly - not sure as this happens so quickly). My machine runs windows 8 and 64 bit version of . I did the same on a windows 7 64 bit machine and double clicking the Python IDLE gui 32 bit doesn't work. Not quite sure what's going on. Our machines are located in a school with GPOs controlling access and security. I am from the ICT support team. There isn't much reported on this issue on the internet either except a couple of entries in stackoverflow. But the solutions offered are far off the mark. Please help. The documentation on the Python web site is not clear or not detailed enough to diagnose the fault. -- components: IDLE messages: 230732 nosy: nx.u priority: normal severity: normal status: open title: Can't run Idle in Windows 8 or windows 64 versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22804 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19102] Add tests for CLI of the tabnanny module
Serhiy Storchaka added the comment: Added comments on Rietveld. Although tabnanny is located in the Lib directory, not in the Tools directory, technically it is a script. May be move test_tabnanny.py to Lib/test/test_tools? -- assignee: - berker.peksag nosy: +serhiy.storchaka type: - enhancement versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19102 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7559] TestLoader.loadTestsFromName swallows import errors
Robert Collins added the comment: Its backported in unittest2 0.8.0 which is available on pypi for 2.6+ and 3.2+. The changes are large enough that I'd hesitate to backport them in cPython itself. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7559 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22804] Can't run Idle in Windows 8 or windows 64
Amaury Forgeot d'Arc added the comment: You can try to run IDLE from a command prompt. Type the command: path_to_python34.exe -m idlelib and look at error messages. -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22804 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15500] Python should support naming threads
Kovid Goyal added the comment: Just FYI, a pure python2 implementation that monkey patches Thread.start() to set the OS level thread name intelligently. import ctypes, ctypes.util, threading libpthread_path = ctypes.util.find_library(pthread) if libpthread_path: libpthread = ctypes.CDLL(libpthread_path) if hasattr(libpthread, pthread_setname_np): pthread_setname_np = libpthread.pthread_setname_np pthread_setname_np.argtypes = [ctypes.c_void_p, ctypes.c_char_p] pthread_setname_np.restype = ctypes.c_int orig_start = threading.Thread.start def new_start(self): orig_start(self) try: name = self.name if not name or name.startswith('Thread-'): name = self.__class__.__name__ if name == 'Thread': name = self.name if name: if isinstance(name, unicode): name = name.encode('ascii', 'replace') ident = getattr(self, ident, None) if ident is not None: pthread_setname_np(ident, name[:15]) except Exception: pass # Don't care about failure to set name threading.Thread.start = new_start -- nosy: +kovid ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15500 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20289] Make cgi.FieldStorage a context manager
Serhiy Storchaka added the comment: Added comments on Rietveld. -- nosy: +serhiy.storchaka type: behavior - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20289 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21579] Python 3.4: tempfile.close attribute does not work
Serhiy Storchaka added the comment: If it is possible to cancel the effect of the O_TEMPORARY flag, we can use it to implement this feature on all platforms. But if it is not possible, we have several options: 1. Just close this issue and do nothing more. This was undocumented and non-portable feature. 2. Implement delete as readonly property. This is similar to 1 but makes the failure loud. 3. Implement this feature on non-Windows, document that it is non-Windows only feature, and raise an exception in delete setter on Windows. 4. Same as 3, but emit deprecation warning in delete setter on non-Windows. In future this should be replaced with solution 2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21579 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22650] set up and use VM for net access in the test suite
Roundup Robot added the comment: New changeset 39536b377241 by Georg Brandl in branch '3.4': #22650: test suite: load Unicode test data files from www.pythontest.net https://hg.python.org/cpython/rev/39536b377241 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22650 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21579] Python 3.4: tempfile.close attribute does not work
Serhiy Storchaka added the comment: See also issue14243. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21579 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types
Serhiy Storchaka added the comment: I've posted to python-list and python-dev. I'll report back here the findings, if any. http://comments.gmane.org/gmane.comp.python.devel/150073 -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22766 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19094] urljoin should raise a TypeError if URL is not a string
Serhiy Storchaka added the comment: About acceptable behavior with wrong arguments types see discussions in issue22766 and http://comments.gmane.org/gmane.comp.python.devel/150073 . -- nosy: +serhiy.storchaka versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19094 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22650] set up and use VM for net access in the test suite
Roundup Robot added the comment: New changeset 0af36ea1d010 by Georg Brandl in branch '2.7': #22650: test suite: load Unicode test data files from www.pythontest.net https://hg.python.org/cpython/rev/0af36ea1d010 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22650 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20220] TarFile.list() outputs wrong time
Antoine Pitrou added the comment: May be issue6478 is related. I'm not sure. issue6478 looks like a Python stdlib bug, while this issue looks like a libc problem. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20220 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20220] TarFile.list() outputs wrong time
Antoine Pitrou added the comment: David, could you try the patch in msg230703 and see if it fixes the problem on your buildbot? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20220 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20220] TarFile.list() outputs wrong time
David Edelsohn added the comment: Unfortunately, the patch does not fix the failures of running test_imaplib before test_tarfile or test_datetime. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20220 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22805] Having pythontest.net index.html link to hg repo
New submission from Brett Cannon: For pythontest.net, it would be nice if the index.html page that is (supposed to be) served linked to the hg repo to make it more discoverable how to add files to the domain. -- assignee: brett.cannon messages: 230747 nosy: brett.cannon priority: low severity: normal stage: needs patch status: open title: Having pythontest.net index.html link to hg repo type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22805 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22806] regrtest: add switch -c to run only modified tests
New submission from Georg Brandl: A quick way to select only tests that are modified in the checkout. -- components: Tests files: regrtest_changed.diff keywords: patch messages: 230748 nosy: georg.brandl, pitrou priority: normal severity: normal status: open title: regrtest: add switch -c to run only modified tests type: enhancement versions: Python 3.4, Python 3.5 Added file: http://bugs.python.org/file37138/regrtest_changed.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22806 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types
Jim Jewett added the comment: I wish there were an APIMismatchError superclass to unify (AttributeError, TypeError). But the wart probably isn't enough to justify the surgery. On Thu, Nov 6, 2014 at 8:48 AM, Serhiy Storchaka rep...@bugs.python.org wrote: Serhiy Storchaka added the comment: I've posted to python-list and python-dev. I'll report back here the findings, if any. http://comments.gmane.org/gmane.comp.python.devel/150073 -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22766 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22766 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22806] regrtest: add switch -c to run only modified tests
Serhiy Storchaka added the comment: Unfortunately this doesn't work with tests for pickle, json or tkinter. I'm afraid this feature would make false promise. Without careful check you can not be confident that all modified tests are selected. If you going to add this switch, it should emit a * * * LOUD WARNING * * * and enumerate all modified files containing 'test' in its path which are not recognized as valid test name. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22806 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22806] regrtest: add switch -c to run only modified tests
Antoine Pitrou added the comment: I agree this is more dangerous than useful. (even if you haven't modified a test it may still be impacted by some other change) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22806 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22806] regrtest: add switch -c to run only modified tests
Georg Brandl added the comment: Well, this is not meant as a comprehensive run ALL impacted tests because that is impossible in general :) An alternate suggestion would be to allow filenames like Lib/test/test_foo.py as arguments to regrtest. Then I could run without the switch using .../regrtest.py `hg status -amn` -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22806 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16353] add function to os module for getting path to default shell
Matt Frank added the comment: In msg174930 Christian Heimes (christian.heimes) wrote: I've tested confstr(CS_PATH) on Linux, Mac OS X, Solaris, HP-UX and BSD. It works and the path to `sh` is always included. In msg230713 Ned Deily(ned.deily) wrote: ignore Lib/macpath.py. [...] OS X uses Lib/posixpath.py. These two messages have convinced me that the correct approach is to kick the can down the road. I will file a new issue and patch to fix os.defpath (by initializing os.defpath by calling confstr(CS_PATH)). Then I will file a new issue and patch that will define a reasonable os.confstr() for platforms where HAVE_CONFSTR is not defined. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16353 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)
Matthias Klose added the comment: steve, please can we keep this issue open until this is forwarded and accepted upstream? -- nosy: +doko resolution: fixed - remind status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20160 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22806] regrtest: add switch -c to run only modified tests
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22806 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16353] add function to os module for getting path to default shell
Matt Frank added the comment: In msg230720 Akira Li (akira) wrote: os.defpath is supposed to be ':'+CS_PATH, e.g., look at glibc (C library used on Linux) sysdeps/posix/spawni.c I don't know whether it is possible to change CS_PATH without recompiling every statically linked executable on a system, sysdeps/unix/confstr.h: #define CS_PATH /bin:/usr/bin Though this issue is about the path to the standard shell sh/cmd.exe. It is not about os.defpath. I understand this issue is about the path to the standard shell. My argument is that os.defpath is the wrong tool for finding that path, and os.confstr('CS_PATH') is the correct tool, as you originally suggested in msg224514. The patch [1] has tests. Have you tried to run them? The tests *pass* at least on one system ;) [...] os.get_shell_executable() does not use cwd. Neither the documentation nor the code in the patch suggest that. I ran the tests (and the entire Python test suite) before I wrote my first message. But you didn't test what happens when there is a bogus 'sh' somewhere along the path. You also have a bug in your path searching loop that interprets an empty element on the path as /. Here's the current failure mode: Go to root on your Posix system. With su or sudo create an executable file named sh. (for example cd /; sudo touch sh; sudo chmod +x sh). Then go back to your python interpreter (with the patch applied) and run os.get_shell_executable(). The returned result will be '/sh'. The loop _should_ be treating empty path elements as current working directory. (In the glibc sysdeps/posix/spawni.c file you pointed to look around line 281, by the comment that says /* Two adjacent colons, or a colon at the beginning or the end of 'PATH' means to search the current directory.*/) But if you fix the loop to iterate over the path correctly (including 'cwd') then you will find that putting an executable named 'sh' in the current working directory will make os.get_shell_executable() return the sh in the current working directory (because os.defpath says it should). Note also, that glibc's spawni() uses two different default paths. One is for if the user didn't specify their PATH variable (that's the one where they use :/bin:/usr/bin) and a completely different (built in path is used in the spawn*p* version) if it turns out that the file is a script that needs to run under the system sh. (On line 290 they call maybe_script_execute(), which calls script_execute(), which uses _PATH_BSHELL.) os.defpath is the default search path used by exec*p* and spawn*p* i.e., if os.defpath is incorrect for these system then os.exec*p* and os.spawn*p* functions could also be broken. I'll look into it. I don't remember exactly the motivation to use os.defpath instead of os.confstr('CS_PATH'). The motivation was in msg224514. You wrote: In the absense of os.confstr('CS_PATH') on Android (msg175006), os.defpath seems appropriate than os.environ['PATH'] to expand 'sh' basename to the full path to be used by subprocess later. But os.defpath doesn't work on Android either (because it is hardcoded to ':/bin:/usr/bin'). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16353 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22789] Compress the marshalled data in PYC files
Stefan Behnel added the comment: FWIW, LZ4HC compression sounds like an obvious choice for write-once-read-many data like .pyc files to me. Blosc shows that you can achieve a pretty major performance improvement just by stuffing more data into less space (although it does it for RAM and CPU cache, not disk). And even if it ends up not being substantially faster for the specific case of .pyc files, there is really no reason why they should take more space on disk than necessary, so it's a sure win in any case. -- nosy: +scoder ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22789 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16255] subrocess.Popen needs /bin/sh but Android only has /system/bin/sh
Matt Frank added the comment: Assuming issue16353 is fixed using http://bugs.python.org/file36196/os.get_shell_executable.patch the appropriate way to find the path to the default shell is by calling os.get_shell_executable(). This is the 1-liner patch that uses os.get_shell_executable() in Popen() instead of the hard-coded string /bin/sh. -- keywords: +patch Added file: http://bugs.python.org/file37139/popen-no-hardcode-bin-sh.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16255 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22796] Support for httponly/secure cookies reintroduced lax parsing behavior
Tim Graham added the comment: Django's test suite doesn't reveal any regressions. All the changes there are expected as far as I can see. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22796 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22807] uuid.uuid1() should use uuid_generate_time_safe() if available
New submission from Barry A. Warsaw: I'm classifying this as a security issue, since using uuid_generate_time() -- i.e. the not _safe() variety -- does return collisions in real world cases that we've seen, and those could have security implications. However, I don't know that this can be exploited in any real world cases, so I'm not making it private or sending to security@. The basic problem is that uuid.uuid1() uses uuid_generate_time(3), but if the synchronization methods used in that C function's manpage are not used, then two concurrent processes can -- and do in our cases -- return the same UUID. I would propose that if uuid_generate_time_safe() is available, this should be used instead, and the return value should be checked to see if a safe method was used. If not, then uuid1() should fall back to the pure-Python approach. -- components: Library (Lib) keywords: security_issue messages: 230759 nosy: barry priority: normal severity: normal status: open title: uuid.uuid1() should use uuid_generate_time_safe() if available versions: Python 2.7, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22807 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22807] uuid.uuid1() should use uuid_generate_time_safe() if available
Alex Gaynor added the comment: FWIW, I'm not convinced the pure python fallback code is sufficient either; time.time() doesn't have the necessary resolution AFAIK? Also clock_seq is generated using the random module's messerne twister, not SystemRandom(). -- nosy: +alex ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22807 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16353] add function to os module for getting path to default shell
Akira Li added the comment: Matt Frank added the comment: In msg230720 Akira Li (akira) wrote: os.defpath is supposed to be ':'+CS_PATH, e.g., look at glibc (C library used on Linux) sysdeps/posix/spawni.c I don't know whether it is possible to change CS_PATH without recompiling every statically linked executable on a system, sysdeps/unix/confstr.h: #define CS_PATH /bin:/usr/bin Though this issue is about the path to the standard shell sh/cmd.exe. It is not about os.defpath. I understand this issue is about the path to the standard shell. My argument is that os.defpath is the wrong tool for finding that path, and os.confstr('CS_PATH') is the correct tool, as you originally suggested in msg224514. I'll repeat os.defpath definition that I've cited in the same message msg224514: The default search path used by exec*p* and spawn*p* if the environment doesn’t have a 'PATH' key. Also available via os.path. 1. os.defpath should work (contain the path to the standard shell) everywhere where os.confstr(CS_PATH) works. 2. And it might be easier to customize e.g., on systems where there is no os.confstr or where changing CS_PATH involves recompiling crucial system processes. If these two statements are not true then os.defpath could be dropped. The patch [1] has tests. Have you tried to run them? The tests *pass* at least on one system ;) [...] os.get_shell_executable() does not use cwd. Neither the documentation nor the code in the patch suggest that. I ran the tests (and the entire Python test suite) before I wrote my first message. But you didn't test what happens when there is a bogus 'sh' somewhere along the path. You also have a bug in your path searching loop that interprets an empty element on the path as /. Here's the current failure mode: Go to root on your Posix system. With su or sudo create an executable file named sh. (for example cd /; sudo touch sh; sudo chmod +x sh). Then go back to your python interpreter (with the patch applied) and run os.get_shell_executable(). The returned result will be '/sh'. But if you fix the loop to iterate over the path correctly (including 'cwd') then you will find that putting an executable named 'sh' in the current working directory will make os.get_shell_executable() return the sh in the current working directory (because os.defpath says it should). Comment in the patch explicitly says that '' is interpreted as '/'. The intent is to exclude the current working directory, thinking that /sh executable can create only root. And root can do anything to the machine anyway. I agree. It is a misfeature. I've uploaded a new patch that excludes '' completely. The previous code tried to be too cute. The loop _should_ be treating empty path elements as current working directory. (In the glibc sysdeps/posix/spawni.c file you pointed to look around line 281, by the comment that says /* Two adjacent colons, or a colon at the beginning or the end of 'PATH' means to search the current directory.*/) yes. Empty path element stands for the current working directory e.g., $ PATH= python $ PATH=: python $ PATH=:/ python $ PATH=/: python run ./python on my system. The current working directory is intentionally excluded (in the original and in the current patches) otherwise os.get_exec_path(env={}) would be used. Note also, that glibc's spawni() uses two different default paths. One is for if the user didn't specify their PATH variable (that's the one where they use :/bin:/usr/bin) and a completely different (built in path is used in the spawn*p* version) if it turns out that the file is a script that needs to run under the system sh. (On line 290 they call maybe_script_execute(), which calls script_execute(), which uses _PATH_BSHELL.) glibc hardcodes the path (like subprocess module does currently): #define _PATH_BSHELL/bin/sh os.get_shell_executable() is an enhancement that allows (Unix) systems to configure the path via os.defpath. But os.defpath doesn't work on Android either (because it is hardcoded to ':/bin:/usr/bin'). As I've mentioned in msg224514 before posting my original patch: - Andriod uses /system/bin/sh - os.defpath could be tweaked on Android i.e., yes. Default os.defpath doesn't work there and it should be configured on Android to include the path to the standard shell. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16353 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16353] add function to os module for getting path to default shell
Changes by Akira Li 4kir4...@gmail.com: Added file: http://bugs.python.org/file37140/os.get_shell_executable-3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16353 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22807] uuid.uuid1() should use uuid_generate_time_safe() if available
Barry A. Warsaw added the comment: On Nov 06, 2014, at 08:10 PM, Alex Gaynor wrote: FWIW, I'm not convinced the pure python fallback code is sufficient either; time.time() doesn't have the necessary resolution AFAIK? Also clock_seq is generated using the random module's messerne twister, not SystemRandom(). Perhaps, but that's a different bug. ;) -snip snip- from uuid import UUID import ctypes import ctypes.util lib = ctypes.CDLL(ctypes.util.find_library('uuid')) _ugts = lib.uuid_generate_time_safe _buffer = ctypes.create_string_buffer(16) retval = _ugts(_buffer) # Remember, this is C! is_safe = (retval == 0) print('{} is safe? {}'.format(UUID(bytes=_buffer.raw), is_safe)) -snip snip- On Ubuntu 14.10, gives me: ---- is safe? True -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22807 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)
Steve Dower added the comment: Upstream as in libffi? I'm fairly sure they've fixed it already, but their current code bears little relation to what we have, so it's not easy to tell and I didn't look all that closely. Who's doing the forwarding? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20160 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22808] Typo in asyncio-eventloop.rst, time() link is wrong
New submission from Mark Grandi: In the asyncio documentation, specifically asyncio-eventloop.rst, in the description for BaseEventLoop.call_at(), it has: Arrange for the *callback* to be called at the given absolute timestamp *when* (an int or float), using the same time reference as :meth:`time`. This links to the time module's time.time() method, which is incorrect as well as confusing, as the event loop's clock is NOT the same as time.time(), and it even says so on the top of the 'delayed calls' section According the python documentation guide, it should have a period before it to make it refer to a method that is within the same module. I however decided to change it to `BaseEventLoop.time()`, because when i see the text 'time()', even if it links to the right method, still makes me think of time.time(), which is again confusing and generally incorrect. Attached is a patch file, its a trivial change, but i did regenerate the docs and confirmed that it works, and clicking the link takes you to the right method in the page. -- assignee: docs@python components: Documentation files: markgrandi_asyncio-eventloop.rst.patch keywords: patch messages: 230764 nosy: docs@python, markgrandi priority: normal severity: normal status: open title: Typo in asyncio-eventloop.rst, time() link is wrong type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file37141/markgrandi_asyncio-eventloop.rst.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22808 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22809] Include/graminit.h and Python/graminit.c always rebuilt (breaks cross builds)
New submission from Matt Frank: changeset 92496:c2a53aa27cad (issue22359) broke cross builds. (Now make touch; make always tries to rebuild Include/graminit.h and Python/graminit.c by running pgen. But pgen is a host executable and won't run on the build machine during a cross-build.) I think the problem is here, around Makefile.pre.in line 750. The dependency was on PGENSRCS and is now on PGEN. Will changing it back to PGENSRCS break something else? @@ -745,15 +746,13 @@ $(IO_OBJS): $(IO_H) -$(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS) +$(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGEN) -- components: Build, Cross-Build messages: 230765 nosy: WanderingLogic priority: normal severity: normal status: open title: Include/graminit.h and Python/graminit.c always rebuilt (breaks cross builds) versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22809 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22359] Remove incorrect uses of recursive make
Matt Frank added the comment: Sorry, I'm complaining. Cross builds broke. Please see issue22809. -- nosy: +WanderingLogic ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22359 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22786] Message could not be delivered
Changes by Ezio Melotti ezio.melo...@gmail.com: -- resolution: - not a bug stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22786 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22809] Include/graminit.h and Python/graminit.c always rebuilt (breaks cross builds)
Georg Brandl added the comment: Duplicate of #22625. -- nosy: +georg.brandl resolution: - duplicate status: open - closed superseder: - When cross-compiling, don’t try to execute binaries ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22809 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22636] avoid using a shell in ctypes.util: replace os.popen with subprocess
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22636 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22810] tkinter: alloc: invalid block: after askopenfilename
New submission from lccat: After running the Tkinter file dialog ( tkinter.filedialog.askopenfilename() ), and closing the tkinter window the following error message is displayed: alloc: invalid block: 0xb035e0: b0 0 To reproduce see the attached python script tktest. This does not stop the program as far as i can see. Also happens for the directory selector. Platform is linux. -- components: Tkinter files: tktest.py messages: 230768 nosy: lccat priority: normal severity: normal status: open title: tkinter: alloc: invalid block: after askopenfilename versions: Python 3.4 Added file: http://bugs.python.org/file37142/tktest.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22810 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22808] Typo in asyncio-eventloop.rst, time() link is wrong
Changes by Berker Peksag berker.pek...@gmail.com: -- components: +asyncio nosy: +gvanrossum, haypo, yselivanov stage: - patch review versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22808 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22808] Typo in asyncio-eventloop.rst, time() link is wrong
Guido van Rossum added the comment: LG, can someone commit this? Should be backported to the 3.4 docs as well. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22808 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22807] uuid.uuid1() should use uuid_generate_time_safe() if available
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22807 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22811] _top_level_dir state leaks on defaultTestLoader
New submission from Robert Collins: TestProgram uses defaultTestLoader to load tests. Calling discover() on a TestLoader sets _top_level_dir. Calling discover with no top_level_dir implictly sets _top_level_dir but only the first time: the second time it is called with a different start_dir the prior one is used. This leads to errors like: == ERROR: test_run_list_failed_import (testtools.tests.test_run.TestRun) testtools.tests.test_run.TestRun.test_run_list_failed_import -- _StringException: Traceback (most recent call last): File /home/robertc/personal/testtools/testtools/tests/test_run.py, line 175, in test_run_list_failed_import run.main, ['prog', 'discover', '-l', broken.package.base, '*.py'], out) File /home/robertc/personal/testtools/testtools/testcase.py, line 420, in assertRaises self.assertThat(our_callable, matcher) File /home/robertc/personal/testtools/testtools/testcase.py, line 431, in assertThat mismatch_error = self._matchHelper(matchee, matcher, message, verbose) File /home/robertc/personal/testtools/testtools/testcase.py, line 481, in _matchHelper mismatch = matcher.match(matchee) File /home/robertc/personal/testtools/testtools/matchers/_exception.py, line 108, in match mismatch = self.exception_matcher.match(exc_info) File /home/robertc/personal/testtools/testtools/matchers/_higherorder.py, line 62, in match mismatch = matcher.match(matchee) File /home/robertc/personal/testtools/testtools/testcase.py, line 412, in match reraise(*matchee) File /home/robertc/personal/testtools/testtools/matchers/_exception.py, line 101, in match result = matchee() File /home/robertc/personal/testtools/testtools/testcase.py, line 965, in __call__ return self._callable_object(*self._args, **self._kwargs) File /home/robertc/personal/testtools/testtools/run.py, line 413, in main stdout=stdout) File /home/robertc/personal/testtools/testtools/run.py, line 208, in __init__ self.parseArgs(argv) File /home/robertc/personal/testtools/testtools/run.py, line 252, in parseArgs self._do_discovery(argv[2:]) File /home/robertc/personal/testtools/testtools/run.py, line 368, in _do_discovery loaded = loader.discover(self.start, self.pattern, self.top) File /home/robertc/.virtualenvs/testtools-2.7/local/lib/python2.7/site-packages/unittest2/loader.py, line 353, in discover raise ImportError('Start directory is not importable: %r' % start_dir) ImportError: Start directory is not importable: '/tmp/tmpac4uwI' When a test tries to test the behaviour of TestProgram (or a subclass thereof). The fix is straight forward: at the end of discover restore the value of _top_level_dir that it had at entry. -- messages: 230770 nosy: rbcollins priority: normal severity: normal status: open title: _top_level_dir state leaks on defaultTestLoader ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22811 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22811] _top_level_dir state leaks on defaultTestLoader
Changes by Robert Collins robe...@robertcollins.net: -- components: +Library (Lib) versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22811 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com