Re: Reading csv file
Thank you, Peter. About OOP: company policy, can't help it. They say it's easier to maintain and code. But it works now. On Thu, Dec 19, 2013 at 2:39 AM, Peter Otten __pete...@web.de wrote: Igor Korot wrote: Hi, Peter, Thank you for the great suggestion. I tried to implement you code but failed. Here's what I have: class FileReader: def __init__(self, filename, isSkip): self.path = filename self.isSkip = isSkip @contextmanager def open(*args): Selfless OO? Not in Python. from StringIO import StringIO lines = range(10) if self.isSkip: lines[0] = skipped lines[6] = field1-from-line6,field2-from-line6 else: lines[0] = field1-from-line1,field2-from-line1 yield StringIO(\r\n.join(map(str, lines))) def is_arbitrary_text(self,fieldnames): return skipped in fieldnames def readData(self): with self.open(self.path, r) as f: reader = csv.DictReader(f) if self.is_arbitrary_text(reader.fieldnames): for _ in range(5): next(reader, None) reader._fieldnames = None Here you introduced another bug, ignoring my helpful comments. reader._fieldnames = None # underscore necessary, # fieldnames setter doesn't work reader.fieldnames # used for its side-effect for row in reader: print row Unfortunately this does not work as def open() does not belong to my class and if I comment the @contextmanager line I will get an exception: AttributeError: __exit__ Any idea what to do? Keeping comments is not an option? But please read and try to understand the comments before you excise them ;) As I mentioned in the comment to the open() function you are not supposed to use it as you have real data -- use Python's built-in open() function. Anyway, if you insist on doing everything the OO-way, at least add a self in all the right places and don't introduce bugs that could be avoided with copy-and-paste. A working script with mock data and following the OO fashion would be: $ cat csv_skip_header_oo.py import csv from contextlib import contextmanager class FileReader: def __init__(self, filename, isSkip): self.path = filename self.isSkip = isSkip @contextmanager def open(self, *args): from StringIO import StringIO lines = range(10) if self.isSkip: lines[0] = skipped lines[6] = field1-from-line6,field2-from-line6 else: lines[0] = field1-from-line1,field2-from-line1 yield StringIO(\r\n.join(map(str, lines))) def is_arbitrary_text(self,fieldnames): return skipped in fieldnames def readData(self): with self.open(self.path, r) as f: reader = csv.DictReader(f) if self.is_arbitrary_text(reader.fieldnames): for _ in range(5): next(reader, None) reader._fieldnames = None # underscore necessary, # fieldnames setter doesn't work reader.fieldnames # used for its side-effect for row in reader: print row if __name__ == __main__: import sys print Demo with made-up data skip = len(sys.argv) 1 and sys.argv[1] == --skip if skip: print Variant 2, header is skipped else: print Variant 1, no header FileReader(whatever.csv, skip).readData() $ python csv_skip_header_oo.py Demo with made-up data Variant 1, no header {'field2-from-line1': None, 'field1-from-line1': '1'} {'field2-from-line1': None, 'field1-from-line1': '2'} {'field2-from-line1': None, 'field1-from-line1': '3'} {'field2-from-line1': None, 'field1-from-line1': '4'} {'field2-from-line1': None, 'field1-from-line1': '5'} {'field2-from-line1': None, 'field1-from-line1': '6'} {'field2-from-line1': None, 'field1-from-line1': '7'} {'field2-from-line1': None, 'field1-from-line1': '8'} {'field2-from-line1': None, 'field1-from-line1': '9'} $ python csv_skip_header_oo.py --skip Demo with made-up data Variant 2, header is skipped {'field1-from-line6': '7', 'field2-from-line6': None} {'field1-from-line6': '8', 'field2-from-line6': None} {'field1-from-line6': '9', 'field2-from-line6': None} A script using real data would be: $ cat csv_skip_header_oo.py import csv class FileReader: def __init__(self, filename): self.path = filename def is_arbitrary_text(self, fieldnames): # XXX replace with a test suitable for your actual
Re: PDFMiner install question
Jason Mellone jason.mell...@gmail.com wrote: I get the following error: PS C:\USERS\Python27 .\python.exe .\MyTest.py Traceback (most recent call last): File .\MyTest.py, line 4, in module from pdfminer.pdfpage import PDFTextExtractionNotAllowed ImportError: cannot import name PDFTextExtractionNotAllowed If I run commenting out the import of PDFTextExtractionNotAllowed it runs without a problem. Quite odd. According to the latest version on Github, PDFTextExtractionNotAllowed was moved into the PDFPage class, but the sample code in the docs was obviously not updated. https://github.com/euske/pdfminer/blob/master/pdfminer/pdfpage.py So just leave out that line and if you need that exception use PDFPage.PDFTextExtractionNotAllowed instead of PDFTextExtractionNotAllowed. Bye, Andreas -- https://mail.python.org/mailman/listinfo/python-list
Re: Determining whether a glyph is available in Tkinter
Le vendredi 20 décembre 2013 00:10:58 UTC+1, wmcb...@gmail.com a écrit : On Monday, December 16, 2013 10:58:06 PM UTC-5, Terry Reedy wrote: In this case, I already know that the glyphs I chose work with the default fonts for OS X 10.4+ and Windows 7+, but not for (for example) Win XP. As I pointed in an another thread, Windows 7 is the first Windows which became full unicode compliant (0th order approximation). If your application works fine with win7, good. If it does not on XP, it's like this. --- Font: I do not know what glyphs you need. Do not expect to find always a single font that will cover your needs. It's a little bit a side effect of unicode, but everything has been constructed to be a no problem. And it is a no problem. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: How to use the method loadtxt() of numpy neatly?
On Friday, December 20, 2013 11:18:53 AM UTC+5:30, chao dong wrote: HI, everybody. When I try to use numpy to deal with my dataset in the style of csv, I face a little problem. In my dataset of the csv file, some columns are string that can not convert to float easily. Some of them can ignore, but other columns I need to change the data to a enum style. for example, one column just contain three kinds : S,Q,C. Each of them can declare one meaning, so I must convert them to a dict just like {1,2,3} What does dict like {1,2,3} mean?? On recent python thats a set On older ones its probably an error. So you can mean one of: 1. Set([1,2,3]) 2. List: [1,2,3] 3. Tuple: (1,2,3) 4. Dict: {S:1, Q:2, C:3} 5. An enumeration (on very recent pythons) 6. A simulation of an enum using classes (or somesuch) 7. Something else Now the question is, when I use numpy.loadtxt, I must do all things above in just one line and one fuction. So as a new user in numpy, I don't know how to solve it. I suggest you supply a couple of rows of your input And the corresponding python data-structures you desire Someone should then suggest how to go about it -- https://mail.python.org/mailman/listinfo/python-list
Re: How to use the method loadtxt() of numpy neatly?
chao dong wrote: HI, everybody. When I try to use numpy to deal with my dataset in the style of csv, I face a little problem. In my dataset of the csv file, some columns are string that can not convert to float easily. Some of them can ignore, but other columns I need to change the data to a enum style. for example, one column just contain three kinds : S,Q,C. Each of them can declare one meaning, so I must convert them to a dict just like {1,2,3} Now the question is, when I use numpy.loadtxt, I must do all things above in just one line and one fuction. So as a new user in numpy, I don't know how to solve it. Thank you. Here's a standalone demo: import numpy _lookup={A: 1, B: 2} def convert(x): return _lookup.get(x, -1) converters = { 0: convert, # in column 0 convert A -- 1, B -- 2, # anything else to -1 } if __name__ == __main__: # generate csv with open(tmp_sample.csv, wb) as f: f.write(\ A,1,this,67.8 B,2,should,56.7 C,3,be,34.5 A,4,skipped,12.3 ) # load csv a = numpy.loadtxt( tmp_sample.csv, converters=converters, delimiter=,, usecols=(0, 1, 3) # skip third column ) print a Does that help? -- https://mail.python.org/mailman/listinfo/python-list
Why Python is like C++
http://xkcd.com/1306/ -- https://mail.python.org/mailman/listinfo/python-list
Struggling with unittest discovery - how to structure my project test suite
I'm trying to write a project using test-first development. I've been basically following the process from Test-Driven Web Development with Python (excellent book, by the way) but I'm writing a command line application rather than a web app, so I'm having to modify some bits as I go along. Notably I am *not* using the django test runner. I have my functional tests in a file in my project root at the moment - functional_tests.py. But now I need to start writing some unit tests and I need to refactor my tests into a more manageable structure. If I create a tests directory with an __init__.py and unit and functional subdirectories, each with __init__.py and test_XXX.py files in them, then python -m unittest works (as in, it discovers my tests fine). But if I just want to run my unit tests, or just my functional tests, I can't seem to get the command line right to do that - I either get all the tests run, or none. What's the best way of structuring my projects so that: 1. I can run all the tests easily on demand. 2. I can run just the functional or unit tests when needed. 3. I can run individual tests (or maybe just individual test modules, I don't have so many tests yet that I know how detailed I'll need to get!) without too much messing (and certainly without changing any source files!) I know that tools like py.test or nose can probably do this sort of thing. But I don't really want to add a new testing tool to the list of things I have to learn for this project (I'm already using it to learn SQLAlchemy and colander, as well as test-driven development, so I have enough on my plate already!) I've looked around on the web for information - there's a lot available on writing the tests themselves, but surprisingly little on how to structure a project for easy testing (unless I've just failed miserably to find the right search terms :-)) Thanks for any help, Paul -- https://mail.python.org/mailman/listinfo/python-list
Newbie question. Are those different objects ?
y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. The second time we type print type y, how does the program knows which one of the y's it refers to ? Is the first y object deleted ? thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Fri, Dec 20, 2013, at 10:16, dec...@msn.com wrote: The second time we type print type y, how does the program knows which one of the y's it refers to ? Is the first y object deleted ? y does not refer to the first object anymore after you've assigned the second object to it. In CPython, if there are no other references to the string object, yes it is deleted - other implementations may defer deletion to a later time. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations Lets unassume that and rewrite the code 1. y ! raw_input('Enter a number:') 2. print type y 3. y ! float(raw_input('Enter a number:')) 4. print type y Now read that 1 as first, 2 as second etc and read the '!' as 'MAKE'. (It may help to shout it) Now what was your question? -- https://mail.python.org/mailman/listinfo/python-list
wxPython latest
As wxPython was mentioned a week ago some of you may be interested in these http://article.gmane.org/gmane.comp.python.wxpython.devel/5680 http://article.gmane.org/gmane.comp.python.wxpython.devel/5675 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Lets unassume that and rewrite the code 1. y ! raw_input('Enter a number:') 2. print type y 3. y ! float(raw_input('Enter a number:')) 4. print type y Now read that 1 as first, 2 as second etc and read the '!' as 'MAKE'. (It may help to shout it) Now what was your question? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 12/20/2013 10:16 AM, dec...@msn.com wrote: print type y That line will give you a syntax error. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Good idea. Only you were beaten to it by about 2 decades. The language ABC calls it 'put' and corrects the unnecessary gratuitous right to left order. Reference http://homepages.cwi.nl/~steven/abc/qr.html#COMMANDS Examples http://homepages.cwi.nl/~steven/abc/types.html And what does that have to do with python? http://www.onlamp.com/lpt/a/2431 -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 20/12/2013 17:10, rusi wrote: On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Good idea. Only you were beaten to it by about 2 decades. I can't find a PEP suggesting this, can you give me the number please? The language ABC calls it 'put' and corrects the unnecessary gratuitous right to left order. So does it go top to bottom or bottom to top? Or to really clarify things does it have putlr, putrl, puttb and putbt? Reference http://homepages.cwi.nl/~steven/abc/qr.html#COMMANDS Examples http://homepages.cwi.nl/~steven/abc/types.html And what does that have to do with python? http://www.onlamp.com/lpt/a/2431 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Struggling with unittest discovery - how to structure my project test suite
20.12.13 16:47, Paul Moore написав(ла): What's the best way of structuring my projects so that: 1. I can run all the tests easily on demand. 2. I can run just the functional or unit tests when needed. python -m unittest discover -s tests/functional python -m unittest discover tests/functional 3. I can run individual tests (or maybe just individual test modules, I don't have so many tests yet that I know how detailed I'll need to get!) without too much messing (and certainly without changing any source files!) python -m unittest discover -s tests/functional -p test_spam.py python -m unittest discover tests/functional -p test_spam.py python -m unittest discover tests/functional test_spam.py -- https://mail.python.org/mailman/listinfo/python-list
Re: Why Python is like C++
20.12.13 16:19, Roy Smith написав(ла): http://xkcd.com/1306/ QBASIC$, not $QBASIC. -- https://mail.python.org/mailman/listinfo/python-list
Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.
This thread hasn't been close to Python for while now and should be shut down. But, it is actually kind of interesting since you debate possible mechanisms behind the behaviour of my Windows box at work: Not responding is happening to me daily for any application including Microsoft's own Office Suite. I hoped it would go away when we moved from Vista to W7 but it didn't. In all fairness, our computers have both corporate and HP crapware installed so Microsoft may be innocent. Coming from many years of SUN Solaris experience I may be a bit spoiled when it comes to robustness :-) Now, let's leave this behind and spend time on Python -- something I with a formal programming education dating back to 1980 and F77 find fascinating. /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Saturday, December 21, 2013 1:10:37 AM UTC+8, rusi wrote: On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. Well, in Python the assignment operation = of a variable named y in the LHS to the object of the RHS result is more complicated than = in those register basd low level languages designed for fast execution speeds in compiled machine codes without an auto GC bundled with the interpreter in the run time. -- https://mail.python.org/mailman/listinfo/python-list
Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.
On 20/12/2013 17:52, Martin Schöön wrote: Coming from many years of SUN Solaris experience I may be a bit spoiled when it comes to robustness :-) You never had the pleasure of working on VMS then? :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 12/20/2013 08:16 AM, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. Rather than thinking that y is an object, it is more accurate to think of it as: y is a name that is bound to (ie, refers to, points to) an object. So, raw_input() creates a string object and returns it. Your first assignment statement binds that string object to the name y. From now on, when you refer to y you will get that string object. When python executes your 3rd line, raw_input() creates a new string object, completely separate from the earlier one. This object is passed to float(). Float() reads it and creates a new float object and returns it. When python then executes your second assignment statement, it changes the binding of y to point to the float object; the old binding to the string object is lost. From now on, when you refer to y you will get the float object. I'm also assuming that the second and the first y are different objects because they have different types. Yes, they are different objects. But not because they have different types; they are different because every time python creates a new object it is distinct from other objects [*1]. The second time we type print type y, how does the program knows which one of the y's it refers to ? Because there is only one name y, and when python executed your second assignment statement, it changed the object that the name y pointed to from the first (string) object to the second (float) one. Is the first y object deleted ? thanks in advance. Yes. If there is no way that the first object can be accessed any more, then it will be deleted. The same thing happened to the string object return by raw_input() in your 3rd statement (which never had a name at all). [*1] My statement was an oversimplification. There are some cases where Python will return the same object such as interned objects and objects like None for which there is only ever a single instance in a Python program. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Dec 20, 2013, at 8:00 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Or a symbol like :=. As a former Smalltalker, I still miss this as the assignment operator, and the “gets” verbiage that went along with it. One said: x := 4 as in “x gets 4” I always got a kick out of the following paragraph from http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html. 1970 - Niklaus Wirth creates Pascal, a procedural language. Critics immediately denounce Pascal because it uses x := x + y syntax instead of the more familiar C-like x = x + y. This criticism happens in spite of the fact that C has not yet been invented. -- https://mail.python.org/mailman/listinfo/python-list
Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.
Le vendredi 20 décembre 2013 18:52:44 UTC+1, Martin Schöön a écrit : This thread hasn't been close to Python for while now and should be shut down. But, it is actually kind of interesting since you debate possible mechanisms behind the behaviour of my Windows box at work: Not responding is happening to me daily for any application including Microsoft's own Office Suite. I hoped it would go away when we moved from Vista to W7 but it didn't. In all fairness, our computers have both corporate and HP crapware installed so Microsoft may be innocent. Coming from many years of SUN Solaris experience I may be a bit spoiled when it comes to robustness :-) Now, let's leave this behind and spend time on Python -- something I with a formal programming education dating back to 1980 and F77 find fascinating. The fact, that a main app window [%] falls in a Ne répond pas, (Not responding) state [*] with a mouse pointer becoming a waiting pointer is not so dramatic. As I pointed, despite this message in the title bar, the app works properly(?). The fact, that system becomes unstable is more critical. While being in that [*]-state, any attempt to work with the mouse, eg clicking on an another app window, leads to a [%] kill and to a msg box Python has stopped working The Python process can be killed, it does not hurt the system. I'm observing this with the Qt-derivatives, PySide and PyQt4, and Python 3.3. Not with Python 3.2. From where does it come from? No idea. I'm inclined to think, it's on the Qt side. Windows 7 pro jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: Copy a file like unix cp -a --reflink
Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt writes: Hi! Is there a way to copy a file the same as Unix command: cp -a --reflink src dest without invoking a shell command? I vaguely remember this was asked and answered some time ago and the answer was no, even just for -a. In fact, the python shutil module documentation starts with a warning to that effect. The --reflink stuff would be another thing altogether. More accurately, currently the only way would be to duplicate this functionality of cp in python. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why Python is like C++
Serhiy Storchaka wrote: 20.12.13 16:19, Roy Smith написав(ла): http://xkcd.com/1306/ QBASIC$, not $QBASIC. Or just QB$. (Most BASICs of that era only regarded the first two characters as significant.) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Struggling with unittest discovery - how to structure my project test suite
On 12/20/2013 12:41 PM, Serhiy Storchaka wrote: 20.12.13 16:47, Paul Moore написав(ла): What's the best way of structuring my projects so that: It depends on your tradeoff between extra setup in the files and how much you type each time you run tests. 1. I can run all the tests easily on demand. I believe that if you copy Lib/idlelib/idle_test/__init__.py to tests/__main__.py and add import unittest; unittest.main() then python -m tests would run all your tests. Lib/idlelib/idle_test/README.py may help explain. 2. I can run just the functional or unit tests when needed. python -m unittest discover -s tests/functional python -m unittest discover tests/functional Ditto for __main__.py files in each, so python -m tests.unit (functional) will work. 3. I can run individual tests (or maybe just individual test modules, I don't have so many tests yet that I know how detailed I'll need to get!) without too much messing (and certainly without changing any source files!) python -m unittest discover -s tests/functional -p test_spam.py python -m unittest discover tests/functional -p test_spam.py python -m unittest discover tests/functional test_spam.py 'discover' is not needed for single files. For instance, python -m unittest idlelib.idle_test.test_calltips works for me. One can extend that to test cases and methods. python -m unittest idlelib.idle_test.test_calltips.Get_entityTest and python -m unittest idlelib.idle_test.test_calltips.Get_entityTest.test_bad_entity If you add to each test_xyz.py file if __name__ == '__main__': unittest.main(verbosity=2) # example of adding fixed option then python -m tests.unit.test_xyz will run the tests in that file. (So does F5 in an Idle editor, which is how I run individual test files while editing. I copy the boilerplate from README.txt or an existing test_xyz.py file.) -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 12/20/2013 10:16 AM, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I recommend starting with 3.3 unless your are forced to use 2.x. I also recommend trying code before posting it. I'm assuming that y is an object. The name 'y' is bound to an object. The second assignment rebinds 'y' to a different object. I'm also assuming that the second and the first y are different objects It depends on whether by 'y' you mean the name, which remains the same, or the object it is bound to, which changes. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
rusi wrote: Good idea. Only you were beaten to it by about 2 decades. More than 2, I think. Lisp: (setq x y) Algol: x := y Smalltalk: x - y (where - is a left arrow character) Cobol: MOVE X TO Y -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Struggling with unittest discovery - how to structure my project test suite
On Friday, 20 December 2013 17:41:40 UTC, Serhiy Storchaka wrote: 20.12.13 16:47, Paul Moore написав(ла): 1. I can run all the tests easily on demand. 2. I can run just the functional or unit tests when needed. python -m unittest discover -s tests/functional python -m unittest discover tests/functional Hmm, I could have sworn I'd tried that. But you're absolutely right. Thanks, and sorry for the waste of bandwidth... Paul -- https://mail.python.org/mailman/listinfo/python-list
bytearray inconsistencies?
Quoting from http://docs.python.org/3/library/functions.html#bytearray The bytearray type is a mutable sequence of integers in the range 0 = x 256. Quoting from http://docs.python.org/3/library/stdtypes.html#bytes-methods Whenever a bytes or bytearray method needs to interpret the bytes as characters (e.g. the is...() methods, split(), strip()), the ASCII character set is assumed (text strings use Unicode semantics). Note - Using these ASCII based methods to manipulate binary data that is not stored in an ASCII based format may lead to data corruption. The search operations (in, count(), find(), index(), rfind() and rindex()) all accept both integers in the range 0 to 255 (inclusive) as well as bytes and byte array sequences. Changed in version 3.3: All of the search methods also accept an integer in the range 0 to 255 (inclusive) as their first argument. I don't understand why the docs talk about a mutable sequence of integers but then discuss needs to interpret the bytes as characters. Further I don't understand why the changes done in 3.3 referred to above haven't also been applied to (say) the split method. If I can call find to look for a zero, why can't I split on it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: How to import Wave files into python?
On Wednesday, December 18, 2013 8:45:08 AM UTC-8, twilk...@gmail.com wrote: How exactly do I import a .wav file and run it? also is it possible to run it inside a while loop if so or it just start playing when its run? - Tom 14 QSound.play(wave_file) -- https://mail.python.org/mailman/listinfo/python-list
Re: bytearray inconsistencies?
On 12/20/13 8:06 PM, Mark Lawrence wrote: Quoting from http://docs.python.org/3/library/functions.html#bytearray The bytearray type is a mutable sequence of integers in the range 0 = x 256. Quoting from http://docs.python.org/3/library/stdtypes.html#bytes-methods Whenever a bytes or bytearray method needs to interpret the bytes as characters (e.g. the is...() methods, split(), strip()), the ASCII character set is assumed (text strings use Unicode semantics). Note - Using these ASCII based methods to manipulate binary data that is not stored in an ASCII based format may lead to data corruption. The search operations (in, count(), find(), index(), rfind() and rindex()) all accept both integers in the range 0 to 255 (inclusive) as well as bytes and byte array sequences. Changed in version 3.3: All of the search methods also accept an integer in the range 0 to 255 (inclusive) as their first argument. I don't understand why the docs talk about a mutable sequence of integers but then discuss needs to interpret the bytes as characters. The split and strip methods work with whitespace when given no arguments. Bytes aren't whitespace. Characters can be, so the bytes need to be interpreted as characters. Likewise, the is* methods (isalnum, isalpha, isdigit, islower, isspace, istitle, isupper) all require characters, so the bytes must be interpreted. Further I don't understand why the changes done in 3.3 referred to above haven't also been applied to (say) the split method. If I can call find to look for a zero, why can't I split on it? I don't know the reason, but I would guess either no one considered it, or it was deemed unlikely to be useful. If you have a zero, you can split on it with: bytestring.split(bytes([0])), but that doesn't explain why find can take a simple zero, and split has to take a bytestring with a zero in it. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Experiences/guidance on teaching Python as a first programming language
On 12/20/13 6:58 PM, Dennis Lee Bieber wrote: On 20 Dec 2013 02:16:05 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info declaimed the following: 2) Even for kernel developers, I believe that systems languages should be safe by default. You ought to have to explicitly disable (say) bounds checking in critical sections of code, rather than explicitly enable it. Or worse, have to program your own bounds checking -- especially if the compiler is permitted to silently disregard it if you make one tiny mistake. I wonder how BLISS falls into that... Have to read the rest of http://en.wikipedia.org/wiki/BLISS (while I had 22 years on VMS, it was mostly F77, a touch of F90, C, Pascal, and some DCL; but never used BLISS) Bliss is even lower-level than C. It made the too-consistent choice of having names mean the same thing on the left-hand side of an assignment as on the right-hand side. A name meant the address of a variable, so to access the value of a variable, you had to dereference it with the dot operator, much like the unary asterisk in C. C: a = b Bliss: a = .b C: a = a + 1 Bliss: a = .a + 1 C: a = *b Bliss: a = ..b C: a = b Bliss: a = b It was far too common to forget the dots... -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: bytearray inconsistencies?
On 21/12/2013 01:58, Ned Batchelder wrote: On 12/20/13 8:06 PM, Mark Lawrence wrote: Quoting from http://docs.python.org/3/library/functions.html#bytearray The bytearray type is a mutable sequence of integers in the range 0 = x 256. Quoting from http://docs.python.org/3/library/stdtypes.html#bytes-methods Whenever a bytes or bytearray method needs to interpret the bytes as characters (e.g. the is...() methods, split(), strip()), the ASCII character set is assumed (text strings use Unicode semantics). Note - Using these ASCII based methods to manipulate binary data that is not stored in an ASCII based format may lead to data corruption. The search operations (in, count(), find(), index(), rfind() and rindex()) all accept both integers in the range 0 to 255 (inclusive) as well as bytes and byte array sequences. Changed in version 3.3: All of the search methods also accept an integer in the range 0 to 255 (inclusive) as their first argument. I don't understand why the docs talk about a mutable sequence of integers but then discuss needs to interpret the bytes as characters. The split and strip methods work with whitespace when given no arguments. Bytes aren't whitespace. Characters can be, so the bytes need to be interpreted as characters. Likewise, the is* methods (isalnum, isalpha, isdigit, islower, isspace, istitle, isupper) all require characters, so the bytes must be interpreted. Further I don't understand why the changes done in 3.3 referred to above haven't also been applied to (say) the split method. If I can call find to look for a zero, why can't I split on it? I don't know the reason, but I would guess either no one considered it, or it was deemed unlikely to be useful. Explanation, or lack of it, here http://bugs.python.org/issue12170 If you have a zero, you can split on it with: bytestring.split(bytes([0])), but that doesn't explain why find can take a simple zero, and split has to take a bytestring with a zero in it. I now have working code as a result of the above paragraph, thanks for that :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Why Python is like C++
On 12/20/2013 02:44 PM, Gregory Ewing wrote: Serhiy Storchaka wrote: 20.12.13 16:19, Roy Smith написав(ла): http://xkcd.com/1306/ QBASIC$, not $QBASIC. Or just QB$. (Most BASICs of that era only regarded the first two characters as significant.) Maybe BASIC's of the 70s. But Not QB. QuickBasic was a pretty impressive compiler in its day. Completely modern, structured language. And a pretty impressive IDE for its day that did some pretty slick source code navigation. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why Python is like C++
On 20/12/2013 14:19, Roy Smith wrote: http://xkcd.com/1306/ I believe that to be a very superficial like. They're unlike in that once C++ people have compiled their code they can head down to the pub, but Python people have to stay at work testing because the compiler hasn't caught all potential errors. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
sort(*, key=None, reverse=None)
The subject refers to the list sort method given here http://docs.python.org/3/library/stdtypes.html#list. I believe that the *, bit is simply a typo, given that the docs also state sort() accepts two arguments that can only be passed by keyword. Am I correct? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: sort(*, key=None, reverse=None)
On Fri, Dec 20, 2013 at 11:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: The subject refers to the list sort method given here http://docs.python.org/3/library/stdtypes.html#list. I believe that the *, bit is simply a typo, given that the docs also state sort() accepts two arguments that can only be passed by keyword. Am I correct? It's good practice in technical writing to repeat yourself: once in the formal spec, and once in plain english. I don't see why this would be a typo. -- Devin -- https://mail.python.org/mailman/listinfo/python-list
Re: sort(*, key=None, reverse=None)
On 21/12/2013 07:20, Devin Jeanpierre wrote: On Fri, Dec 20, 2013 at 11:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: The subject refers to the list sort method given here http://docs.python.org/3/library/stdtypes.html#list. I believe that the *, bit is simply a typo, given that the docs also state sort() accepts two arguments that can only be passed by keyword. Am I correct? It's good practice in technical writing to repeat yourself: once in the formal spec, and once in plain english. I don't see why this would be a typo. -- Devin So what is it actually saying? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: sort(*, key=None, reverse=None)
On Sat, Dec 21, 2013 at 6:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: The subject refers to the list sort method given here http://docs.python.org/3/library/stdtypes.html#list. I believe that the *, bit is simply a typo, given that the docs also state sort() accepts two arguments that can only be passed by keyword. Am I correct? The *, means that they're keyword-only arguments. It prevents you from passing them positionally. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: sort(*, key=None, reverse=None)
On Sat, Dec 21, 2013 at 6:24 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 21/12/2013 07:20, Devin Jeanpierre wrote: On Fri, Dec 20, 2013 at 11:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: The subject refers to the list sort method given here http://docs.python.org/3/library/stdtypes.html#list. I believe that the *, bit is simply a typo, given that the docs also state sort() accepts two arguments that can only be passed by keyword. Am I correct? It's good practice in technical writing to repeat yourself: once in the formal spec, and once in plain english. I don't see why this would be a typo. -- Devin So what is it actually saying? def func(x, y, *moreargs, foo, bar): pass Any positional args after x and y will go into moreargs, so foo and bar have to be specified by keywords. (And are mandatory, since I didn't default them.) If moreargs isn't given a name, then additional positional args are forbidden, but the requirements on foo and bar are the same. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue19927] Path-based loaders lack a meaningful __eq__() implementation.
Eric Snow added the comment: Unless there are objections, I'll commit this in the next day or two. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19927 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20030] unittest.TestLoader.discover return value incorrectly documented.
New submission from Arnaut Billings: Here: http://docs.python.org/3/library/unittest.html#unittest.TestLoader.discover it states that Find and return all test modules ... This implies that in order to get a test suite, one has to iterate over the return value of unittest.TestLoader.discover and call loadTestsFromModule for each module. But, the type of the result of unittest.TestLoader.discover returns: class 'unittest.suite.TestSuite' -- assignee: docs@python components: Documentation messages: 206670 nosy: arnaut-billings, docs@python priority: normal severity: normal status: open title: unittest.TestLoader.discover return value incorrectly documented. versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20031] unittest.TextTestRunner missing run() documentation.
New submission from Arnaut Billings: Here: http://docs.python.org/3/library/unittest.html 1) unittest.TextTestRunner is missing documentation for its public run method. 2) There are references to the TestRunner class sprinkled through out the above page, yet no link or documentation as to what that class actually is and does. -- assignee: docs@python components: Documentation messages: 206671 nosy: arnaut-billings, docs@python priority: normal severity: normal status: open title: unittest.TextTestRunner missing run() documentation. versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20031 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20031] unittest.TextTestRunner missing run() documentation.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti, michael.foord stage: - needs patch type: - enhancement versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20031 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20030] unittest.TestLoader.discover return value incorrectly documented.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- keywords: +easy nosy: +ezio.melotti, michael.foord stage: - needs patch type: - enhancement versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20030 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20031] unittest.TextTestRunner missing run() documentation.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- keywords: +easy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20031 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19967] asyncio: remove _TracebackLogger
STINNER Victor added the comment: I think this patch is bad and should be reverted. It always calls traceback.format_exception() which is an expensive operation, while the _TracebackLogger takes care to call it only when necessary. Oh, I didn't notice that, and I agree that the new code is inefficient. Since the Future object does not release the reference to the exception after result() or exception() has been called, there is no need to preformat the exception. It can be done in the destructor. Attached asyncio_defer_format_tb.patch implements that. Future.set_exception() creates a reference cycle. I created the issue #20032 to discuss that. -- resolution: fixed - Added file: http://bugs.python.org/file33229/asyncio_defer_format_tb.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19967 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
New submission from STINNER Victor: asyncio.Future.set_exception(exc) sets the exception attribute to exc, but exc.__traceback__ refers to frames and the current frame probably referes to the future instance. Tell me if I'm wrong, but it looks like a reference cycle: fut -- fut.exception -- exception --exception.__traceback__ - traceback --traceback.tb_frame -- frame --frame.fb_locals -- fut The frame class got a new clear() method in Python 3.4: http://docs.python.org/dev/reference/datamodel.html#frame.clear Maybe because of the PEP 442, the reference cycle is no more an issue. In fact, the following example calls fut destructor immediatly, at fut = None line. --- import asyncio fut = asyncio.Future() try: raise ValueError() except Exception as err: fut.set_exception(err) fut = None --- Attached patch breaks explicitly the reference cycle by scheduling a call to traceback.clear_frames() using call_soon(). The patch depends on asyncio_defer_format_tb.patch which is attached to the issue #19967. -- files: asyncio_break_ref_cycle.patch keywords: patch messages: 206672 nosy: gvanrossum, haypo, pitrou priority: normal severity: normal status: open title: asyncio.Future.set_exception() creates a reference cycle versions: Python 3.4 Added file: http://bugs.python.org/file33228/asyncio_break_ref_cycle.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
STINNER Victor added the comment: asyncio_break_ref_cycle.patch does not fix the issue on Python 3.3 (for Tulip). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20033] Fix makelocalealias.py for Python 3
New submission from Serhiy Storchaka: When Tools/i18n/makelocalealias.py was ported to Python 3 some things were not fixed. 1. locale.alias is opened as binary file in Python 2, but as text file (with locale encoding) in Python 3. This can cause fail when the script runs in UTF-8 locale because locale.alias contains non-ASCII locales ('bokmål' and 'français', encoded in Latin1). 2. In Python 2 %r formatting always produce ASCII output. In Python 3 %a should be used to produce the same output. Proposed patch fixes these minor bugs. -- components: Demos and Tools files: locale_py3k.patch keywords: patch messages: 206675 nosy: lemburg, loewis, serhiy.storchaka priority: normal severity: normal status: open title: Fix makelocalealias.py for Python 3 versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file33230/locale_py3k.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20033 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file33231/locale_devanagari_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file33219/locale_devanagari.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
New submission from Serhiy Storchaka: Proposed patch updates locale alias table to most recent locale.alias file (from X.org 7.7 distribution). -- components: Library (Lib) files: locale_aliases_77.patch keywords: patch messages: 206676 nosy: lemburg, loewis, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Update locale alias table type: enhancement versions: Python 2.7, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file33232/locale_aliases_77.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19946] Handle a non-importable __main__ in multiprocessing
Roundup Robot added the comment: New changeset 00d09afb57ca by Nick Coghlan in branch 'default': Issue #19946: use public API for multiprocessing start methods http://hg.python.org/cpython/rev/00d09afb57ca -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19946 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19946] Handle a non-importable __main__ in multiprocessing
Nick Coghlan added the comment: Pending a clean bill of health from the stable buildbots :) -- status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19946 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19736] posixmodule.c: Add flags for statvfs.f_flag to constant list
Changes by Matthias Klose d...@debian.org: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19736 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Marc-Andre Lemburg added the comment: On 20.12.2013 12:36, Serhiy Storchaka wrote: Proposed patch updates locale alias table to most recent locale.alias file (from X.org 7.7 distribution). Looks good. BTW, regarding the devanagari cases: There is some recent activity in glibc related to these. Here's a patch that adds the sd_IN@devanagari locale to glibc: http://sourceware.org/cgi-bin/cvsweb.cgi/libc/localedata/locales/sd...@devanagari.diff?cvsroot=glibcr1=NONEr2=1.1 So they will start working once platforms adopt the new glibc versions. The @-modifier is applied to the locale, not the encoding, because the locale uses a different script, as opposed to limiting itself to part of an encoding. This looks reasonable, even though I'm not sure it conforms to standards. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Marc-Andre Lemburg added the comment: On 20.12.2013 12:19, Serhiy Storchaka wrote: Added file: http://bugs.python.org/file33231/locale_devanagari_2.patch See my message on issue20034: There is some recent activity in glibc related to these. Here's a patch that adds the sd_IN@devanagari locale to glibc: http://sourceware.org/cgi-bin/cvsweb.cgi/libc/localedata/locales/sd...@devanagari.diff?cvsroot=glibcr1=NONEr2=1.1 So they will start working once platforms adopt the new glibc versions. The @-modifier is applied to the locale, not the encoding, because the locale uses a different script, as opposed to limiting itself to part of an encoding. This looks reasonable, even though I'm not sure it conforms to standards. Since all this is still very much in flux, perhaps we ought to wait a bit more and let the dust settle ?! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Berker Peksag added the comment: See also issue 16555. -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15599] test_threaded_import fails sporadically on Windows and FreeBSD
Nick Coghlan added the comment: Another recent instance of the parallel meta path failure: http://buildbot.python.org/all/builders/x86%20Windows7%203.x/builds/7740/steps/test/logs/stdio -- keywords: +buildbot -patch nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15599 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19946] Handle a non-importable __main__ in multiprocessing
Nick Coghlan added the comment: Now passing on all the stable buildbots (the two red Windows bots are for other issues, such as issue 15599 for the threaded import test failure) -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19946 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Serhiy Storchaka added the comment: Ubuntu 12.04 supports Kashmiri and Sindhi locales (requires language-pack-sd-base and language-pack-sd-base packages). $ locale -a ... ks_IN ks_IN@devanagari ks_IN.utf8 ks_IN.utf8@devanagari ... sd_IN sd_IN@devanagari sd_IN.utf8 sd_IN.utf8@devanagari ... Current Python doesn't support all of these locales: $ LC_ALL=ks_IN ./python -c 'import locale; print(locale.getlocale())' Traceback (most recent call last): File string, line 1, in module File /home/serhiy/py/cpython/Lib/locale.py, line 556, in getlocale return _parse_localename(localename) File /home/serhiy/py/cpython/Lib/locale.py, line 465, in _parse_localename raise ValueError('unknown locale: %s' % localename) ValueError: unknown locale: ks_IN $ LC_ALL=ks_IN@devanagari ./python -c 'import locale; print(locale.getlocale())' Traceback (most recent call last): File string, line 1, in module File /home/serhiy/py/cpython/Lib/locale.py, line 556, in getlocale return _parse_localename(localename) File /home/serhiy/py/cpython/Lib/locale.py, line 465, in _parse_localename raise ValueError('unknown locale: %s' % localename) ValueError: unknown locale: ks_IN@devanagari $ LC_ALL=ks_IN.utf8 ./python -c 'import locale; print(locale.getlocale())' ('ks_IN', 'utf8') $ LC_ALL=ks_IN.utf8@devanagari ./python -c 'import locale; print(locale.getlocale())' ('ks_IN', 'UTF-8') $ LC_ALL=sd_IN ./python -c 'import locale; print(locale.getlocale())' Traceback (most recent call last): File string, line 1, in module File /home/serhiy/py/cpython/Lib/locale.py, line 556, in getlocale return _parse_localename(localename) File /home/serhiy/py/cpython/Lib/locale.py, line 465, in _parse_localename raise ValueError('unknown locale: %s' % localename) ValueError: unknown locale: sd_IN $ LC_ALL=sd_IN@devanagari ./python -c 'import locale; print(locale.getlocale())' Traceback (most recent call last): File string, line 1, in module File /home/serhiy/py/cpython/Lib/locale.py, line 556, in getlocale return _parse_localename(localename) File /home/serhiy/py/cpython/Lib/locale.py, line 465, in _parse_localename raise ValueError('unknown locale: %s' % localename) ValueError: unknown locale: sd_IN@devanagari $ LC_ALL=sd_IN.utf8 ./python -c 'import locale; print(locale.getlocale())' ('sd_IN', 'utf8') $ LC_ALL=sd_IN.utf8@devanagari ./python -c 'import locale; print(locale.getlocale())' ('sd_IN', 'utf8') After applying the patch Python supports all ks_IN and sd_IN locales. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Marc-Andre Lemburg added the comment: On 20.12.2013 15:55, Serhiy Storchaka wrote: After applying the patch Python supports all ks_IN and sd_IN locales. Well, yes, but only because you are removing the @-modifiers. I don't think that's correct, since e.g. the string formatting used for numbers is different with the modifier. If you keep the modifiers, but move them to the end of the locale string you should get the correct behavior, e.g. -'sd': 'sd...@devanagari.utf-8', +'sd': 'sd_IN.UTF-8@devanagari', (modulo perhaps the spelling of UTF-8) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Serhiy Storchaka added the comment: Looks good. Should these patch be applied only to 3.4 or to all maintained releases? I suppose the later, because alias table which is not conform recent systems configuration is a bug. BTW, regarding the devanagari cases: This patch only updates the devanagari cases in conform to locale.alias file. *Issue20027 should fix support of these cases.* -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Serhiy Storchaka added the comment: Well, yes, but only because you are removing the @-modifiers. I don't think that's correct, since e.g. the string formatting used for numbers is different with the modifier. All the @-modifiers except euro are applied to the locale, not the encoding. And Python removes all the @-modifiers, e.g. latin and cyrillic which specify the script. If you keep the modifiers, but move them to the end of the locale string you should get the correct behavior, e.g. -'sd': 'sd...@devanagari.utf-8', +'sd': 'sd_IN.UTF-8@devanagari', (modulo perhaps the spelling of UTF-8) Recent the locale.alias file changes these entities: sd: sd_IN.UTF-8 sd_IN.utf8: sd_IN.UTF-8 sd@devanagari: sd...@devanagari.utf-8 sd_IN@devanagari: sd...@devanagari.utf-8 sd_IN@devanagari.utf8: sd...@devanagari.utf-8 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Marc-Andre Lemburg added the comment: On 20.12.2013 16:12, Serhiy Storchaka wrote: Serhiy Storchaka added the comment: Looks good. Should these patch be applied only to 3.4 or to all maintained releases? I suppose the later, because alias table which is not conform recent systems configuration is a bug. Agreed. BTW, regarding the devanagari cases: This patch only updates the devanagari cases in conform to locale.alias file. *Issue20027 should fix support of these cases.* Ok. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Marc-Andre Lemburg added the comment: On 20.12.2013 16:24, Serhiy Storchaka wrote: Serhiy Storchaka added the comment: Well, yes, but only because you are removing the @-modifiers. I don't think that's correct, since e.g. the string formatting used for numbers is different with the modifier. All the @-modifiers except euro are applied to the locale, not the encoding. And Python removes all the @-modifiers, e.g. latin and cyrillic which specify the script. That's not quite correct. The modifiers are used to determine the correct mapping, so you'll often find them on the left side, but not necessarily on the right side. There are several cases where the modifiers are kept around, since they have implications on the way number or dates are formatted. For the Indian devanagari locales we have to keep them, because the locale formatting of number and dates depends on them. If you keep the modifiers, but move them to the end of the locale string you should get the correct behavior, e.g. -'sd': 'sd...@devanagari.utf-8', +'sd': 'sd_IN.UTF-8@devanagari', (modulo perhaps the spelling of UTF-8) Recent the locale.alias file changes these entities: sd: sd_IN.UTF-8 sd_IN.utf8: sd_IN.UTF-8 sd@devanagari:sd...@devanagari.utf-8 sd_IN@devanagari: sd...@devanagari.utf-8 sd_IN@devanagari.utf8:sd...@devanagari.utf-8 I'm not sure I can parse this comment :-) Looking at issue20034 I think we are saying that the new updated local.alias file contains these entries: sd: sd_IN.UTF-8 sd_IN.utf8: sd_IN.UTF-8 sd@devanagari: sd...@devanagari.utf-8 sd_IN@devanagari: sd...@devanagari.utf-8 sd_IN@devanagari.utf8: sd...@devanagari.utf-8 So my example is wrong with the new locale.alias file. Instead, sd will map directly to sd_IN.UTF-8. Still, I think the makelocalalias.py script should correct the non-standard locale names from sd...@devanagari.utf-8 to sd_IN.UTF-8@devanagari in order to match the output of locale -a. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Roundup Robot added the comment: New changeset 81f8375e60ce by Serhiy Storchaka in branch '2.7': Issue #20034: Updated alias mapping to most recent locale.alias file http://hg.python.org/cpython/rev/81f8375e60ce New changeset ed62c4c70c4d by Serhiy Storchaka in branch '3.3': Issue #20034: Updated alias mapping to most recent locale.alias file http://hg.python.org/cpython/rev/ed62c4c70c4d -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Serhiy Storchaka added the comment: Thanks for your review, Marc-Andre. -- assignee: - serhiy.storchaka resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20035] Suppress 'os.environ was modified' warning on Tcl/Tk tests
New submission from Zachary Ware: The attached patch refactors tkinter._fix's main logic into a function called 'fix_environ' which is called unconditionally on import, and adds a function 'unfix_environ' to undo the effects of fix_environ. fix/unfix_environ are then used in all test files that import tkinter (test___all__, test_tcl, test_tk, test_ttk_guionly, test_ttk_textonly, test_idle) to ensure that the environment is properly set to allow Tcl to load and to suppress regrtest's warning that os.environ has been modified. Since tkinter._fix is an implementation detail, I assume this change isn't against the 'no new features' policy of all currently open branches, but if this needs to wait until 3.5, that's ok with me. -- components: Tests, Tkinter files: suppress_environ_warning.diff keywords: patch messages: 206692 nosy: zach.ware priority: low severity: normal stage: patch review status: open title: Suppress 'os.environ was modified' warning on Tcl/Tk tests type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file33233/suppress_environ_warning.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20035 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20034] Update locale alias table
Roundup Robot added the comment: New changeset 72e68af9e2fa by Serhiy Storchaka in branch 'default': Issue #20034: Updated alias mapping to most recent locale.alias file http://hg.python.org/cpython/rev/72e68af9e2fa -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20034 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
Guido van Rossum added the comment: Do you have an example of code that behaves differently with this patch? I can't find any. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Serhiy Storchaka added the comment: Updated patch to tip. The makelocalalias.py script now corrects the non-standard locale names. -- Added file: http://bugs.python.org/file33234/locale_devanagari_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20027] Fixed support for Indian locales
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file33231/locale_devanagari_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20027 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20035] Suppress 'os.environ was modified' warning on Tcl/Tk tests
Serhiy Storchaka added the comment: This looks fragile. What if some test will import tkinter after other test unfix the environment? I suggest unload the tkinter._fix module in unfix_environ(). Then next import should implicitly fix the environment. And explicit fix_environ() will be not needed. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20035 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20035] Suppress 'os.environ was modified' warning on Tcl/Tk tests
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20035 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20035] Suppress 'os.environ was modified' warning on Tcl/Tk tests
Zachary Ware added the comment: I like that idea, though I'm a bit wary of messing around is sys.modules. Is there another way to unload a module that I'm not aware of? Here's a new patch that does that. -- Added file: http://bugs.python.org/file33235/suppress_environ_warning.v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20035 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20036] Running same doctests not possible on both py3 and py2
New submission from Maries Ionel Cristian: One of these doesn't work depending on how you write the exception name. python3 -mdoctest src/tete.rst python -mdoctest src/tete.rst One cannot put an ellipsis in the exception name so you see how this is a problem. -- components: Demos and Tools, Library (Lib) files: tete.py messages: 206698 nosy: ionel.mc priority: normal severity: normal status: open title: Running same doctests not possible on both py3 and py2 type: behavior versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file33236/tete.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20036 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20036] Running same doctests not possible on both py3 and py2
Changes by Maries Ionel Cristian ionel...@gmail.com: Added file: http://bugs.python.org/file33237/tete.rst ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20036 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20036] Running same doctests not possible on both py3 and py2
R. David Murray added the comment: This has already been addressed in issue 7490. -- nosy: +r.david.murray resolution: - duplicate stage: - committed/rejected status: open - closed superseder: - IGNORE_EXCEPTION_DETAIL should ignore the module name ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20036 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20036] Running same doctests not possible on both py3 and py2
Maries Ionel Cristian added the comment: Oooops, sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20036 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20036] Running same doctests not possible on both py3 and py2
R. David Murray added the comment: No problem. It's not necessarily *obvious* what one needs to do to make this work, so missing it isn't too surprising. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20036 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19717] resolve() fails when the path doesn't exist
Antoine Pitrou added the comment: Well, given the diversity of possible behaviours, it starts to seem like it should maybe be discussed on python-dev. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19717 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20029] asyncio.SubprocessProtocol is missing
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +gvanrossum, haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20029 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
Antoine Pitrou added the comment: +self._loop.call_soon(traceback.clear_frames, + self._exception.__traceback__) This will keep the traceback alive until called by the event loop, even if self._exception is cleared in the meantime... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20029] asyncio.SubprocessProtocol is missing
Guido van Rossum added the comment: I propose that we fix the code. There are also some documented Transport classes that aren't listed in __all__. I'll submit the fix. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20029 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
STINNER Victor added the comment: Do you have an example of code that behaves differently with this patch? I can't find any. I didn't check in the Python standard library, but the reference cycle is obvious, and I hate such issue. It introduces tricky issues like memory leaks. Here is an example to demonstrate the issue. The DELETE OBJECT message is never displayed, so the object is never deleted (memory leak). Comment fut.set_exception(err) line to delete the object, or apply attached patch. -- Added file: http://bugs.python.org/file33238/never_deleted.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20029] asyncio.SubprocessProtocol is missing
Roundup Robot added the comment: New changeset 0a135e790ce5 by Guido van Rossum in branch 'default': asyncio: Export all abstract protocol and transport classes. Fixes issue #20029. http://hg.python.org/cpython/rev/0a135e790ce5 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20029 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20037] Calling traceback.format_exception() during Pyhon shutdown does crash Python
New submission from STINNER Victor: Attached crash.py script does crash Python. Python traceback on the crash: (gdb) py-bt Traceback (most recent call first): File /home/haypo/prog/python/default/Lib/tokenize.py, line 431, in open text = TextIOWrapper(buffer, encoding, line_buffering=True) File /home/haypo/prog/python/default/Lib/linecache.py, line 126, in updatecache with tokenize.open(fullname) as fp: File /home/haypo/prog/python/default/Lib/linecache.py, line 41, in getlines return updatecache(filename, module_globals) File /home/haypo/prog/python/default/Lib/linecache.py, line 15, in getline lines = getlines(filename, module_globals) File /home/haypo/prog/python/default/Lib/traceback.py, line 65, in _extract_tb_or_stack_iter line = linecache.getline(filename, lineno, f.f_globals) File /home/haypo/prog/python/default/Lib/traceback.py, line 18, in _format_list_iter for filename, lineno, name, line in extracted_list: File /home/haypo/prog/python/default/Lib/traceback.py, line 153, in _format_exception_iter yield from _format_list_iter(_extract_tb_iter(tb, limit=limit)) File /home/haypo/prog/python/default/Lib/traceback.py, line 181, in format_exception return list(_format_exception_iter(etype, value, tb, limit, chain)) File /home/haypo/prog/python/default/Lib/asyncio/futures.py, line 178, in __del__ exc.__traceback__) Garbage-collecting End of the C traceback: #46 0x005aa742 in PyEval_CallObjectWithKeywords (func=method at remote 0x719e79f8, arg=(), kw=0x0) at Python/ceval.c:4107 #47 0x004ee268 in slot_tp_finalize ( self=Future(_state='FINISHED', _exception=ValueError(), _loop=_UnixSelectorEventLoop(_selector=EpollSelector(_epoll=select.epoll at remote 0x70dd3a18, _fd_to_key={9: SelectorKey at remote 0x7fffeefaa0e0}, _map=_SelectorMapping(_selector=...) at remote 0x718eae90) at remote 0x718ea1f8, _running=False, _signal_handlers={}, _default_executor=None, _ssock=socket at remote 0x7fffef7e6e68, _internal_fds=1, _scheduled=[], _ready=collecti---Type return to continue, or q return to quit--- ons.deque at remote 0x718c56e0, _csock=socket at remote 0x7fffeefb5958) at remote 0x718ea190, _log_traceback=True, _callbacks=[]) at remote 0x718ea0c0) at Objects/typeobject.c:5954 #48 0x0043b530 in finalize_garbage (collectable=0x7fffdc90, old=0x8eea20 generations+64) at Modules/gcmodule.c:793 #49 0x0043bce5 in collect (generation=2, n_collected=0x0, n_uncollectable=0x0, nofail=1) at Modules/gcmodule.c:1009 #50 0x0043cff4 in _PyGC_CollectNoFail () at Modules/gcmodule.c:1625 #51 0x005cd873 in PyImport_Cleanup () at Python/import.c:383 #52 0x0041e898 in Py_Finalize () at Python/pythonrun.c:622 #53 0x0043a65c in Py_Main (argc=2, argv=0x970020) at Modules/main.c:800 #54 0x0041aad9 in main (argc=2, argv=0x7fffe0b8) at ./Modules/python.c:69 -- files: crash.py messages: 206707 nosy: haypo priority: normal severity: normal status: open title: Calling traceback.format_exception() during Pyhon shutdown does crash Python versions: Python 3.4 Added file: http://bugs.python.org/file33239/crash.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20037 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20037] Calling traceback.format_exception() during Pyhon shutdown does crash Python
STINNER Victor added the comment: Begin of the C traceback: #0 0x004bf70a in PyModule_GetState (m=0x0) at Objects/moduleobject.c:292 #1 0x006373b6 in textiowrapper_init (self=0x71073790, args=(_io.BufferedReader at remote 0x7fffefa094b8, 'utf-8'), kwds={'line_buffering': True}) at ./Modules/_io/textio.c:855 #2 0x004daf26 in type_call (type=0x94d700 PyTextIOWrapper_Type, args=(_io.BufferedReader at remote 0x7fffefa094b8, 'utf-8'), kwds={'line_buffering': True}) at Objects/typeobject.c:759 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20037 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
Guido van Rossum added the comment: The cycle will be cleaned up (and the message printed) when the garbage collector runs next. Your demo doesn't do anything else, so it never allocates memory, so it never runs gc.collect(). But that's only because it's a toy program. Maybe it's time to look into http://code.google.com/p/tulip/issues/detail?id=42 ? (It proposes to run gc.collect() occasionally when the loop is idle.) I am also concerned about Antoine's point -- the patch may actually *prolong* the life of the traceback. On Fri, Dec 20, 2013 at 2:15 PM, STINNER Victor rep...@bugs.python.org wrote: STINNER Victor added the comment: Do you have an example of code that behaves differently with this patch? I can't find any. I didn't check in the Python standard library, but the reference cycle is obvious, and I hate such issue. It introduces tricky issues like memory leaks. Here is an example to demonstrate the issue. The DELETE OBJECT message is never displayed, so the object is never deleted (memory leak). Comment fut.set_exception(err) line to delete the object, or apply attached patch. -- Added file: http://bugs.python.org/file33238/never_deleted.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20029] asyncio.SubprocessProtocol is missing
Guido van Rossum added the comment: There's one issue left: the docs need to document BaseProtocol. -- assignee: - haypo stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20029 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
Antoine Pitrou added the comment: Maybe it's time to look into http://code.google.com/p/tulip/issues/detail?id=42 ? (It proposes to run gc.collect() occasionally when the loop is idle.) Is it possible to break the cycle instead? Or is the graph of references too complex for that? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
Guido van Rossum added the comment: The only reasonable place to break the cycle seems to be the frame containing the set_exception() call -- but that could be app code. Looking again at what the patch actually does I think it is too big a hammer anyway -- it would break debugging tools that preserve tracebacks and inspect the frames later. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
STINNER Victor added the comment: The cycle will be cleaned up (and the message printed) when the garbage collector runs next. Oh, ok. Using the following task, the object is correctly deleted. --- @asyncio.coroutine def idle(): while 1: gc.collect() yield from asyncio.sleep(0.1) asyncio.Task(idle()) --- Maybe it's time to look into http://code.google.com/p/tulip/issues/detail?id=42 ? (It proposes to run gc.collect() occasionally when the loop is idle.) I don't like such task. The issue can be documented, maybe with an example of call calling gc.collect() regulary? Such background task should be implemented in the application to control when the garbage collector is called. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20032] asyncio.Future.set_exception() creates a reference cycle
Changes by STINNER Victor victor.stin...@gmail.com: -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20032 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19967] asyncio: remove _TracebackLogger
Guido van Rossum added the comment: Victor, can you commit the fix (with my suggested improvement)? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19967 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19995] hex() and %x, oct() and %o do not behave the same
Terry J. Reedy added the comment: It seems to me that anything that is an 'integer' that can be turned into an int without loss of information (has .__index__) is logically a 'number' that can be turned into an int possibly with loss of information (has .__int__). So perhaps one of the following should be true: 1. The doc for .__index__ specifies that def __index__ 'must' be followed by __int__ = __index__ to make a coherent class. (So Ethan's Grade as written above would not qualify.) 2. The type constructor does this for us by adding __int__ as an alias for __index__ when the latter is present. 3. Every core usage of __int__ looks for __index__ also. Int() does not do this now, but '%d' does, so int(Grade.F) fails but int('%d' % Grade.f) works. The exact details would depend on whether we want to allow (or at least bless) classes with __int__ and __index__ returning different ints. The docs for bin/oct/hex(x) are clear. Convert an integer number to a binary/octal/hexadecimal string. The result is a valid Python expression. If x is not a Python int object, it has to define an __index__() method that returns an integer. This should not change. If the domain of %x is going to be a subset of of the domain of %d, it seems to me that the exclusion should be of non-integers (such as floats) rather than of non-int integers. Given things as they are, I would simply expand the domain of %x, etc, to that of %d without bothering to go through a deprecation process. -- nosy: +terry.reedy stage: - test needed type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19995 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19967] asyncio: remove _TracebackLogger
Roundup Robot added the comment: New changeset 06ed1691efdc by Victor Stinner in branch 'default': Issue #19967: Defer the formating of the traceback in asyncio.Future destructor http://hg.python.org/cpython/rev/06ed1691efdc -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19967 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com