ANN: fancycompleter 0.2
Hi, fancycompleter 0.2 has been released. http://bitbucket.org/antocuni/fancycompleter/src From the README: fancycompleter is a module to improve your experience in Python by adding TAB completion to the interactive prompt. It is an extension of the stdlib's rlcompleter module. Features: * its best feature is that the completions are displayed in different colors, depending on their type. * To save space on screen, fancycompleter only shows the characters after the dot. * If we press ``TAB`` at the beginning of the line, a real tab character is inserted, instead of trying to complete. This is useful when typing function bodies or multi-line statements at the prompt. * Unlike rlcompleter, fancycompleter **does** complete expressions containing dictionary or list indexing. For example, ``mydict['foo'].TAB`` works (assuming that mydict is a dictionary and that it contains the key 'foo', of course :-)). * Starting from Python 2.6, is the completed name is a callable, rlcompleter automatically adds an open parenthesis ``(``. This is annoying in case we do not want to really call it, so fancycompleter disable this behaviour. Enjoy, Antonio Cuni -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Glob in python which supports the ** wildcard
On 22 November 2010 21:43, Martin Lundberg martin.lundb...@gmail.com wrote: Hi, I want to be able to let the user enter paths like this: apps/name/**/*.js and then find all the matching files in apps/name and all its subdirectories. However I found out that Python's glob function doesn't support the recursive ** wildcard. Is there any 3rd party glob function which do support **? This does roughly what you want: http://code.activestate.com/recipes/499305-locating-files-throughout-a-directory-tree/ -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list
Re: Glob in python which supports the ** wildcard
On 23 November 2010 09:26, Martin Lundberg martin.lundb...@gmail.com wrote: It does not seem to support the ** wildcard? It will recursively seek for files matching a pattern like *.js but it won't support /var/name/**/*.js as root, will it? I did say roughly. ;-) You'd need to do: for filename in locate(*.js, /var/name/): print filename Adding support for ** is left as an exercise for the reader. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading bz2 file into numpy array
Nobody wrote: On Mon, 22 Nov 2010 11:37:22 +0100, Peter Otten wrote: is there a convenient way to read bz2 files into a numpy array? Try f = bz2.BZ2File(filename) data = numpy.fromstring(f.read(), numpy.float32) That's going to hurt if the file is large. Yes, but memory usage will peak at about 2*sizeof(data), and most scripts need more data than just a single numpy.array. In short: the OP is unlikely to run into the problem. You might be better off either extracting to a temporary file, or creating a pipe with numpy.fromfile() reading the pipe and either a thread or subprocess decompressing the data into the pipe. I like to keep it simple, so if available RAM turns out to be the limiting factor I think extracting the data into a temporary file is a good backup plan. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursively __getattribute__
On 22 nov, 21:44, Roman Dolgiy tost...@gmail.com wrote: http://stackoverflow.com/questions/4247036/python-recursively-getattr... I need to support a lot of legacy code, with THC4k's approach I'll have to modify project's existing code to use obj.attr1.val instead of obj.attr1 but this is not suitable. You should probably re-read THC4k's answer. His code works just fine AFAICT: # the proxy maps attribute access to another object class GetattrProxy(object): def __init__(self, proxied, prefix=None): self.proxied = proxied self.prefix = prefix def __getattr__(self, key): attr = (key if self.prefix is None else self.prefix + '__' + key) try: # if the proxied object has the attr return it return getattr(self.proxied, attr) except AttributeError: # else just return another proxy return GetattrProxy(self.proxied, attr) # the thing you want to wrap class Target(object): attr1__attr2__attr3 = 5 attr2 = attr2 t = Target() proxy = GetattrProxy(t) print proxy.attr1.attr2.attr3 : '%s' % proxy.attr1.attr2.attr3 print proxy.attr2 : '%s' % proxy.attr2 -- http://mail.python.org/mailman/listinfo/python-list
Making module content available in parent module
Hi! Note up front: I'm using Python2.6 still, I guess with 2.7 test discovery, I could get better results easier, right? Now, my problem is I have a directory containing test scripts which I all want to run. I used to run them individually and manually, but want to avoid this overhead in the future. tests/ foo.py # defines TestFoo1 and TestFoo2 bar.py # defines TestBar1 and TestBar2 What I would like to do now is this: from tests import * unittest.main() In other words, import all test files and run them. This does import them, but it turns out that I end up with modules foo and bar, and the unittests inside those are not found. Am I approaching the test loading the wrong way? Cheers! Uli PS: I've been trying a few things here, and stumbled across another thing that could provide a solution. I can from tests import *, but then all these modules will pollute my namespace. I can import tests, but then neither of the submodules will be in tests. I tried import tests.*, but that doesn't work. Is there no way to import a whole package but with its namespace? -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list
Re: Making module content available in parent module
Hi, On Tue, 23 Nov 2010 11:36:05 +0100 Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Now, my problem is I have a directory containing test scripts which I all want to run. I used to run them individually and manually, but want to avoid this overhead in the future. tests/ foo.py # defines TestFoo1 and TestFoo2 bar.py # defines TestBar1 and TestBar2 Nose does what you want: http://packages.python.org/nose/ -- Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: Making module content available in parent module
On Tue, 23 Nov 2010 11:36:05 +0100, Ulrich Eckhardt wrote: tests/ foo.py # defines TestFoo1 and TestFoo2 bar.py # defines TestBar1 and TestBar2 What I would like to do now is this: from tests import * unittest.main() In other words, import all test files and run them. This does import them, but it turns out that I end up with modules foo and bar, and the unittests inside those are not found. Given the directory structure you show, I find that hard to believe. You should get an ImportError, as there is no module or package called tests. But suppose you turn tests into a proper package: tests/ __init__.py foo.py bar.py You could have __init__.py include these lines: from foo import * from bar import * Then later, when you do this: from tests import * it will pick up everything from foo and bar, and unittest.main() should run those tests as well. I think. Or you could just do: for module in (foo, bar): try: unittest.main(module) except SystemExit: pass PS: I've been trying a few things here, and stumbled across another thing that could provide a solution. I can from tests import *, but then all these modules will pollute my namespace. I can import tests, but then neither of the submodules will be in tests. I tried import tests.*, but that doesn't work. Is there no way to import a whole package but with its namespace? The package needs to know what submodules to make available. Put inside __init__.py: import foo import bar and then from outside the package, do this: import tests Now tests.foo and tests.bar will exist. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: unittests with different parameters
On Nov 22, 11:38 am, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Hi! I'm writing tests and I'm wondering how to achieve a few things most elegantly with Python's unittest module. Let's say I have two flags invert X and invert Y. Now, for testing these, I would write one test for each combination. What I have in the test case is something like this: def test_invert_flags(self): test flags to invert coordinates tests = [((10, 20), INVERT_NONE, (10, 20)), ((10, 20), INVERT_X, (-10, 20)), ((10, 20), INVERT_Y, (10, -20))] for input, flags, expected in tests: res = do_invert(input, flags) self.assertEqual(res, expected, %s caused wrong results % (flags,)) So, what I do that I test the function 'do_invert' for different input combinations and verify the result. The ugly thing is that this will abort the whole test if one of the tests in the loop fails. So, my question is how do I avoid this? I know that I could write a common test function instead: def _test_invert_flags(self, input, flags, expected): res = do_invert(input, flags) self.assertEqual(res, expected) def test_invert_flags_non(self): test not inverting coordinates self._test_invert_flags((10, 20), INVERT_NONE, (10, 20)) def test_invert_flags_x(self): test inverting X coordinates self._test_invert_flags((10, 20), INVERT_X, (-10, 20)) def test_invert_flags_y(self): test inverting Y coordinates self._test_invert_flags((10, 20), INVERT_Y, (10, -20)) What I don't like here is that this is unnecessarily verbose and that it basically repeats information. Also, I'd rather construct the error message from the data instead of maintaining it in different places, because manually keeping those in sync is another, errorprone burden. Any suggestions? Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 The following is a bit ghastly, I'm not sure I'd recommend it, but if you are determined, you could try dynamically adding test methods to the test class. The following is untested - I suspect I have made a schoolboy error in attempting to make methods out of functions - but something like it might work: class MyTestClass(unittest.TestCase): pass testdata = [ (INPUTS, EXPECTED), (INPUTS, EXPECTED), (INPUTS, EXPECTED), ] for index, (input, expected) in enumerate(testdata): # the following sets an attribute on MyTestClass # the names of the attributes are 'test_1', 'test_2', etc # the value of the attributes is a test method that performs the assert setattr( MyTestClass, 'test_%d' % (index,), lambda s: s.assertEquals(METHOD_UNDER_TEST(*input), expected) ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Need advices regarding the strings (str, unicode, coding) used as interface for an external library.
Thanks for the reply. Subject closed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursively __getattribute__
Thanks to Andreas Waldenburger, THC4k (http://stackoverflow.com/ questions/4247036/python-recursively-getattribute) and others for their tips. I was able to find solution: class Null(object): def __repr__(self): return Null def __str__(self): return '' def __nonzero__(self): return False class ResultAttrFactory(type): _cache = {} @classmethod def prepare(cls, base, result): dict_ = ResultAttr.__dict__.copy() dict_.update({ '_ResultAttr__base': base, '_ResultAttr__result': result}) return ('ResultAttr', (base,), dict_) def __new__(cls, base, result): if (base, result) in cls._cache: type_ = cls._cache[(base, result)] else: type_ = super(ResultAttrFactory, cls).__new__( cls, *cls.prepare(base, result)) cls._cache[(base, result)] = type_ return type_ def __init__(cls, base, result): pass class ResultAttr: Should be used only with ResultAttrFactory @staticmethod def __new__(cls, arg1, name): return cls.__base.__new__(cls, arg1) def __init__(self, arg1, name): self.__name = name super(self.__class__, self).__init__(arg1) def get_result_attr(self, name): if self.__result.is_denorm_attr(name): attr = getattr(self.__result, name, None) else: attr = getattr(self.__result, name) return attr def __getattr__(self, name): lookup_name = %s__%s % (self.__name, name) attr = self.get_result_attr(lookup_name) if type(attr).__name__ == 'ResultAttr': type_ = attr.__base elif attr is None: type_ = Null else: type_ = type(attr) result_attr = ResultAttrFactory( type_, self.__result)(attr, lookup_name) return result_attr class BaseResult(object): class Result(BaseResult): ... def __init__(self, *args, **kwargs): ... self.x = 35 ... self.y = 5 ... self.y__a = 3 ... self.y__b = 'hello' ... self.y__c__x = [1, 2, 3] ... super(Result, self, *args, **kwargs) r = Result() r.x 35 type(r.x) type 'int' r.y 5 type(r.y) # doctest:+ELLIPSIS class 'ResultAttr' r.y.a 3 r.y.b 'hello' r.y.c # Is there any way to raise AtrributeError here? Null r.y.d Traceback (most recent call last): AttributeError: 'Result' object has no attribute 'y__d' r.y.c.x [1, 2, 3] def is_denorm_attr(self, name): return bool([k for k in self.__dict__.keys() if %s__ % name in k]) def __getattribute__(self, name): attr = super(BaseResult, self).__getattribute__(name) if name in ('__dict__', 'is_denorm_attr'): return attr if self.is_denorm_attr(name): return ResultAttrFactory(type(attr), self)(attr, name) else: return attr if __name__ == '__main__': import doctest doctest.testmod() https://gist.github.com/710977 The only problem is: r.y.c Null Is there any way to raise AtrributeError here? Also is there any negative side effects of such method? -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On Nov 22, 5:12 pm, Raffael Cavallaro raffaelcavall...@pas.despam.s.il.vous.plait.mac.com wrote: On 2010-11-22 11:25:34 -0500, scattered said: And you don't think that [JH] could write a book about Haskell if he honestly came to think that it were a superior all-aroung language? Until he actually does, he has a financial interest in trash-talking Haskell. This makes anything he says about Haskell suspect. The fact that he *didn't* mindlessly reject [musical note lang] in favor of [Irish Ship Of The Desert] when [musical note lang] came out (despite the fact that at the time his company was deeply (exclusively?) invested in [Irish Ship Of The Desert] and arguably had a vested interest in having [musical note lang] fail to gain support) suggests that he is able to fairly evaluate the merits of other languages. No, it suggests that he saw that supporting the Irish Ship Of The Desert meant going up against Microsoft, so he jumped to the MS supported variant of the Donut Dromedary. You miss the fundamental point; having a financial interest in the outcome of a debate makes anything that person says an advertisement for his financial interests, not a fair assessment. There is a well-known name for such illogical reasoning: ad hominem. When a person poses an /argument/, nothing personal outside of the /argument/ is relevant. Thus, your claim that anything that person says ... is not only obvious hyperbole it is also illogical. It is a common refuge of those who cannot support their position with fact and logic. On more than one occasion Jon Harrop has all but crushed Ertugrul in this very forum with /source code/; that is as objective as it gets. KHD -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On 2010-11-23 10:08:12 -0500, Keith H Duggar said: There is a well-known name for such illogical reasoning: ad hominem. You don't understand ad hominem: The ad hominem is a classic logical fallacy,[2] but it is not always fallacious. For in some instances, questions of personal conduct, character, motives, etc., are legitimate and relevant to the issue.[3] Source: http://en.wikipedia.org/wiki/Ad_hominem Sometimes the person's conduct and motives *are relevant* to the point under discussion. Financial conflict of interest is a perfect example where it *is* legitimate and relevant to explore a person's motives and conduct outside of the debate. In this case, JH's conduct outside of the debate (i.e., the fact that he earns his living by selling tools and training for a particular set of languages) and his motives (i.e., he is therefore financially motivated to present these languages in the best possible light and to trash-talk other languages), render his arguments in the debate inherently suspect. warmest regards, Ralph -- Raffael Cavallaro -- http://mail.python.org/mailman/listinfo/python-list
Re: Making module content available in parent module
Steven D'Aprano wrote: On Tue, 23 Nov 2010 11:36:05 +0100, Ulrich Eckhardt wrote: PS: I've been trying a few things here, and stumbled across another thing that could provide a solution. I can from tests import *, but then all these modules will pollute my namespace. I can import tests, but then neither of the submodules will be in tests. I tried import tests.*, but that doesn't work. Is there no way to import a whole package but with its namespace? The package needs to know what submodules to make available. Put inside __init__.py: import foo import bar and then from outside the package, do this: import tests Now tests.foo and tests.bar will exist. I've been reading up on packages, but I didn't find anything like that in the documentation, all I found was the meaning of __all__. If I import the modules explicitly there, there's no need to define __all__, unless there are some I don't want to import there, right? Well, I'll try it and see. ;) Steven, thank you for this explanation! Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On Nov 23, 10:34 am, Raffael Cavallaro raffaelcavall...@pas.despam.s.il.vous.plait.mac.com wrote: On 2010-11-23 10:08:12 -0500, Keith H Duggar said: On Nov 22, 5:12 pm, Raffael Cavallaro raffaelcavall...@pas.despam.s.il.vous.plait.mac.com wrote: On 2010-11-22 11:25:34 -0500, scattered said: And you don't think that [JH] could write a book about Haskell if he honestly came to think that it were a superior all-aroung language? Until he actually does, he has a financial interest in trash-talking Haskell. This makes anything he says about Haskell suspect. The fact that he *didn't* mindlessly reject [musical note lang] in favor of [Irish Ship Of The Desert] when [musical note lang] came out (despite the fact that at the time his company was deeply (exclusively?) invested in [Irish Ship Of The Desert] and arguably had a vested interest in having [musical note lang] fail to gain support) suggests that he is able to fairly evaluate the merits of other languages. No, it suggests that he saw that supporting the Irish Ship Of The Desert meant going up against Microsoft, so he jumped to the MS supported variant of the Donut Dromedary. You miss the fundamental point; having a financial interest in the outcome of a debate makes anything that person says an advertisement for his financial interests, not a fair assessment. There is a well-known name for such illogical reasoning: ad hominem. When a person poses an /argument/, nothing personal outside of the /argument/ is relevant. Thus, your claim that anything that person says ... is not only obvious hyperbole it is also illogical. It is a common refuge of those who cannot support their position with fact and logic. On more than one occasion Jon Harrop has all but crushed Ertugrul in this very forum with /source code/; that is as objective as it gets. You don't understand ad hominem: The ad hominem is a classic logical fallacy,[2] but it is not always fallacious. For in some instances, questions of personal conduct, character, motives, etc., are legitimate and relevant to the issue.[3] Source: http://en.wikipedia.org/wiki/Ad_hominem Sometimes the person's conduct and motives *are relevant* to the point under discussion. Financial conflict of interest is a perfect example where it *is* legitimate and relevant to explore a person's motives and conduct outside of the debate. In this case, JH's conduct outside of the debate (i.e., the fact that he earns his living by selling tools and training for a particular set of languages) and his motives (i.e., he is therefore financially motivated to present these languages in the best possible light and to trash-talk other languages), render his arguments in the debate inherently suspect. You don't understand the implications of your own words: having a financial interest in the outcome of a debate makes anything that person says an advertisement for his financial interests, not a fair assessment. is substantially different from render his arguments in the debate inherently suspect. Do you understand how? Hint, see my comment regarding hyperbole and also consider the relationship between the qualifier anything and universal quantification. I think if you think a bit more carefully you will come to see how your original statement was indeed fallacious ad hominem. (And that specific example remains so regardless of which common approach to informal logic you take ie whether you choose one that is more or less sympathetic to ad hominem in general.) KHD -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On Tue, 23 Nov 2010 10:34:22 -0500 Raffael Cavallaro raffaelcavall...@pas.despam.s.il.vous.plait.mac.com wrote: On 2010-11-23 10:08:12 -0500, Keith H Duggar said: There is a well-known name for such illogical reasoning: ad hominem. You don't understand ad hominem: Perhaps you don't understand it. The ad hominem is a classic logical fallacy,[2] but it is not always fallacious. For in some instances, questions of personal conduct, character, motives, etc., are legitimate and relevant to the issue.[3] So, explain how motive makes the logic wrong in this case then. In this case, JH's conduct outside of the debate (i.e., the fact that he earns his living by selling tools and training for a particular set of languages) and his motives (i.e., he is therefore financially motivated to present these languages in the best possible light and to trash-talk other languages), render his arguments in the debate inherently suspect. Fine. Suspect his arguments to the point that you examine them closely and then explain what you found erroneous in them. Don't just claim that we should dismiss them because of who made them. You know, it's just possible that Jon actually investigated Haskell before choosing to focus on CL. That would make his opinion carry more weight, not less. Remind me, how is this relevant to Python? -- 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. -- http://mail.python.org/mailman/listinfo/python-list
Time and date operation
Hi everyone, Could you anybody shed lights to me? Say I have two dics. cstart defaultdict(type 'int', {15424: ['Dec', '6', '18:57:40'], 552: ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: ['Dec', '7', '13:14:47'], 18291: ['Dec', '6', '21:01:17'], 18969: ['Dec', '7', '14:28:42'], 18937: ['Dec', '7', '14:21:34']}) ccompl defaultdict(type 'int', {15424: ['Dec', '6', '19:42:55'], 18291: ['Dec', '6', '21:01:28'], 15500: ['Dec', '6', '20:26:03'], 18863: ['Dec', '7', '13:24:07']}) and I need to calculate the difference time if the key value is the same in both dics. thanks in advance Huisky -- http://mail.python.org/mailman/listinfo/python-list
Re: Time and date operation
On Tue, Nov 23, 2010 at 9:47 AM, huisky hui...@gmail.com wrote: Hi everyone, Could you anybody shed lights to me? Say I have two dics. cstart defaultdict(type 'int', {15424: ['Dec', '6', '18:57:40'], 552: ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: ['Dec', '7', '13:14:47'], 18291: ['Dec', '6', '21:01:17'], 18969: ['Dec', '7', '14:28:42'], 18937: ['Dec', '7', '14:21:34']}) ccompl defaultdict(type 'int', {15424: ['Dec', '6', '19:42:55'], 18291: ['Dec', '6', '21:01:28'], 15500: ['Dec', '6', '20:26:03'], 18863: ['Dec', '7', '13:24:07']}) and I need to calculate the difference time if the key value is the same in both dics. Create datetime.datetime objects. Subtract one from another and you'll get a datetime.timedelta object representing the difference between them. The fine manual: http://docs.python.org/library/datetime.html#datetime-objects Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Time and date operation
-Original Message- From: c...@rebertia.com [mailto: c...@rebertia.com] Sent: 2010年11月23日 19:12 To: huisky Cc: python-list@python.org Subject: Re: Time and date operation On Tue, Nov 23, 2010 at 9:47 AM, huisky hui...@gmail.com wrote: Hi everyone, Could you anybody shed lights to me? Say I have two dics. cstart defaultdict(type 'int', {15424: ['Dec', '6', '18:57:40'], 552: ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: ['Dec', '7', '13:14:47'], 18291: ['Dec', '6', '21:01:17'], 18969: ['Dec', '7', '14:28:42'], 18937: ['Dec', '7', '14:21:34']}) ccompl defaultdict(type 'int', {15424: ['Dec', '6', '19:42:55'], 18291: ['Dec', '6', '21:01:28'], 15500: ['Dec', '6', '20:26:03'], 18863: ['Dec', '7', '13:24:07']}) and I need to calculate the difference time if the key value is the same in both dics. Create datetime.datetime objects. Subtract one from another and you'll get a datetime.timedelta object representing the difference between them. The fine manual: http://docs.python.org/library/datetime.html#datetime-objects On Tue, Nov 23, 2010 at 10:42 AM, Huisky hui...@gmail.com wrote: Hi, Thanks. I'm wondering is datetime.datetime objects able to read 'Dec', for example? Yes. Use the %b format directive when calling datetime.datetime.strptime(). http://docs.python.org/library/datetime.html#datetime.datetime.strptime http://docs.python.org/library/time.html#time.strftime Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Subprocess Call works on Windows, but not Ubuntu
I ran into an interesting problem trying to spawn a subprocess, so I thought I'd ask if the experts could explain it to me. I'm spawning a subprocess to run pdf2txt.py, which is a tool that is distributed with PDFminer to do moderately advanced text-dumps of PDFs. Yet when I run the same code on my two dev machines - one Win XP, the other Ubuntu 10.04 or 10.10 - it only works on the former and not the later. And its not terribly complicated code. # Code Start sp_line = 'python pdf2txt.py -p 1 -o %s %s' % ('temp.out', pdf_filename) print sp_line sp = subprocess.Popen(sp_line) sp.wait() with open('temp.out', 'r') as pdf_handle: #Do stuff to read the file The output from the print statements reads: python pdf2txt.py -p 1 -o temp.out Aarts et al (2009).pdf That command works on both systems when copied directly to the command-line, and the python script it is a part of works on the Windows machine, but I can't the script to work on Ubuntu for the life of me. What am I missing? /b/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess Call works on Windows, but not Ubuntu
On Tue, Nov 23, 2010 at 11:28 AM, Brett Bowman bnbow...@gmail.com wrote: I ran into an interesting problem trying to spawn a subprocess, so I thought I'd ask if the experts could explain it to me. I'm spawning a subprocess to run pdf2txt.py, which is a tool that is distributed with PDFminer to do moderately advanced text-dumps of PDFs. Yet when I run the same code on my two dev machines - one Win XP, the other Ubuntu 10.04 or 10.10 - it only works on the former and not the later. And its not terribly complicated code. # Code Start sp_line = 'python pdf2txt.py -p 1 -o %s %s' % ('temp.out', pdf_filename) print sp_line sp = subprocess.Popen(sp_line) snip python pdf2txt.py -p 1 -o temp.out Aarts et al (2009).pdf That command works on both systems when copied directly to the command-line, and the python script it is a part of works on the Windows machine, but I can't the script to work on Ubuntu for the life of me. What am I missing? Quoting the docs (for the Nth time; emphasis added): On Unix, with shell=False (default): args should normally be a sequence. ***If a string is specified for args***, it will be used as the name or path of the program to execute; ***this will only work if the program is being given no arguments.*** http://docs.python.org/library/subprocess.html#subprocess.Popen Fixed version: sp_args = ['python', 'pdf2txt.py', '-p', '1', '-o', 'temp.out', pdf_filename] sp = subprocess.Popen(sp_args) Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Collect output to string
Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Thanks. -- Burton Samograd -- http://mail.python.org/mailman/listinfo/python-list
Re: Collect output to string
On Tue, Nov 23, 2010 at 11:53 AM, Burton Samograd bur...@userful.com wrote: Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Rebind sys.stdout to a StringIO object. http://docs.python.org/library/sys.html#sys.stdout http://docs.python.org/library/stringio.html Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess Call works on Windows, but not Ubuntu
Ah, that fixed it. Thank you. On Tue, Nov 23, 2010 at 11:37 AM, Chris Rebert c...@rebertia.com wrote: On Tue, Nov 23, 2010 at 11:28 AM, Brett Bowman bnbow...@gmail.com wrote: I ran into an interesting problem trying to spawn a subprocess, so I thought I'd ask if the experts could explain it to me. I'm spawning a subprocess to run pdf2txt.py, which is a tool that is distributed with PDFminer to do moderately advanced text-dumps of PDFs. Yet when I run the same code on my two dev machines - one Win XP, the other Ubuntu 10.04 or 10.10 - it only works on the former and not the later. And its not terribly complicated code. # Code Start sp_line = 'python pdf2txt.py -p 1 -o %s %s' % ('temp.out', pdf_filename) print sp_line sp = subprocess.Popen(sp_line) snip python pdf2txt.py -p 1 -o temp.out Aarts et al (2009).pdf That command works on both systems when copied directly to the command-line, and the python script it is a part of works on the Windows machine, but I can't the script to work on Ubuntu for the life of me. What am I missing? Quoting the docs (for the Nth time; emphasis added): On Unix, with shell=False (default): args should normally be a sequence. ***If a string is specified for args***, it will be used as the name or path of the program to execute; ***this will only work if the program is being given no arguments.*** http://docs.python.org/library/subprocess.html#subprocess.Popen Fixed version: sp_args = ['python', 'pdf2txt.py', '-p', '1', '-o', 'temp.out', pdf_filename] sp = subprocess.Popen(sp_args) Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Collect output to string
Chris Rebert c...@rebertia.com writes: On Tue, Nov 23, 2010 at 11:53 AM, Burton Samograd bur...@userful.com wrote: Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Rebind sys.stdout to a StringIO object. http://docs.python.org/library/sys.html#sys.stdout http://docs.python.org/library/stringio.html Thanks for the tip. Here's my function: def with_output_to_string(f, args): oldstdout = sys.stdout buffer = StringIO.StringIO() sys.stdout = buffer apply(f, args) sys.stdout = oldstdout return buffer.getvalue() Any way I could improve it? -- Burton Samograd -- http://mail.python.org/mailman/listinfo/python-list
Re: Collect output to string
On 23/11/2010 20:59, Burton Samograd wrote: Chris Rebertc...@rebertia.com writes: On Tue, Nov 23, 2010 at 11:53 AM, Burton Samogradbur...@userful.com wrote: Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Rebind sys.stdout to a StringIO object. http://docs.python.org/library/sys.html#sys.stdout http://docs.python.org/library/stringio.html Thanks for the tip. Here's my function: def with_output_to_string(f, args): oldstdout = sys.stdout buffer = StringIO.StringIO() sys.stdout = buffer apply(f, args) sys.stdout = oldstdout return buffer.getvalue() Any way I could improve it? Use a try...finally block in an exception occurs: try: apply(f, args) finally: sys.stdout = oldstdout and possibly also replace the older: apply(f, args) with the newer: f(*args) You might also want to handle keyword arguments. -- http://mail.python.org/mailman/listinfo/python-list
progamming approach review, child processes
So I have not done much with child processes before. I have an input of programs to be updated, a child process that does the compiles and links (with a log output to an individual file), and a process wait at the end. Except the child process can hang (at the moment, the problem that might show up is: waiting for input). At which point a convenience becomes a hinderance. As it happens the idea of doing the compiles in parallel is supported by the ports system I am working with. So I thought I could avoid the wait syntax, do a lot of children, save all the process hmm I am not sure what to call the pointers, and after a while interrogate the process information to see if all the children got done. At some point, I could think a child is hung and maybe do some useful reporting. Realize that this might be the next day because the compiles might take a while. Is this a reasonable approach? Thank you for your consideration. Possibly pointless information: openbsd 4.8 workstation, packages, but using the port system, want only to compile packages I have installed. There is a utility to tell me which packages are out of date. And I really know I could use pkg_add -u. I did some attachments of the programs, but I suppose they will get scrubbed.. python is I think 2.6.5? -- http://mail.python.org/mailman/listinfo/python-list
Re: Collect output to string
On Nov 23, 1:59 pm, Burton Samograd bur...@userful.com wrote: Thanks for the tip. Here's my function: def with_output_to_string(f, args): oldstdout = sys.stdout buffer = StringIO.StringIO() sys.stdout = buffer apply(f, args) sys.stdout = oldstdout return buffer.getvalue() Any way I could improve it? You should wrap the inner function call in a try-finally call to ensure that the old stdout gets restored even if f raises an exception. Also, the `apply` function is deprecated. Use `f(*args)` instead. The function as a whole would be a bit more Pythonic if written as a decorator IMO, but that's your call. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Collect output to string
On Tue, Nov 23, 2010 at 1:15 PM, Ian ian.g.ke...@gmail.com wrote: On Nov 23, 1:59 pm, Burton Samograd bur...@userful.com wrote: Thanks for the tip. Here's my function: def with_output_to_string(f, args): oldstdout = sys.stdout buffer = StringIO.StringIO() sys.stdout = buffer apply(f, args) sys.stdout = oldstdout return buffer.getvalue() Any way I could improve it? You should wrap the inner function call in a try-finally call to ensure that the old stdout gets restored even if f raises an exception. Also, the `apply` function is deprecated. Use `f(*args)` instead. The function as a whole would be a bit more Pythonic if written as a decorator IMO, but that's your call. A context manager could also be worth considering. http://docs.python.org/library/stdtypes.html#context-manager-types Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Collect output to string
On 11/23/2010 3:02 PM, Chris Rebert wrote: On Tue, Nov 23, 2010 at 11:53 AM, Burton Samogradbur...@userful.com wrote: Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Rebind sys.stdout to a StringIO object. http://docs.python.org/library/sys.html#sys.stdout http://docs.python.org/library/stringio.html If you are using print or print(), you can redirect output to the StringIO object with sfile or file=sfile. I use the latter in a custom test function where I normally want output to the screen but occasionally want to capture test reports. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
Keith H Duggar dug...@alum.mit.edu wrote: It is a common refuge of those who cannot support their position with fact and logic. On more than one occasion Jon Harrop has all but crushed Ertugrul in this very forum with /source code/; that is as objective as it gets. Since Jon has financial reasons to invest time doing this and I don't, this is nowhere near crushing or objective. It's simply meaningless. If someone pays me for writing proof code or coming up with challenges, then I will, and I assure you, I would give him a hard time, since I'm an experienced Haskell programmer, who uses it for many different, practical purposes in the real world outside of academia. And I stated explicitly many times that (without being paid) I don't feel like wasting time proving my point to Jon, who would just come up with new arbitrary arguments and challenges anyway, as he does all the time. Jon doesn't and cannot acknowledge valid arguments, so it would be an ongoing, pointless cycle. After all, he was the only one posing stupid challenges on me at all, deliberately constructing problems to be easy to solve in his languages. When I would challenge him, the picture would change, but I think, this is stupid and infantile enough not to do it. In fact, I've even done it once and proved my point that way (which, as always, he didn't acknowledge, but I don't care anymore). Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://ertes.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI FieldStorage instances?
On Nov 22, 11:32 pm, Dennis Lee Bieber wrote: Or upgrade to some modernistic framework wherein the application is a monolithic program and the name/ portion maps to methods/functions within the application... Yes, that describes what I am looking for! Is there such a modernistic framework? Links? -- Gnarlie, K5ZN -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI FieldStorage instances?
On 11/23/2010 7:01 PM, Gnarlodious wrote: On Nov 22, 11:32 pm, Dennis Lee Bieber wrote: Or upgrade to some modernistic framework wherein the application is a monolithic program and the name/ portion maps to methods/functions within the application... Yes, that describes what I am looking for! Is there such a modernistic framework? Links? Try Django[1] or TurboGears[2]. [1] http://www.djangoproject.com/ [2] http://www.turbogears.org/ Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Arrays
Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Are arrays immutable? -- http://mail.python.org/mailman/listinfo/python-list
Re: Arrays
On 11/23/2010 10:55 PM, Garland Fulton wrote: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Do you mean the arrays of the array module, or NumPy arrays, or something else entirely? In the first case, yes; arrays behave more or less like lists, but more efficiently and with type constraints. In the second case, I believe you have to explicitly resize the array in order to add new elements to it. Are arrays immutable? No in either case. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Ensuring symmetry in difflib.SequenceMatcher
I'm generally pleased with difflib.SequenceMatcher: It's probably not the best available string matcher out there, but it's in the standard library and I've seen worse in the wild. One thing that kind of bothers me is that it's sensitive to which argument you pick as seq1 and which you pick as seq2: Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import difflib difflib.SequenceMatcher(None, 'BYRD', 'BRADY').ratio() 0.2 difflib.SequenceMatcher(None, 'BRADY', 'BYRD').ratio() 0.3 Is this a bug? I am guessing the algorithm is implemented correctly, and that it's just an inherent property of the algorithm used. It's certainly not what I'd call a desirably property. Are there any simple adjustments that can be made without sacrificing (too much) performance? John -- http://mail.python.org/mailman/listinfo/python-list
[issue10508] compiler warnings about formatting pid_t as an int
Georg Brandl ge...@python.org added the comment: Well, I can't see a problem with it. Backported in r86706, r86707. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10508 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10511] heapq docs clarification
New submission from Georg Brandl ge...@python.org: On the python-docs mailing list, a user suggested to rewrite the first paragraph of the heapq docs like this. Are you okay with this change, Raymond? Heaps are trees for which every parent node has a value less than or equal to any of its children. This implementation uses arrays for which ``heap[k] = heap[2*k+1]`` and ``heap[k] = heap[2*k+2]`` for all *k*, counting elements from zero. For the sake of comparison, non-existing elements are considered to be infinite. The interesting property of a heap is that its smallest element is always the root, ``heap[0]``. -- assignee: rhettinger messages: 122203 nosy: georg.brandl, rhettinger priority: normal severity: normal status: open title: heapq docs clarification ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10511 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10504] Trivial mingw compile fixes
Martin v. Löwis mar...@v.loewis.de added the comment: Why exactly are you skeptical? Because it doesn't fix everything in one go? The other changes are also minimal (I'm not even sure if it requires more source changes, maybe I have just to get my #defines right). If you prefer to see a single patch which you can reproduce to fix MinGW compilation completely, I'm willing to do that. Only bug fixes are acceptable for the 2.7 branch. If this *doesn't* actually fix the bug (i.e. allows building Python with mingw), then it's not a bug fix. Mere improvements are not acceptable for that branch. We have a long tradition of people proposing patches we need this and that code to support this and that platform. Then, right after applying the patch, they come back with more patches, and after that with more patches. I can accept this for the trunk if it doesn't break anything, but not for a maintenance branch. The objective should be to have the minimal necessary amount of changes that just address the goal of the maintenance branch (i.e. fixes). Work in progress doesn't belong here (some will argue that work in progress doesn't even belong to the trunk, but should be carried out in a separate branch). Given that 2.7 is supposed to be a long time support version, I really think people should have a chance to use MinGW. The patch is trivial, but figuring out everything from the compiler error messages can be brain bending. If this bug (which, unfortunately, hasn't been identified clearly, either) ever gets fixed, I'm open for backporting it (with the release manager's approval - it could also be considered as a new feature - port to mingw - in which case it also would be out of scope). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10504 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10511] heapq docs clarification
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: That looks fine. Perhaps s/trees/binary trees -- assignee: rhettinger - georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10511 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10511] heapq docs clarification
Georg Brandl ge...@python.org added the comment: Great! Applied in r86708. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10511 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10504] Trivial mingw compile fixes
Johann Hanne pyt...@jf.hanne.name added the comment: Well... ok. Although I already regard the patch as a strict bugfix (it fixes compilation of some C modules on MinGW), I'll go forward and create a patch for Python 3.2 which fixes compilation of all C modules on MinGW (all which are supposed to work on Win32 that is). I assume once I've shown that the patch still mostly consists of some preprocessor fixes, it will have a fair chance of being applied in 2.7. If somebody knows that there is *no* chance, please speak *now* so I can just stop trying to make something that already works for me available to everybody. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10504 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10483] http.server - what is executable on Windows
Glenn Linderman v+pyt...@g.nevcal.com added the comment: Martin, you are splitting hairs about the reported problem. The original message does have a paragraph about the executable bits being wrong. But the bulk of the message is commenting about the difficulty of figuring out what to replace it with. So it looks like in spite of the hair splitting, we have iterated to a design of making run_cgi a bit friendlier in this regard. I find it sufficient to define a method fully extracted from run_cgi as follows: def make_cmdline( self, scriptfile, query ): cmdline = [scriptfile] if self.is_python(scriptfile): interp = sys.executable if interp.lower().endswith(w.exe): # On Windows, use python.exe, not pythonw.exe interp = interp[:-5] + interp[-4:] cmdline = [interp, '-u'] + cmdline if '=' not in query: cmdline.append(query) This leaves run_cgi with: import subprocess cmdline = self.make_cmdline( scriptfile, query ) self.log_message(command: %s, subprocess.list2cmdline(cmdline)) Apologies: I don't know what format of patch is acceptable, but this is a simple cut-n-paste change. I was sort of holding off until the hg conversion to figure out how to make code submissions, since otherwise I'd have to learn it twice in short order. I have reimplemented my work-arounds in terms of the above fix, and they function correctly, so this fix would suffice for me, for this issue. (N.B. I'm sure you've noticed that I have entered a number of issues for http.server; I hope that was the right way to do it, to attempt to separate the issues.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10483 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10512] regrtest ResourceWarning - unclosed socket
New submission from Nadeem Vawda nadeem.va...@gmail.com: When running make test on Python3, test_socket reports a number of ResourceWarnings due to unclosed sockets. Attached is a patch that changes the relevant tests so that they close all the created sockets. test_multiprocessing and test_xmlrpc have a similar problem; I will upload patches for these shortly. -- components: Tests files: test_socket-resourcewarning-fix.diff keywords: patch messages: 122209 nosy: nvawda priority: normal severity: normal status: open title: regrtest ResourceWarning - unclosed socket type: behavior versions: Python 3.2 Added file: http://bugs.python.org/file19783/test_socket-resourcewarning-fix.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10512 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10510] distutils.command.upload/register HTTP message headers: bad line termination
Éric Araujo mer...@netwok.org added the comment: Thank you for the report. This is how I understand the part of the spec you quoted: Strictly valid HTTP uses CRLF, but servers and clients should be liberal in what they accept and deal with LF too. Senthil, do you agree with that? There are a small number of PyPI-like servers out there which seem to deal fine with what distutils produces. We have strong backward compatibility constraints in distutils, so we try to make the less changes possible to fix bugs. Because we’ve haven’t had this reported by those other servers before, I’m tempted to reject this report. The good part is that since you’re still writing the server, you can change its code to follow Postel’s Law and be liberal in what you accept. Does that sound acceptable to you? Best regards -- assignee: - eric.araujo components: +Distutils, Distutils2 nosy: +eric.araujo, orsenthil, tarek versions: +3rd party, Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10500] Palevo.DZ worm msix86 installer 3.x installer
Changes by Éric Araujo mer...@netwok.org: -- nosy: +loewis versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10500] Palevo.DZ worm msix86 installer 3.x installer
Martin v. Löwis mar...@v.loewis.de added the comment: What file specifically did you download? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10504] Trivial mingw compile fixes
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: But a strict bugfix should fix something. Is there something that did not work before, and will work after this patch? IOW, how do you compile posixmodule.c with MinGW and does it produce a working module? Now, I *am* interested in a working MinGW build. Please share what you have done. Your patch will certainly be merged into the py3k branch. But it won't be merged into 2.7 until it gives a tangible benefit to the maintenance branch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10504 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10513] sqlite3.InterfaceError after commit
New submission from Anders Blomdell anders.blomd...@control.lth.se: With version 2.7 (and 2.7.1rc1), the following sequence (see attached test): c = cursor.execute(' select k from t where k == ?;', (1,)) conn.commit() r = c.fetchone() Traceback (most recent call last): File /bugs/sqlite_bug.py, line 22, in module c = cursor.execute(' select k from t where k == ?;', (2,)) sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type. The program works with 2.6.2 -- components: Extension Modules files: sqlite_bug.py messages: 122213 nosy: anders.blomd...@control.lth.se priority: normal severity: normal status: open title: sqlite3.InterfaceError after commit type: crash versions: Python 2.7 Added file: http://bugs.python.org/file19784/sqlite_bug.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10513 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10499] Modular interpolation in configparser
Changes by Alexander Solovyov pira...@piranha.org.ua: -- nosy: +asolovyov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10499 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10514] configure does not create accurate Makefile
New submission from Keith Meyer meyer.ke...@gmail.com: When running configure on AIX 5.3 using: OPT=-O2 LDFLAGS=-s ./configure --with-gcc=xlc_r -q64 --with-cxx-main=xlC_r -q64 --disable-ipv6 AR=ar -X64 The Makefile still contains g++ as the CXX compiler to be used. -- components: Build messages: 122214 nosy: daelious priority: normal severity: normal status: open title: configure does not create accurate Makefile versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10514 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10435] Document unicode C-API in reST
Marc-Andre Lemburg m...@egenix.com added the comment: Alexander Belopolsky wrote: Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Wed, Nov 17, 2010 at 5:20 PM, Marc-Andre Lemburg rep...@bugs.python.org wrote: .. -/* Encodes a Unicode object and returns the result as Python string +/* Encodes a Unicode object and returns the result as Python bytes object. */ PyUnicode_AsEncodedObject() encodes the Unicode object to whatever the codec returns, so the bytes is wrong in the above line. The above line describes PyUnicode_AsEncodedString(), not PyUnicode_AsEncodedObject(). The former has PyBytes_Check(v) after calling v = PyCodec_Encode(..). As far as I can tell this is the only difference that makes PyUnicode_AsEncodedObject() not redundant. In that case, the change is fine. .. +.. c:function:: PyObject* PyUnicode_AsDecodedObject(PyObject *unicode, const char *encoding, const char *errors) + Create a Unicode object by decoding the encoded Unicode object + *unicode*. The function does not guarantee that a Unicode object will be returned. It merely passes a Unicode object to a codec's decode function and returns whatever the codec returns. Good point. I am changing Unicode object to Python object. .. + Note that Python codecs do not accept Unicode objects for decoding, + so this method is only useful with user or 3rd party codecs. Please strike the last sentence. The codecs that were wrongly removed from Python3 will get added back and provide such functionality. Would it be acceptable to keep this note, but add as of version 3.2 or something like that? I don't think there is a chance that these codecs will be added in 3.2 given the current schedule. Please remove the sentence or change it to: Note that most Python codecs only accept Unicode objects for decoding. .. This should read: Decodes a Unicode object by passing the given Unicode object *unicode* to the codec for *encoding*. *encoding* and *errors* have the same meaning as the parameters of the same name in the :func:`unicode` built-in function. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. Is the following better? Decodes a Unicode object by passing the given Unicode object *unicode* to the codec for *encoding*. *encoding* and *errors* have the same meaning as the parameters of the same name in the :func:`unicode` built-in function. The codec to be used is looked up using the Python codec registry. Return *NULL* if an exception was raised by the codec. As of Python 3.2, this method is only useful with user or 3rd party codec that encodes string into something other than bytes. Same as above. For encoding to bytes, use c:func:`PyUnicode_AsEncodedString` instead. .. +.. c:function:: void PyUnicode_Append(PyObject **pleft, PyObject *right) .. + +.. c:function:: void PyUnicode_AppendAndDel(PyObject **pleft, PyObject *right) .. Please don't document these two obscure APIs. Instead we should make them private functions by prepending them with an underscore. If you look at the implementations of those two APIs, they are little more than a macros around PyUnicode_Concat(). I don't agree that they are obscure. Python uses them in multiple places and developers seem to know about them. See patches submitted to issue4113 and issue7584. I found these references: http://osdir.com/ml/python.python-3000.cvs/2007-11/msg00270.html and http://riverbankcomputing.co.uk/hg/sip/annotate/91a545605044/siplib/siplib.c so you're right: they are already in use in the wild. Too bad... Please add these porting notes to the documentation: PyUnicode_Append() works like the PyString_Concat(), while PyUnicode_AppendAndDel() works like PyString_ConcatAndDel(). 3rd party extensions should use PyUnicode_Concat() to achieve the same effect. Hmm. I would not be surprised if current 3rd party extensions used PyUnicode_AppendAndDel() more often than PyUnicode_Concat(). (I know that I learned about PyUnicode_AppendAndDel() before PyUnicode_Concat().) Certainly not more often. PyUnicode_Concat() has been around much longer than the other two APIs which are only available in Python3. Is there anything that makes PyUnicode_AppendAndDel() undesirable? I don't mind adding a recommendation to use PyUnicode_Concat() if there is a practical reason for it or even a warning that PyUnicode_AppendAndDel() may be deprecated in the future, but renaming it to _PyUnicode_AppendAndDel() seems premature. Both APIs are just slight variants of the PyUnicode_Concat() API. They change parameters in-place which is rather uncommon for the Unicode API and don't return their result - in fact the error reporting is somewhat broken: APIs which do in-place modifcations usually return an integer for error
[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)
Marc-Andre Lemburg m...@egenix.com added the comment: R. David Murray wrote: R. David Murray rdmur...@bitdance.com added the comment: I had a report from a user on IRC during the bug weekend that they could not reproduce the failure on windows. So it may be dependent on the windows version. That doesn't answer your question of why it hasn't come up before, though, since my tests were done on XP. Some research shows that the MS VCRT uses non-ISO locale names for setlocale(): http://msdn.microsoft.com/en-us/library/x99tb11d.aspx http://msdn.microsoft.com/en-us/library/hzz3tw78.aspx http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx http://msdn.microsoft.com/en-us/library/cdax410z.aspx and it doesn't support the ISO style locale namings, even though the setlocale() page says The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API and the Win32 API does support the ISO names: http://msdn.microsoft.com/en-us/library/dd373814(VS.85).aspx I'll have to check whether Vista also shows this behavior. On Win XP the setlocale() API doesn't accept ISO language names; I can confirm that. It only accepts the fully written out form described on the above pages. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10466 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7094] Add alternate float formatting styles to new-style formatting.
Changes by Eric Smith e...@trueblade.com: -- stage: unit test needed - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10466] locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)
Marc-Andre Lemburg m...@egenix.com added the comment: Marc-Andre Lemburg wrote: Marc-Andre Lemburg m...@egenix.com added the comment: R. David Murray wrote: R. David Murray rdmur...@bitdance.com added the comment: I had a report from a user on IRC during the bug weekend that they could not reproduce the failure on windows. So it may be dependent on the windows version. That doesn't answer your question of why it hasn't come up before, though, since my tests were done on XP. Some research shows that the MS VCRT uses non-ISO locale names for setlocale(): http://msdn.microsoft.com/en-us/library/x99tb11d.aspx http://msdn.microsoft.com/en-us/library/hzz3tw78.aspx http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx http://msdn.microsoft.com/en-us/library/cdax410z.aspx and it doesn't support the ISO style locale namings, even though the setlocale() page says The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API and the Win32 API does support the ISO names: http://msdn.microsoft.com/en-us/library/dd373814(VS.85).aspx I'll have to check whether Vista also shows this behavior. On Win XP the setlocale() API doesn't accept ISO language names; I can confirm that. It only accepts the fully written out form described on the above pages. Confirmed on Vista as well. I think the only choice we have is to add a new alias dictionary mapping the ISO language names to the Windows ones. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10466 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9742] Python 2.7: math module fails to build on Solaris 9
Jerzy Kozera jerzy.koz...@gmail.com added the comment: Running gcc -Wl,-R/usr/local/lib,-R/usr/lib -o python Python/pymath.o Modules/python.o libpython2.7.a -lresolv -lsocket -lnsl -lrt -ldl -lpthread -lm mv build/lib.solaris-2.8-sun4u-2.7/math_failed.so build/lib.solaris-2.8-sun4u-2.7/math.so seems to have made math module import correctly and work: bash-2.03$ ./python Python 2.7 (r27:82500, Nov 23 2010, 14:49:30) [GCC 3.4.6] on sunos5 Type help, copyright, credits or license for more information. import math math.floor(2.4) 2.0 I suppose it's more a workaround than a solution, but hopefully it makes using math module possible and confirms the suggestion there might be something wrong with ar/gcc linking the .a file. -- nosy: +Jerzy.Kozera ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9742 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10087] HTML calendar is broken
Chris Lambacher ch...@kateandchris.net added the comment: I don't think we *need* to have the encoding in the HTML calendar, but I doubt we could remove it at this point, deprecate maybe, but since I don't use the module I don't have a sense for how often the need for encoding comes up. The one thing that the encoding is doing in the HTML calendar is ensuring that Unicode characters that are not directly translatable in the target encoding are replaced with html character references (the xmlcharrefreplace option to the errors argument in the encode method). The encoding may be a holdover from Python 2x where the expected result was a string. The docs say HTMLCalendar was added in Python 2.5 at the same time that the Local versions were added. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10087 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10510] distutils.command.upload/register HTTP message headers: bad line termination
Brian Jones bkjo...@gmail.com added the comment: In truth, I don't personally know if the other PyPI server implementations also have to work around this issue. Other comments on that are welcome. As for my own implementation, I've implemented a workaround to this, but I'm working around and reimplementing what is otherwise a feature built into the server (and every other one). I believe the suggested change makes the world a better place, and having administered several different web servers, I can't imagine ill effects from making the change. Web servers support *at least* the standard. Any ill effects we might imagine are, at least for my part, pure speculation. I, on the other hand, have found a real-life problem now :) I guess in the end I think that servers are more likely to err on the side of strict HTTP than make allowances for every SHOULD in the protocol spec, and leaving things as-is relies on a SHOULD, which I submit is incorrect behavior, and therefore a bug. It's not like a fix is going to magically improve my life, as I'll have to support older buggy versions anyway, but making the change now can help grease the wheels for future implementations who won't have to hit this hurdle. My $.02. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2636] Regexp 2.7 (modifications to current re 2.2.2)
Steve Moran s...@uw.edu added the comment: Forgive me if this is just a stupid oversight. I'm a linguist and use UTF-8 for special characters for linguistics data. This often includes multi-byte Unicode character sequences that are composed as one grapheme. For example the í̵ (if it's displaying correctly for you) is a LATIN SMALL LETTER I WITH STROKE \u0268 combined with COMBINING ACUTE ACCENT \u0301. E.g. a word I'm parsing: jí̵-e-gɨ I was pretty excited to find out that this regex library implements the grapheme match \X (equivalent to \P{M}\p{M}*). For the above example I needed to evaluate which sequences of characters can occur across syllable boundaries (here the hyphen -), so I'm aiming for: í̵-e e-g When regex couldn't get any better, you awesome developers implemented an overlapped=True flag with findall and finditer. Python 3.1.2 (r312:79147, May 19 2010, 11:50:28) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 import regex s = jí̵-e-gɨ s 'jí̵-e-gɨ' m = regex.compile((\X)(-)(\X)) m.findall(s, overlapped=False) [('í̵', '-', 'e')] But these results are weird to me: m.findall(s, overlapped=True) [('í̵', '-', 'e'), ('í̵', '-', 'e'), ('e', '-', 'g'), ('e', '-', 'g'), ('e', '-', 'g')] Why the extra matches? At first I figured this had something to do with the overlapping match of the grapheme, since it's multiple characters. So I tried it with with out the grapheme match: m = regex.compile((.)(-)(.)) s2 = a-b-cd-e-f m.findall(s2, overlapped=False) [('a', '-', 'b'), ('d', '-', 'e')] That's right. But with overlap... m.findall(s2, overlapped=True) [('a', '-', 'b'), ('b', '-', 'c'), ('b', '-', 'c'), ('d', '-', 'e'), ('d', '-', 'e'), ('d', '-', 'e'), ('e', '-', 'f'), ('e', '-', 'f')] Those 'extra' matches are confusing me. 2x b-c, 3x d-e, 2x e-f? Or even more simply: s2 = a-b-c m.findall(s2, overlapped=False) [('a', '-', 'b')] m.findall(s2, overlapped=True) [('a', '-', 'b'), ('b', '-', 'c'), ('b', '-', 'c')] Thanks! -- nosy: +stiv type: feature request - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Phillip M. Feldman phillip.m.feld...@gmail.com added the comment: I would like to unsubscribe from this thread, but haven't been able to figure out how to do it. Phillip On Mon, Nov 22, 2010 at 11:50 PM, Georg Brandl rep...@bugs.python.orgwrote: Georg Brandl ge...@python.org added the comment: Yes, please do apply. You don't need to run a doc build for every small change; of course it is nice if you do, but errors will be caught by the daily build routine anyway and mailed to me. As for the two blank lines: you'll see that the original conversion from LaTeX produced two blank lines after each description (function, class, ...), and I find this to be a little more readable than only one blank line, especially when the descriptions are longer; for short descriptions leaving only one blank line saves space. Syntactically, both are fully equivalent. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ -- Added file: http://bugs.python.org/file19785/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___I would like to unsubscribe from this thread, but haven#39;t been able to figure out how to do it.brbrPhillipbrbrdiv class=gmail_quoteOn Mon, Nov 22, 2010 at 11:50 PM, Georg Brandl span dir=ltrlt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span wrote:br blockquote class=gmail_quote style=margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;br Georg Brandl lt;a href=mailto:ge...@python.org;ge...@python.org/agt; added the comment:br br Yes, please do apply. Â You don#39;t need to run a doc build for every small change; of course it is nice if you do, but errors will be caught by the daily build routine anyway and mailed to me.br br As for the two blank lines: you#39;ll see that the original conversion from LaTeX produced two blank lines after each description (function, class, ...), and I find this to be a little more readable than only one blank line, especially when the descriptions are longer; for short descriptions leaving only one blank line saves space. Â Syntactically, both are fully equivalent.br br --br br ___br Python tracker lt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br lt;a href=http://bugs.python.org/issue1859; target=_blankhttp://bugs.python.org/issue1859/agt;br ___br /blockquote/divbr ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Changes by Brian Curtin cur...@acm.org: -- nosy: -phillip.m.feld...@gmail.com ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10510] distutils.command.upload/register HTTP message headers: bad line termination
Senthil Kumaran orsent...@gmail.com added the comment: I think, it is better that distutils.command.register and distutils.command.upload use CRLF as the line terminator for header values. It just helps in many cases, we can safely side by this case, but not relying LR or CR only may not be always possible. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9807] deriving configuration information for different builds with the same prefix
Matthias Klose d...@debian.org added the comment: looks good. checked with a plain and a debug build and installation. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9807 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2636] Regexp 2.7 (modifications to current re 2.2.2)
R. David Murray rdmur...@bitdance.com added the comment: Please don't change the type, this issue is about the feature request of adding this regex engine to the stdlib. I'm sure Matthew will get back to you about your question. -- type: behavior - feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10513] sqlite3.InterfaceError after commit
Ned Deily n...@acm.org added the comment: Also fails with 3.2 as in 2.7 and works in 3.1 as in 2.6. -- nosy: +ghaering, ned.deily stage: - needs patch type: crash - behavior versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10513 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10515] csv sniffer does not recognize quotes at the end of line
New submission from Martin Budaj m.bu...@gmail.com: The method Sniffer._guess_quote_and_delimiter() in the module csv.py contains a bug in a regexp which checks for quotes around the last item of the line (example: a,b,c,d\n). the pattern '(?Pdelim[^\w\n\'])(?Pspace ?)(?Pquote[\']).*?(?P=quote)(?:$|\n)' used in the regex should be changed to '(?Pdelim[^\w\n\'])(?Pspace ?)(?Pquote[\']).*?(?P=quote)(?:$|\n)' file csv.py: line 212 in python 2.6, line 216 in 2.7, line 207 in 3.1 -- components: Library (Lib) messages: 17 nosy: Martin.Budaj priority: normal severity: normal status: open title: csv sniffer does not recognize quotes at the end of line type: behavior versions: Python 2.6, Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2636] Regexp 2.7 (modifications to current re 2.2.2)
Matthew Barnett pyt...@mrabarnett.plus.com added the comment: issue2636-20101123.zip is a new version of the regex module. Oops, sorry, the weird behaviour of msg11 was a bug. :-( -- Added file: http://bugs.python.org/file19786/issue2636-20101123.zip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9742] Python 2.7: math module fails to build on Solaris 9
Doug Shea doug.s...@gmail.com added the comment: It's actually not quite a solution, either. Working your changes into the build process, I *do* get a math module... but it does *not* have a round function. python Python 2.7 (r27, Nov 23 2010, 11:54:39) [GCC 3.3.2] on sunos5 Type help, copyright, credits or license for more information. import math; print math.round(2.5); Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'round' print math.floor(2.5); 2.0 A step in the right direction, though, I'd think. Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9742 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10515] csv sniffer does not recognize quotes at the end of line
Ned Deily n...@acm.org added the comment: Thanks for the report. It would be helpful if you could supply a patch including a unit test for this against 3.2 and/or 2.7. Note only security issues are accepted for 2.6. -- nosy: +ned.deily stage: - unit test needed versions: +Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1745035] DoS smtpd vulnerability
Savio Sena savio.s...@acm.org added the comment: Attaching a more concise patch, as requested by georg.brandl. -- Added file: http://bugs.python.org/file19787/issue1745035-101123-saviosena.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745035 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1745035] DoS smtpd vulnerability
Giampaolo Rodola' g.rod...@gmail.com added the comment: I think data_size_limit and command_size_limit should be class attributes instead of instance attributes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745035 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10399] AST Optimization: inlining of function calls
Dave Malcolm dmalc...@redhat.com added the comment: If this a work in progress, you could create an SVN branch in the sandbox (you can then use svnmerge to avoid diverging too much from mainline) or an hg repo. Good idea; I've created branch dmalcolm-ast-optimization-branch (of py3k) on svn.python.org for use as I build up my prototype implementation of this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10399 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9742] Python 2.7: math module fails to build on Solaris 9
Mark Dickinson dicki...@gmail.com added the comment: I *do* get a math module... but it does *not* have a round function. Not a problem: the math module isn't supposed to have a round function. :-) The round function is used as part of the calculations that produce the gamma function. So if the gamma function is working, then all's well: from math import gamma gamma(3.1) 2.197620278392477 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9742 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1745035] DoS smtpd vulnerability
Savio Sena savio.s...@acm.org added the comment: Previous patch was incorrect. I'm attaching another one, I'm really sorry. @giampaolo, about making the limits class attributes, it's not a good idea IMHO. According to RFC1869 command sizes can change depending on which Service Extensions are supported. -- Added file: http://bugs.python.org/file19788/issue1745035-101123-saviosena.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745035 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10512] regrtest ResourceWarning - unclosed sockets and files
Nadeem Vawda nadeem.va...@gmail.com added the comment: Attached is a patch that fixes the warnings in test_xmlrpc, along with some other file- and socket-related warnings in test_normalization, test_timeout and test_tk that only show up when regrtest is run with -uall. The warning in test_timeout could be fixed with a smaller modification of the test code, but I thought it was better to have two separate attributes for the two sockets. It seemed misleading to have _some_ of the setup/teardown code in setUp() and tearDown(), but then be doing more in the actual tests. The warnings in test_multiprocessing seem to be due to leaks in the actual multiprocessing module, not in the test code, so that might be a bit more work to fix. -- title: regrtest ResourceWarning - unclosed socket - regrtest ResourceWarning - unclosed sockets and files Added file: http://bugs.python.org/file19789/resourcewarning-fixes-2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10512 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10399] AST Optimization: inlining of function calls
Dave Malcolm dmalc...@redhat.com added the comment: py3k-ast-pyoptimize-2010-11-19-006.patch fixed up and committed to the branch as r86715; I'll work on that branch for the time being. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10399 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2001] Pydoc interactive browsing enhancement
Éric Araujo mer...@netwok.org added the comment: I am reviewing this and making some edits to the patch. Will post this week. -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2001 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1745035] DoS smtpd vulnerability
Savio Sena savio.s...@acm.org added the comment: size_limits are not class attributes instead of instance attributes, as suggested by giampaolo.rodola. -- Added file: http://bugs.python.org/file19790/issue1745035-101123-saviosena.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745035 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1676121] Problem linking to readline lib on x86(64) Solaris
Roumen Petrov bugtr...@roumenpetrov.info added the comment: Hmm why you dont use LDFLAGS ? It is well documented what to expect during configuration and build phase. -- nosy: +rpetrov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1676121 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Changes by Terry J. Reedy tjre...@udel.edu: Removed file: http://bugs.python.org/file19785/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1745035] DoS smtpd vulnerability
Giampaolo Rodola' g.rod...@gmail.com added the comment: AFAICT patch looks ok to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745035 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Matthew Barnett pyt...@mrabarnett.plus.com added the comment: textwrap_2010-11-23.diff is my attempt to provide a fix, if it's wanted/needed. -- Added file: http://bugs.python.org/file19791/textwrap_2010-11-23.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9189] Improve CFLAGS handling
Stefan Krah stefan-use...@bytereef.org added the comment: Since I was the one who reopened this: The issues I found were fixed in r85358 and #9047 seems to be ok now. Setting to pending. -- resolution: - fixed stage: - committed/rejected status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9189 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1745035] DoS smtpd vulnerability
Changes by Georg Brandl ge...@python.org: -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1745035 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Terry J. Reedy tjre...@udel.edu added the comment: Doc patch applied to 3.2, 3.1, 2.7 in r86717, r86718, r86719 Jeremy Thurgood added to 3.2 Misc/ACKS in r86720. (I know, I should have added this first before committing.) I am leaving this open for a possible behavior patch. Mathew: look at the examples by Tom Lynn and Jeremy Thurgood for unit tests. My comment If newlines in the text are left in, [with replace_whitespace=False] they should reset the characters-in-line count to 0 the same as inserted newlines. may be all that is needed for a fix. If and when there is a behavior patch, the current doc patch should be reverted (undone) with an alternate doc patch. Whoops, you just added a patch while I wrote the above. I will try to take a look if no one else does. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1508475] transparent gzip compression in urllib
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- nosy: +nvawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1508475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9915] speeding up sorting with a key
Antoine Pitrou pit...@free.fr added the comment: The Rietveld issue is here: http://codereview.appspot.com/3269041 I ended up loading my incremental patches in, but it's easy enough to diff the base with the last patch. If for some reasons it doesn't work as conveniently as I expect, let me know and I will upload it to Rietveld again as one big patch. I've started reviewing, and I must say that incremental patches would have made more sense if they didn't mutate each other's changes. Still reviewing though, thanks for the upload. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Tom Lynn tl...@users.sourceforge.net added the comment: I've also been attempting to look into this and came up with an almost identical patch, which is promising: https://bitbucket.org/tlynn/issue1859/diff/textwrap.py?diff2=041c9deb90a2diff1=f2c093077fbf I missed the wordsep_simple_re though. Testing it is the hard part. I've got a few examples that could become tests in that repository, but it's far from conclusive. One corner case I found is trailing whitespace becoming a blank line: from textwrap import TextWrapper T = TextWrapper(replace_whitespace=False, drop_whitespace=False, width=9) T.wrap('x'*9 + ' \nfoo') ['x', ' ', 'foo'] I think it's fine. drop_whitespace=True removes the blank line, and those who really want drop_whitespace=False can remove the blank lines easily. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9915] speeding up sorting with a key
Antoine Pitrou pit...@free.fr added the comment: I ended up loading my incremental patches in, but it's easy enough to diff the base with the last patch. If for some reasons it doesn't work as conveniently as I expect, let me know and I will upload it to Rietveld again as one big patch. I've started reviewing, and I must say that incremental patches would have made more sense if they didn't mutate each other's changes. Still reviewing though, thanks for the upload. Ok, things are even worse: comments I've made to intermediate patches have wrong URLs in the summary e-mail, so they don't point to the right line numbers. Certainly a bug in Rietveld, but I'm not willing to do it, sorry. Bottom line is that you're making too many gratuitous changes, including style changes, and probably useless changes (Py_LOCAL_INLINE everywhere, nitpicking over ISLT / IFLT...). Also, there's some strange complication in some places which deserves comments and justification. Next time, please upload a single patch. Really. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9915] speeding up sorting with a key
Daniel Stutzbach stutzb...@google.com added the comment: Antoine Pitrou wrote: Next time, please upload a single patch. Really. I haven't used Rietveld that much yet, and I'm still learning best-practices. I apologize for the painful experience. For anyone else planning to take a look at this, here it is as one big patch: http://codereview.appspot.com/3290041 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9915] speeding up sorting with a key
Daniel Stutzbach stutzb...@google.com added the comment: Antoine, My original patch was much more focused, but had a slightly larger performance penalty for sorting random keys (see http://bugs.python.org/msg122178). Do you think the performance tradeoff there was still worthwhile? Ihave uploaded my original patch (as one patch :) ) here: http://codereview.appspot.com/3291041 If you think the original performance looks like a worthwhile tradeoff, could you spend about 1 minute looking over that version of patch and give your general impression? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9915] speeding up sorting with a key
Antoine Pitrou pit...@free.fr added the comment: My original patch was much more focused, but had a slightly larger performance penalty for sorting random keys (see http://bugs.python.org/msg122178). Do you think the performance tradeoff there was still worthwhile? I am not objecting against the performance tweaks but the other more or less gratuitous changes (IFLT vs ISLT, Py_LOCAL_INLINE sprinkled all over, weird complicated static keys instead of the initial stack_keys, else style change...). You can still try to salvage my comments from the review I've posted, but it seems Rietveld makes the thing tediously annoying to navigate (best thing may be to browse all 14 side-by-side diffs to look for the comments). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear()
New submission from Terry J. Reedy tjre...@udel.edu: Add list.clear() method with obvious semantics. Pro: 1. parallel to set/dict/defaultdict/deque.clear(), usable in generic mutable collection function; 2. makes it easier to switch between list and other collection class; 3. current alternatives are not as obvious; 4. some people seem to expect it. Anti: 1. unneeded; del l[:] or l[:]=[] do same already. Guido: (python-ideas list, 'Set Syntax' thread, today) FWIW I'm fine with adding list.clear() to 3.3. -- components: Interpreter Core messages: 122251 nosy: terry.reedy priority: normal severity: normal stage: unit test needed status: open title: Add list.clear() type: feature request versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear()
Eric Smith e...@trueblade.com added the comment: Guido's email is archived at: http://mail.python.org/pipermail/python-ideas/2010-November/008732.html -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9404] IDLE won't launch on XP
demarcus pyt...@dmarkphotography.com added the comment: Had this issue.. figured out what's causing it... definitively. I had an earlier version of python installed, and I created a pythonhome user variable: c:\python24. I'm now using Python 2.5, and that old variable was: 1.) Keeping me from opening the IDLE 2.) Keeping the console from finding the os module. This is also the source of the import os error. TO FIX: - modify the pythonhome variable to your current version, or.. remove it. -Dmark www.dmarkphotography.com -- nosy: +rugburnpy versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9404 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10517] test_concurrent_futures crashes with Fatal Python error: Invalid thread state for this thread
New submission from Łukasz Langa luk...@langa.pl: py3k built from trunk on Centos 5.5 freezes during regrtest on test_concurrent_futures with Fatal Python error: Invalid thread state for this thread. A set of hopefully useful diagnostic logs attached as patch. -- assignee: bquinlan components: Extension Modules files: concurrent-futures-freeze.tar.bz2 messages: 122254 nosy: bquinlan, lukasz.langa priority: critical severity: normal status: open title: test_concurrent_futures crashes with Fatal Python error: Invalid thread state for this thread type: crash versions: Python 3.2 Added file: http://bugs.python.org/file19792/concurrent-futures-freeze.tar.bz2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10517] test_concurrent_futures crashes with Fatal Python error: Invalid thread state for this thread
Łukasz Langa luk...@langa.pl added the comment: A colorful example: http://bpaste.net/show/11493/ (just in case if downloading and extracting logs is not feasible) Some clarification: as in a typical concurrent problem, subsequent calls freeze in different test cases, but the freeze itself is always reproducible and always during this test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10515] csv sniffer does not recognize quotes at the end of line
Changes by Andrew McNamara andr...@object-craft.com.au: -- nosy: +andrewmcnamara ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10515 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3061] time.strftime() always decodes result with UTF-8
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3061 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com