[issue1125] bytes.split shold have same interface as str.split, or different name
Stefan Sonnenberg-Carstens added the comment: IMHO I also aggree that strings and bytes (list of bytes) should have the same interface. It is common sense that talking about strings most programmers think of a list of bytes composing it (char *). So the abbreviation should also hold true with python. -- nosy: +pythonmeister __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1125 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1765140] logging: delay_fh option and configuration kwargs
Vinay Sajip added the comment: Thanks for the patch. I think it would be simpler to just implement an optional delay parameter in FileHandler and its subclasses: then the configuration stuff need not be touched at all, since the delay parameter can be specified in the configuration file. There would then be no need for a callback or a file-opening closure: If delay is False (the default), FileHandler would behave as it does now. If True, then the open code in FileHandler's constructor would be deferred until the time emit() was called on the instance. Would this meet your needs? _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1765140 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1099] Mac compile fails with pydebug and framework enabled
Elias Pipping added the comment: I can reproduce this problem on both an intel and a powerpc mac. With '--with-pydebug --enable-framework --enable-universalsdk', the behavior is very much different: On a powerpc mac, configure fails with 'checking size of wchar_t...configure: error: cannot compute sizeof (wchar_t)' On an intel mac, configure and make succeed; a test fails, though (which normally passes, e.g. when no arguments at all were passed to configure). The failing test is: test_xmlrpc. -- nosy: +pipping __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1099 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1131] Reference Manual: for statement links to break statement
New submission from Martoon: Error in the Windows distro documentation. If you go to for or for statement in the index, it brings you to the doc page for The break statement. -- components: Documentation, Windows messages: 55749 nosy: Martoon severity: minor status: open title: Reference Manual: for statement links to break statement versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1131 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1125] bytes.split shold have same interface as str.split, or different name
Guido van Rossum added the comment: Updated patch that also modifies bytes.*strip(). __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1125 __Index: Objects/bytesobject.c === --- Objects/bytesobject.c (revision 58052) +++ Objects/bytesobject.c (working copy) @@ -2104,7 +2104,7 @@ Py_LOCAL_INLINE(PyObject *) split_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { -register Py_ssize_t i, j, count=0; +register Py_ssize_t i, j, count = 0; PyObject *str; PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); @@ -2113,7 +2113,7 @@ i = j = 0; while ((j len) (maxcount-- 0)) { -for(; jlen; j++) { +for(; j len; j++) { /* I found that using memchr makes no difference */ if (s[j] == ch) { SPLIT_ADD(s, i, j); @@ -2133,28 +2133,72 @@ return NULL; } +#define ISSPACE(c) (isspace(Py_CHARMASK(c)) ((c) 0x80) == 0) + +Py_LOCAL_INLINE(PyObject *) +split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount) +{ +register Py_ssize_t i, j, count = 0; +PyObject *str; +PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); + +if (list == NULL) +return NULL; + +for (i = j = 0; i len; ) { + /* find a token */ + while (i len ISSPACE(s[i])) + i++; + j = i; + while (i len !ISSPACE(s[i])) + i++; + if (j i) { + if (maxcount-- = 0) + break; + SPLIT_ADD(s, j, i); + while (i len ISSPACE(s[i])) + i++; + j = i; + } +} +if (j len) { + SPLIT_ADD(s, j, len); +} +FIX_PREALLOC_SIZE(list); +return list; + + onError: +Py_DECREF(list); +return NULL; +} + PyDoc_STRVAR(split__doc__, -B.split(sep [,maxsplit]) - list of bytes\n\ +B.split([sep [, maxsplit]]) - list of bytes\n\ \n\ Return a list of the bytes in the string B, using sep as the\n\ -delimiter. If maxsplit is given, at most maxsplit\n\ -splits are done.); +delimiter. If sep is not given, B is split on ASCII whitespace\n\ +characters (space, tab, return, newline, formfeed, vertical tab).\n\ +If maxsplit is given, at most maxsplit splits are done.); static PyObject * bytes_split(PyBytesObject *self, PyObject *args) { Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j; -Py_ssize_t maxsplit = -1, count=0; +Py_ssize_t maxsplit = -1, count = 0; const char *s = PyBytes_AS_STRING(self), *sub; -PyObject *list, *str, *subobj; +PyObject *list, *str, *subobj = Py_None; #ifdef USE_FAST Py_ssize_t pos; #endif -if (!PyArg_ParseTuple(args, O|n:split, subobj, maxsplit)) +if (!PyArg_ParseTuple(args, |On:split, subobj, maxsplit)) return NULL; if (maxsplit 0) maxsplit = PY_SSIZE_T_MAX; + +if (subobj == Py_None) +return split_whitespace(s, len, maxsplit); + if (PyBytes_Check(subobj)) { sub = PyBytes_AS_STRING(subobj); n = PyBytes_GET_SIZE(subobj); @@ -2167,7 +2211,7 @@ PyErr_SetString(PyExc_ValueError, empty separator); return NULL; } -else if (n == 1) +if (n == 1) return split_char(s, len, sub[0], maxsplit); list = PyList_New(PREALLOC_SIZE(maxsplit)); @@ -2293,26 +2337,71 @@ return NULL; } +Py_LOCAL_INLINE(PyObject *) +rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount) +{ +register Py_ssize_t i, j, count = 0; +PyObject *str; +PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); + +if (list == NULL) +return NULL; + +for (i = j = len - 1; i = 0; ) { + /* find a token */ + while (i = 0 Py_UNICODE_ISSPACE(s[i])) + i--; + j = i; + while (i = 0 !Py_UNICODE_ISSPACE(s[i])) + i--; + if (j i) { + if (maxcount-- = 0) + break; + SPLIT_ADD(s, i + 1, j + 1); + while (i = 0 Py_UNICODE_ISSPACE(s[i])) + i--; + j = i; + } +} +if (j = 0) { + SPLIT_ADD(s, 0, j + 1); +} +FIX_PREALLOC_SIZE(list); +if (PyList_Reverse(list) 0) +goto onError; + +return list; + + onError: +Py_DECREF(list); +return NULL; +} + PyDoc_STRVAR(rsplit__doc__, B.rsplit(sep [,maxsplit]) - list of bytes\n\ \n\ Return a list of the sections in the byte B, using sep as the\n\ delimiter, starting at the end of the bytes and working\n\ -to the front. If maxsplit is given, at most maxsplit splits are\n\ -done.); +to the front. If sep is not given, B is split on ASCII whitespace\n\ +characters (space, tab, return, newline, formfeed, vertical tab).\n\ +If maxsplit is given, at most maxsplit splits are done.); static PyObject * bytes_rsplit(PyBytesObject *self, PyObject *args) { Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j; -Py_ssize_t maxsplit = -1, count=0; +Py_ssize_t maxsplit = -1, count = 0; const char *s = PyBytes_AS_STRING(self), *sub; -PyObject *list, *str, *subobj; +PyObject *list, *str,
[issue1125] bytes.split shold have same interface as str.split, or different name
Guido van Rossum added the comment: New version with corrected docstrings and buffer support for *split() as well. Added unittests. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1125 __Index: Objects/bytesobject.c === --- Objects/bytesobject.c (revision 58052) +++ Objects/bytesobject.c (working copy) @@ -2104,7 +2104,7 @@ Py_LOCAL_INLINE(PyObject *) split_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount) { -register Py_ssize_t i, j, count=0; +register Py_ssize_t i, j, count = 0; PyObject *str; PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); @@ -2113,7 +2113,7 @@ i = j = 0; while ((j len) (maxcount-- 0)) { -for(; jlen; j++) { +for(; j len; j++) { /* I found that using memchr makes no difference */ if (s[j] == ch) { SPLIT_ADD(s, i, j); @@ -2133,46 +2133,91 @@ return NULL; } +#define ISSPACE(c) (isspace(Py_CHARMASK(c)) ((c) 0x80) == 0) + +Py_LOCAL_INLINE(PyObject *) +split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount) +{ +register Py_ssize_t i, j, count = 0; +PyObject *str; +PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); + +if (list == NULL) +return NULL; + +for (i = j = 0; i len; ) { + /* find a token */ + while (i len ISSPACE(s[i])) + i++; + j = i; + while (i len !ISSPACE(s[i])) + i++; + if (j i) { + if (maxcount-- = 0) + break; + SPLIT_ADD(s, j, i); + while (i len ISSPACE(s[i])) + i++; + j = i; + } +} +if (j len) { + SPLIT_ADD(s, j, len); +} +FIX_PREALLOC_SIZE(list); +return list; + + onError: +Py_DECREF(list); +return NULL; +} + PyDoc_STRVAR(split__doc__, -B.split(sep [,maxsplit]) - list of bytes\n\ +B.split([sep [, maxsplit]]) - list of bytes\n\ \n\ -Return a list of the bytes in the string B, using sep as the\n\ -delimiter. If maxsplit is given, at most maxsplit\n\ -splits are done.); +Return a list of the bytes in the string B, using sep as the delimiter.\n\ +If sep is not given, B is split on ASCII whitespace charcters\n\ +(space, tab, return, newline, formfeed, vertical tab).\n\ +If maxsplit is given, at most maxsplit splits are done.); static PyObject * bytes_split(PyBytesObject *self, PyObject *args) { Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j; -Py_ssize_t maxsplit = -1, count=0; +Py_ssize_t maxsplit = -1, count = 0; const char *s = PyBytes_AS_STRING(self), *sub; -PyObject *list, *str, *subobj; +PyObject *list, *str, *subobj = Py_None; +PyBuffer vsub; #ifdef USE_FAST Py_ssize_t pos; #endif -if (!PyArg_ParseTuple(args, O|n:split, subobj, maxsplit)) +if (!PyArg_ParseTuple(args, |On:split, subobj, maxsplit)) return NULL; if (maxsplit 0) maxsplit = PY_SSIZE_T_MAX; -if (PyBytes_Check(subobj)) { -sub = PyBytes_AS_STRING(subobj); -n = PyBytes_GET_SIZE(subobj); -} -/* XXX - use the modern buffer interface */ -else if (PyObject_AsCharBuffer(subobj, sub, n)) + +if (subobj == Py_None) +return split_whitespace(s, len, maxsplit); + +if (_getbuffer(subobj, vsub) 0) return NULL; +sub = vsub.buf; +n = vsub.len; if (n == 0) { PyErr_SetString(PyExc_ValueError, empty separator); +PyObject_ReleaseBuffer(subobj, vsub); return NULL; } -else if (n == 1) +if (n == 1) return split_char(s, len, sub[0], maxsplit); list = PyList_New(PREALLOC_SIZE(maxsplit)); -if (list == NULL) +if (list == NULL) { +PyObject_ReleaseBuffer(subobj, vsub); return NULL; +} #ifdef USE_FAST i = j = 0; @@ -2198,10 +2243,12 @@ #endif SPLIT_ADD(s, i, len); FIX_PREALLOC_SIZE(list); +PyObject_ReleaseBuffer(subobj, vsub); return list; onError: Py_DECREF(list); +PyObject_ReleaseBuffer(subobj, vsub); return NULL; } @@ -2293,44 +2340,90 @@ return NULL; } +Py_LOCAL_INLINE(PyObject *) +rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount) +{ +register Py_ssize_t i, j, count = 0; +PyObject *str; +PyObject *list = PyList_New(PREALLOC_SIZE(maxcount)); + +if (list == NULL) +return NULL; + +for (i = j = len - 1; i = 0; ) { + /* find a token */ + while (i = 0 Py_UNICODE_ISSPACE(s[i])) + i--; + j = i; + while (i = 0 !Py_UNICODE_ISSPACE(s[i])) + i--; + if (j i) { + if (maxcount-- = 0) + break; + SPLIT_ADD(s, i + 1, j + 1); + while (i = 0 Py_UNICODE_ISSPACE(s[i])) + i--; + j = i; + } +} +if (j = 0) { + SPLIT_ADD(s, 0, j + 1); +} +FIX_PREALLOC_SIZE(list); +if (PyList_Reverse(list) 0) +goto onError; + +return list; + + onError: +Py_DECREF(list); +return NULL; +} +
[issue1125] bytes.split shold have same interface as str.split, or different name
Changes by Guido van Rossum: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1125 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1125] bytes.split shold have same interface as str.split, or different name
Changes by Guido van Rossum: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1125 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1099] Mac compile fails with pydebug and framework enabled
Bill Janssen added the comment: Which versions of OS X, please? And which Xcode versions? -- nosy: +janssen __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1099 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1132] compile error in poplib.py
New submission from André: File c:\Python30\lib\poplib.py, line 137, in _getlongresp while line != '.': TypeError: can't compare bytes and str -- components: Library (Lib) messages: 55753 nosy: andre severity: normal status: open title: compile error in poplib.py type: compile error versions: Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1132 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1107] 2to3, lambda with non-tuple argument inside parenthesis
Collin Winter added the comment: Fixed in r58055, r58056. -- resolution: - fixed status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1107 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1132] compile error in poplib.py
Bill Janssen added the comment: Isn't this 1094? -- nosy: +janssen __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1132 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1133] python3.0-config raises SyntaxError
New submission from Viktor Ferenczi: Running python3.0-config raises SyntaxError: $ python3.0-config File /usr/local/bin/python3.0-config, line 33 print sysconfig.PREFIX ^ SyntaxError: invalid syntax OS: Ununtu Feisty, up-to-date Python: Python 3.0a1, compiled from source, configured with: --prefix=/usr/local -- components: Demos and Tools, Installation messages: 55757 nosy: complex severity: normal status: open title: python3.0-config raises SyntaxError versions: Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1133 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1134] Parsing a simple script eats all of your memory
New submission from Viktor Ferenczi: Read the WARNING below, then run the attached script with Python3.0a2. It will eat all of your memory. WARNING: Keep a process killing tool or an extra command line at your fingertips, since this script could render your machine unusable in about 10-20 seconds depending on your memory and CPU speed!!! YOU ARE WARNED! OS: Ubuntu Feisty, up-to-date Python: Python3.0a1, built from sources, configured with: --prefix=/usr/local -- components: Interpreter Core files: hungry_script.py messages: 55758 nosy: complex severity: critical status: open title: Parsing a simple script eats all of your memory type: crash versions: Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1134 __#!/usr/local/bin/python3.0 # -*- coding: ascii -*- def this_will_eat_all_of_your_memory(): ''' Parsing this function will eat all of your memory. It's a BUG. pass''' ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1134] Parsing a simple script eats all of your memory
Viktor Ferenczi added the comment: Confirmed on Windows: OS: Windows XP SP2 ENG Python: Python3.0a1 MSI installer, default installation __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1134 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1134] Parsing a simple script eats all of your memory
Viktor Ferenczi added the comment: Works fine (does nothing) with Python 2.4.4 and Python 2.5.1 under Windows, so this bug must be caused by some new code in Python3.0a1. The bug depends on the contents of the doc string. There's another strange behavior if you write the word this in the docstring somewhere. The docstring could be parsed as source code somehow and causes strange things to the new parser. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1134 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1134] Parsing a simple script eats all of your memory
Viktor Ferenczi added the comment: Errata: In the first line of my original post I mean Python3.0a1 and not 3.0a2, certainly. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1134 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1135] xview/yview of Tix.Grid is broken
New submission from Hirokazu Yamamoto : Attached code test_tixGrid.py fails with following error message. TypeError: yview() takes exactly 1 argument (4 given) -- components: Tkinter files: test_tixGrid.py messages: 55762 nosy: ocean-city severity: normal status: open title: xview/yview of Tix.Grid is broken type: behavior versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1135 __import Tkinter as Tk def scrollable(Widget, master, *a, **kw): frame = Tk.Frame(master) frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) widget = Widget(frame, *a, **kw) widget.grid(row=0, column=0, sticky=news) scroll_x = Tk.Scrollbar(frame, command=widget.xview, orient=Tk.HORIZONTAL) scroll_x.grid(row=1, column=0, sticky=news) scroll_y = Tk.Scrollbar(frame, command=widget.yview, orient=Tk.VERTICAL) scroll_y.grid(row=0, column=1, sticky=news) widget.configure(xscrollcommand=scroll_x.set, yscrollcommand=scroll_y.set) for name in (pack, grid, place): setattr(widget, name, getattr(frame, name)) return widget import Tix root = Tix.Tk() grid = scrollable(Tix.Grid, root) grid.pack(fill=Tix.BOTH, expand=True) for y in xrange(30): for x in xrange(6): grid.set(x, y, text=repr((x, y))) root.mainloop() ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1135] xview/yview of Tix.Grid is broken
Hirokazu Yamamoto added the comment: Probably right fix is attached file fix_tixGrid.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1135 __Index: Lib/lib-tk/Tix.py === --- Lib/lib-tk/Tix.py (revision 58052) +++ Lib/lib-tk/Tix.py (working copy) @@ -1865,16 +1865,16 @@ # def size dim index ?option value ...? # def unset x y -def xview(self): -return self._getdoubles(self.tk.call(self, 'xview')) +def xview(self, *args): +return self._getdoubles(self.tk.call(self, 'xview', *args)) def xview_moveto(self, fraction): self.tk.call(self,'xview', 'moveto', fraction) def xview_scroll(self, count, what=units): Scroll right (count0) or left count of units|pages self.tk.call(self, 'xview', 'scroll', count, what) -def yview(self): -return self._getdoubles(self.tk.call(self, 'yview')) +def yview(self, *args): +return self._getdoubles(self.tk.call(self, 'yview', *args)) def yview_moveto(self, fraction): self.tk.call(self,'ysview', 'moveto', fraction) def yview_scroll(self, count, what=units): ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com