[issue44728] Testsuite fails on x86_64
New submission from Erich Eckner : The following tests fails on x86 32 bit: test_cmath test_math test_posix test_turtle - looks, like the expected precision is too high. Full log is attached. -- components: Tests files: build-log.php?a=pentium4=python messages: 398084 nosy: deep42thought priority: normal severity: normal status: open title: Testsuite fails on x86_64 versions: Python 3.9 Added file: https://bugs.python.org/file50175/build-log.php?a=pentium4=python ___ Python tracker <https://bugs.python.org/issue44728> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34095] [2.7] Seg fault on archlinux 32 when run tests with xvfb-run
Erich Eckner added the comment: yes, I'm also not sure what's different now - I executed the very same commands on the very same source tree :-/ -- ___ Python tracker <https://bugs.python.org/issue34095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34095] [2.7] test_idle fails with: /usr/bin/xvfb-run: line 181: 3617 Segmentation fault
Erich Eckner added the comment: Yes, I get much further in the test suite, currently (40k lines logged vs. 23k). Now, it succeeds until: 0:08:26 load avg: 0.72 [358/403/3] test_tuple test_addmul (test.test_tuple.TupleTest) ... ok test_bigrepeat (test.test_tuple.TupleTest) ... /usr/bin/xvfb-run: line 181: 231 8 Segmentation fault (core dumped) DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 -- Added file: https://bugs.python.org/file47869/log ___ Python tracker <https://bugs.python.org/issue34095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34096] [2.7] test_audioop.test_max() failed: AssertionError: -2147483648 != 2147483648L
Erich Eckner added the comment: ah, that would explain, why we don't get it set automatically on archlinux32 - there's "export OPT=$CFLAGS" right infront of ./configure ... - so $OPT is set and thus, -fwrapv is not appended -- ___ Python tracker <https://bugs.python.org/issue34096> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34095] [2.7] test_idle fails with: /usr/bin/xvfb-run: line 181: 3617 Segmentation fault
Erich Eckner added the comment: ok, some update: 1st: running the complete test suite with xvfb fails (as already reported): > LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} \ xvfb-run "${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall ... 0:02:14 load avg: 0.90 [174/403/1] test_idle test_close (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_misc (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_read (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_readline (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_readlines (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_unsupported (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_close (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_misc (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_unsupported (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_write (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_writelines (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok /usr/bin/xvfb-run: line 181: 13491 Segmentation fault (core dumped) DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 running w/o xvfb-run succeeds: > LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} > ${srcdir}/Python-${pkgver}/python -m test.regrtest -v -m test_io test_idle == CPython 2.7.15 (default, Jul 16 2018, 12:22:58) [GCC 8.1.1 20180531] == Linux-4.17.4-1.0-ARCH-i686-with-glibc2.1.3 little-endian == /home/vagrant/python2/src/Python-2.7.15/build/test_python_14208 == CPU count: 2 Run tests sequentially 0:00:00 load avg: 0.26 [1/1] test_idle test_close (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_misc (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_read (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_readline (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_readlines (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_unsupported (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_close (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_misc (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_unsupported (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_write (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_writelines (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok -- Ran 11 tests in 0.003s OK 1 test OK. Total duration: 150 ms Tests result: SUCCESS running only these tests with xvfb-run _succeeds_: > LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} xvfb-run > ${srcdir}/Python-${pkgver}/python -m test.regrtest -v -m test_io test_idle == CPython 2.7.15 (default, Jul 16 2018, 12:22:58) [GCC 8.1.1 20180531] == Linux-4.17.4-1.0-ARCH-i686-with-glibc2.1.3 little-endian == /home/vagrant/python2/src/Python-2.7.15/build/test_python_14226 == CPU count: 2 Run tests sequentially 0:00:00 load avg: 0.15 [1/1] test_idle test_close (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_misc (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_read (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_readline (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_readlines (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_unsupported (idlelib.idle_test.test_io.PseudeInputFilesTest) ... ok test_close (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_misc (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_unsupported (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_write (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok test_writelines (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... ok -- Ran 11 tests in 0.004s OK 1 test OK. Total duration: 144 ms Tests result: SUCCESS -- ___ Python tracker <https://bugs.python.org/issue34095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34095] [2.7] test_idle fails with: /usr/bin/xvfb-run: line 181: 3617 Segmentation fault
Erich Eckner added the comment: > Can you try to get the Python traceback and/or C traceback using gdb? Sry, I can't - I don't know how to use gdb :-( Is there some one-line command which makes gdb start xvfb-run and attach to it? Or do I need to start xvfb-run and separately attach gdb to it? (how do I do this?) > ... and hence would need xvfb-run on a headless server, as opposed to a > workstation with screen. Erich, I assume you are running on the latter. I'm running this on a headless box (packaging for archlinux32). Setting up a desktop on the test box would be some effort, but should be possible in principle. In the original PKGBUILD which Eli posted, there is a comment about when the tests started failing - which suggests, the problem is connected to xvfb-run. -- ___ Python tracker <https://bugs.python.org/issue34095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34096] [2.7] test_audioop.test_max() failed: AssertionError: -2147483648 != 2147483648L
Erich Eckner added the comment: yes, you were absolutely right: just adding "-fwrapv" to $OPT is enough. Ok, is this something, we at archlinux32 need to opt in for, or is this something, that the configure script should add for x86? -- ___ Python tracker <https://bugs.python.org/issue34096> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34096] [2.7] test_audioop.test_max() failed: AssertionError: -2147483648 != 2147483648L
Erich Eckner added the comment: yes, indeed, I just tested with your three flags-variables set and the build+test succeeded - I'll have to figure out what the minimal change is, though :-) -- ___ Python tracker <https://bugs.python.org/issue34096> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34096] [2.7] test_audioop.test_max() failed: AssertionError: -2147483648 != 2147483648L
Erich Eckner added the comment: yes, I'm using gcc (GCC) 8.1.1 20180531 I attached the created pythoninfo -- Added file: https://bugs.python.org/file47687/pythoninfo ___ Python tracker <https://bugs.python.org/issue34096> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34096] testsuite fails assertion
New submission from Erich Eckner : building python 2.7.15 on archlinux32 (the i686 branch of archlinux) from source succeeds, but running the testsuite (with some segfaulting tests disabled - see issue34095) results in an assertion error: test_wrongsize (test.test_audioop.TestAudioop) ... test test_audioop failed -- Traceback (most recent call last): File "/home/vagrant/python2/src/Python-2.7.15/Lib/test/test_audioop.py", line 48, in test_max self.assertEqual(audioop.max(p(minvalues[w]), w), -minvalues[w]) AssertionError: -2147483648 != 2147483648L ok == FAIL: test_max (test.test_audioop.TestAudioop) -- Traceback (most recent call last): File "/home/vagrant/python2/src/Python-2.7.15/Lib/test/test_audioop.py", line 48, in test_max self.assertEqual(audioop.max(p(minvalues[w]), w), -minvalues[w]) AssertionError: -2147483648 != 2147483648L The commands leading to this are: cd Python-${pkgver} # Temporary workaround for FS#22322 # See http://bugs.python.org/issue10835 for upstream report sed -i "/progname =/s/python/python${_pybasever}/" Python/pythonrun.c # Enable built-in SQLite module to load extensions (fix FS#22122) sed -i "/SQLITE_OMIT_LOAD_EXTENSION/d" setup.py # FS#23997 sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python2|" Lib/cgi.py sed -i "s/python2.3/python2/g" Lib/distutils/tests/test_build_scripts.py \ Lib/distutils/tests/test_install_scripts.py # Ensure that we are using the system copy of various libraries (expat, zlib and libffi), # rather than copies shipped in the tarball rm -r Modules/expat rm -r Modules/zlib rm -r Modules/_ctypes/{darwin,libffi}* # clean up #!s find . -name '*.py' | \ xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" # Workaround asdl_c.py/makeopcodetargets.py errors after we touched the shebangs touch Include/Python-ast.h Python/Python-ast.c Python/opcode_targets.h # FS#48761 # http://bugs.python.org/issue25750 patch -Np1 -i ../descr_ref.patch export OPT="${CFLAGS}" ./configure --prefix=/usr \ --enable-shared \ --with-threads \ --enable-optimizations \ --with-lto \ --enable-ipv6 \ --enable-unicode=ucs4 \ --with-system-expat \ --with-system-ffi \ --with-dbmliborder=gdbm:ndbm \ --without-ensurepip make LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} \ xvfb-run "${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall -x test_idle test_bytes test_str test_string test_unicode test_userstring test_tuple test_tk test_ttk_guionly test_ctypes 2>&1 | tee log.reduced -- components: Build files: log.reduced messages: 321449 nosy: deep42thought priority: normal severity: normal status: open title: testsuite fails assertion versions: Python 2.7 Added file: https://bugs.python.org/file47684/log.reduced ___ Python tracker <https://bugs.python.org/issue34096> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34095] segfault in testsuite
New submission from Erich Eckner : building python 2.7.15 on archlinux32 from source succeeds, but running the testsuite segfaults with: test_writelines (idlelib.idle_test.test_io.PseudeOutputFilesTest) ... /usr/bin/xvfb-run: line 181: 3617 Segmentation fault (core dumped) DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 the executed commands are: cd Python-${pkgver} # Temporary workaround for FS#22322 # See http://bugs.python.org/issue10835 for upstream report sed -i "/progname =/s/python/python${_pybasever}/" Python/pythonrun.c # Enable built-in SQLite module to load extensions (fix FS#22122) sed -i "/SQLITE_OMIT_LOAD_EXTENSION/d" setup.py # FS#23997 sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python2|" Lib/cgi.py sed -i "s/python2.3/python2/g" Lib/distutils/tests/test_build_scripts.py \ Lib/distutils/tests/test_install_scripts.py # Ensure that we are using the system copy of various libraries (expat, zlib and libffi), # rather than copies shipped in the tarball rm -r Modules/expat rm -r Modules/zlib rm -r Modules/_ctypes/{darwin,libffi}* # clean up #!s find . -name '*.py' | \ xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" # Workaround asdl_c.py/makeopcodetargets.py errors after we touched the shebangs touch Include/Python-ast.h Python/Python-ast.c Python/opcode_targets.h # FS#48761 # http://bugs.python.org/issue25750 patch -Np1 -i ../descr_ref.patch export OPT="${CFLAGS}" ./configure --prefix=/usr \ --enable-shared \ --with-threads \ --enable-optimizations \ --with-lto \ --enable-ipv6 \ --enable-unicode=ucs4 \ --with-system-expat \ --with-system-ffi \ --with-dbmliborder=gdbm:ndbm \ --without-ensurepip make LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} \ xvfb-run "${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall 2>&1 | tee log.all -- components: Build files: log.all messages: 321447 nosy: deep42thought priority: normal severity: normal status: open title: segfault in testsuite versions: Python 2.7 Added file: https://bugs.python.org/file47682/log.all ___ Python tracker <https://bugs.python.org/issue34095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16012] pyexpat: Argument for UseForeignDTD should be optional
New submission from Erich Seifert: It seems the recent changes to Modules/pyexpat.c made the boolean 'flag' for UseForeignDTD mandatory although it was optional in previous Python releases. According to the docs the usage is UseForeignDTD([flag]), but calling UseForeignDTD without arguments leads to an error:: from xml.parsers import expat parser = expat.ParserCreate('utf8') parser.UseForeignDTD() Traceback (most recent call last): File stdin, line 1, in module TypeError: UseForeignDTD() takes exactly 1 argument (0 given) This was tested with version bfdf366a779a from hg repository. -- components: Extension Modules messages: 171108 nosy: eseifert priority: normal severity: normal status: open title: pyexpat: Argument for UseForeignDTD should be optional type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16012 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Commercial Products in Python
On Oct 21, 12:50 pm, Paulo J. Matos [EMAIL PROTECTED] wrote: Hi all, I was just wondering, if you wish to commercialize an application developed in Python, what's the way to go? I guess the only way is to sell the source, right? If this application is a Windows app, and can use .Net, you may wish to look at how Resolver Systems [1] did it. Their products are written in IronPython, a python implementation for .Net. 1. http://www.resolversystems.com/products/ Regards, Erich -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is slow
On May 22, 1:18 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: snip lots My mum's fast...more snipping snip some more Arnaud Was it a good idea to include that bit in a troll response? If English isn't your first language, it's one of those language idioms that's not very nice to say about someone's mother (especially your own mother). Erich -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python for no reason
On May 12, 12:27 pm, John Salerno [EMAIL PROTECTED] wrote: The *process* of learning is enough fun for me, and every now and then I do find a small use for Python that really pays off, but for the most part I'm wondering what people's thoughts are as far as simply learning it for the sake of learning. Does it seem like a silly endeavor to most people? Did anyone here learn a programming language when you didn't need to? If so, how much and in what capacity did you use it after you learned it? I am of the belief that there is no such thing as useless learning, or bad learning*. I have found that the more I learn about anything, the better I am at everything. I think this is because more knowledge/ understanding does: 1. gives me more 'entry points' for new knowledge, I can relate more bits to something I know, making the whole learning process easier. 2. allows me to better relate to people who I need to communicate with, becuase it is more likely there is a common point of knowledge/ interest to build from 3. gives me personal satisfaction in my life (self-actualization). When I learned python, I was a bartender, and was just learning it for fun. Only later did I become a computer programmer. I was lucky enough to find a job where I get to do a lot of my work in python. * There are times when learning new info set A is more productive than new info set B, depending on other constraints of time, energy, money, etc, B could be classified as unwise learning Regards, Erich -- http://mail.python.org/mailman/listinfo/python-list
Recurring patterns: Am I missing it, or can we get these added to the language?
Hello all, Today I found myself once again defining two functions that I use all the time: nsplit and iterable. These little helper functions of mine get used all the time when I work. Im sick of having to define them (but am very good at it these days, less than 1 typo per function!). It leads me to the following questions 1. Is this functionality already built in and im just missing it 2. Is there some well known, good technique for these that I missed? 3. Insert question I need to ask here (with a response) These are the funtions w/ explaination: def nsplit(s,p,n): n -= 1 l = s.split(p, n) if len(l) n: l.extend([''] * (n - len(l))) return l This is like split() but returns a list of exactly lenght n. This is very useful when using unpacking, e.g.: x, y = nsplit('foo,bar,baz', ',', 2) def iterable(item, count_str=False): if not count_str and isinstance(item, str): return False try: iter(item) except: return False return True This is just simple boolean test for whether or not an object is iterable. I would like to see this in builtins, to mirror callable. The optional count_str adds flexibility for string handling, since sometimes I need to iterate over a string, but usually not. I frequently use it to simplify my case handling in this type of costruct: def foo(bar): bar = bar if iterable(bar) else [bar] for x in bar: Thanks for feeback, Erich -- http://mail.python.org/mailman/listinfo/python-list
Re: Google App Engine
On Apr 9, 3:51 am, Duncan Booth [EMAIL PROTECTED] wrote: snip The backend data store, while it has a vaguely SQLish query language is an object database not a relational database, i.e. more like ZODB than MySQL. It uses similar concepts to django's data api but isn't the same. It should be possible to write something simple to replace it, but given that you only need to migrate away from Google when your data or page hits get large, you need to replace it with something scalable. I have a bet with a coworker that someone will implement the api, in a way that makes migration away from Google easy, within a month. (actually, the bet is just that there will be a project with this goal). The reason I mention it here, is that he had the same comments as you regarding this. My thinking is that (if past experiences can be used as a yardstick) the python community will see this deficiency and work to correct it. As a result of that thinking, I am fairly certain that this concern is not a big concern. The authentication thing, thats a bit different. -- http://mail.python.org/mailman/listinfo/python-list
Re: Self-referencing decorator function parameters
On Apr 2, 10:13 am, Thomas Dimson [EMAIL PROTECTED] wrote: I guess my real question is: why does wrapping the call to be call=lambda x: DecorateMe.callMe(x) somehow fix the issue with this temporary namespace? It seems strange to me that defining an additional function (through lambda) would allow me to see/add more members to the namespace. This works because of the very same mechanism that allows decorators to work. When the decorator in your example is called, it then evaluates the inner statements, including the creation of the function inner (the def ...). Similarly, when you do the lambda above, python points call to the lambda function, but does not evaluate it until later, when the youBet method is run. By the time youBet is run, the DecorateMe class exists, so this will properly evaluate. I hope the above is clear, I haven't had my coffee yet. regards, Erich -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycon disappointment
On Mar 20, 12:39 pm, Ed Leafe [EMAIL PROTECTED] wrote: On Mar 20, 2008, at 11:54 AM, [EMAIL PROTECTED] wrote: Number Three: Too much code, not enough concept. Presenters this one's for you. I can't count the number of presentations I attended where the presenter would click through three slides of pycode just to show us a two or three-line snippet that illustrated their point. Worse yet, it was often at the bottom of the screen so no one but the front row could see it. This goes for text two. I saw some great presentations as well, and they had limited text on each slide. The last thing your audience wants to see is a slide drenched in text of any kind. This is good advice: simple slides serve as organization cues, but the content should come from the speaker. The worst case (only saw this twice at this year's PyCon) is when there is a text-heavy slide that the presenter simply reads. We can all read it ourselves! Your job is to elaborate on the topic. I'd like to see two things regarding slides: first, if at all possible, set a limit on the percentage of the talk that can consist of slides. I would much rather see the presenter show actual demonstrations of what they're talking about than simply talking about it. If that's not possible, then in the session description, clearly state the % of the talk that will be slides. Perhaps there are people who like to sit in a room and watch long PowerPoint (-type) presentations, but I'm not one of them. Let's see some code! Let's see stuff working (and sometimes crashing!), and how changes affect the results. When I've presented at PyCon and other conferences, that's the part that I spend the most time on: preparing demonstrations. It's not easy to do; certainly much more difficult than creating a slide that sums up what the demo does. But it makes for a much more interesting session! -- Ed Leafe I'd like to see code listings made available to download where appropriate. That way the slides dont have much hard to read content, and we can look at the bits of code we find tricky as we see fit. And if we get bored with bits, we can play with code! Erich. -- http://mail.python.org/mailman/listinfo/python-list
Generator woes
Hi all, I am trying to get the following generator to work to these goals: 1. When it recieves an exception (via a throw()) it yeilds the value of handler.remaining. Otherwise it yeilds None. 2. Send adds data to the generator. Goal 2 is working great. Goal 1 on the other hand, is not working. The result of a throw is always None. Any reasons why this does not work as I expect? If not, what is wrong? Code: def make_handler(): def handler(): eol = '\r\n' handler.remaining = 1 response = '' data = '' while not response.endswith(eol): trv = None try: ndata = (yield trv) if ndata: response += ndata trv = None except: trv = handler.remaining response = response.strip() yield response * 2 res = handler() res.next() return res x = make_handler() y = x.send('a') print 'y (should be None):',y y = x.send('b') print 'y (should be None):',y y = x.throw(Exception) print 'y (should be 1):',y y = x.send('c\r\n') print 'y (should be abcabc):',y Output: y (should be None): None y (should be None): None y (should be 1): None y (should be abcabc): abcabc Thanks, Erich -- http://mail.python.org/mailman/listinfo/python-list
Re: Generator woes
On Mar 13, 12:33 am, Erich [EMAIL PROTECTED] wrote: Hi all, I am trying to get the following generator to work to these goals: 1. When it recieves an exception (via a throw()) it yeilds the value of handler.remaining. Otherwise it yeilds None. 2. Send adds data to the generator. Goal 2 is working great. Goal 1 on the other hand, is not working. The result of a throw is always None. Any reasons why this does not work as I expect? If not, what is wrong? Code: def make_handler(): def handler(): eol = '\r\n' handler.remaining = 1 response = '' data = '' while not response.endswith(eol): trv = None try: ndata = (yield trv) if ndata: response += ndata trv = None except: trv = handler.remaining response = response.strip() yield response * 2 res = handler() res.next() return res x = make_handler() y = x.send('a') print 'y (should be None):',y y = x.send('b') print 'y (should be None):',y y = x.throw(Exception) print 'y (should be 1):',y y = x.send('c\r\n') print 'y (should be abcabc):',y Output: y (should be None): None y (should be None): None y (should be 1): None y (should be abcabc): abcabc Thanks, Erich Never mind its obviously a case of I need to look foolish before I can see the simple error. Im going to blush and hide now. Erich -- http://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator
On Feb 12, 5:15 am, Ben C [EMAIL PROTECTED] wrote: I think this works OK, but it seems a bit odd. Is there something more Pythonic I should be doing? I have a similar tree to the one you describe here at work. I have a visit function that is very similar to yours, but takes function arguments for doing pre- and/or post- order operations on the node (code below). It also yeilds the nodes, but in a postorder manner. The flexibility is quite useful. Regards, Erich def visit(self,prefunc = None, postfunc = None): if prefunc: prefunc(self) for child in self.children: for y in child.visit(prefunc, postfunc): yield y if postfunc: postfunc(self) yield self -- http://mail.python.org/mailman/listinfo/python-list
Re: concatenating strings
thank you, i just plainly overlooked it ; ) now it works -- http://mail.python.org/mailman/listinfo/python-list
Re: Premature wakeup of time.sleep()
Thank you every body for your comments. Especially Jeff Epler for your hint about NTP. You're right. I see a (constant but somewhat huge)time drift of about 1 ms/min which I can correct for. Thank you Steve Horsley for the clarification of the interrupts that would end the delay. I didn't think of something as trivial as ^C. And thank you Nick Craig-Wood for the shell script to get hands on the HZ value. I had to modify it a little as I do not have /proc/interrupts, but I've got the idea. I measure about 100 and so I have a 10 ms granularity in my VPS as you predicted. Erich -- http://mail.python.org/mailman/listinfo/python-list