[issue1272] Decode __file__ and co_filename to unicode using fs default
Guido van Rossum added the comment: Committed revision 58466. Fingers crossed. -- resolution: - accepted status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1272 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1130] Idle - Save (buffer) - closes IDLE and does not save file (Windows XP)
Kurt B. Kaiser added the comment: I caught the first part, but not the second using GNU/Linux. I think that eol_convention can be a class variable, since os.linesep isn't going to change from file to file. Thanks for the report! r58465. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1130 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1643641] Fix Bug 1362475 Text.edit_modified() doesn't work
Changes by Georg Brandl: -- resolution: - duplicate status: open - closed superseder: - Text.edit_modified() fails _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1643641 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1074462] Irregular behavior of datetime.__str__()
Zooko O'Whielacronx added the comment: Here is a note for the next person who comes to this ticket wondering why isoformat() exhibits this slightly un-Pythonic behavior. If you want to use isoformat() to produce, for example, timestamps for your logfiles, you'll need to do something like the following. (I do hope you noticed the documentation and didn't use isoformat() in the naive way, or your log files will very rarely have a different format than you expected.) d = datetime.datetime.utcfromtimestamp(when) if d.microsecond: return d.isoformat( )[:-3]+Z else: return d.isoformat( ) + .000Z http://allmydata.org/trac/tahoe/browser/src/allmydata/node.py#L21 -- nosy: +zooko _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1074462 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
atsuo ishimoto added the comment: That's fine with me. Please replace PyErr_Print() with PyErr_Clear(). _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1074462] Irregular behavior of datetime.__str__()
Skip Montanaro added the comment: Zooko Here is a note for the next person who comes to this ticket Zooko wondering why isoformat() exhibits this slightly un-Pythonic Zooko behavior. What are you referring to, that it doesn't display any microseconds when the microsecond field happens to be 0 or that it doesn't truncate the fractions of a second to milliseconds? Skip _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1074462 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1263] PEP 3137 patch - str8/str comparison should return false
Thomas Lee added the comment: Hack to make Python/codecs.c use Unicode strings internally. I recognize the way I have fixed it here is probably not ideal (basically ripped out PyString_*, replaced with a PyMem_Malloc/PyMem_Free call) but it fixes 10-12 tests that were failing with my earlier changes. If anybody can recommend a nice way to fix this, I'm all ears. The following still fail for me with this patch applied: -- test_compile This is due to PyString_*/PyUnicode_*/PyBytes_* confusion in the assembler struct (specifically: a_lnotab and a_bytecode) in Python/compile.c - tried replacing PyString_* calls with PyBytes_* calls, but this raises a TypeError because PyBytes is not hashable ... not sure what exactly is causing this. -- test_ctypes Looks like a simple case of ctypes using str8 instead of str. Appears to be an easy fix. -- test_modulefinder Failing because str8 = str is now an invalid operation -- test_set This test needs some love. -- test_sqlite Not sure what's going on here. -- test_str This one is a little tricky: str8/str with __str__/__unicode__ ... how is this test supposed to behave with the fix in this patch? -- test_struct unpack/pack not transitive - what does that mean? -- test_subprocess Like modulefinder, this is probably just due to the use of str8 over str internally in the subprocess module. Likely to be an easy fix. The following tests fail for me irrespective of whether or not I have r4 of my patch applied: -- test_doctest -- test_email -- test_nis -- test_pty If anybody can give this new patch a try and let me know the result it would be much appreciated. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1263 __Index: Python/codecs.c === --- Python/codecs.c (revision 58468) +++ Python/codecs.c (working copy) @@ -55,16 +55,15 @@ size_t len = strlen(string); char *p; PyObject *v; - + if (len PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, string is too large); return NULL; } -v = PyString_FromStringAndSize(NULL, len); -if (v == NULL) - return NULL; -p = PyString_AS_STRING(v); +p = PyMem_Malloc(len + 1); +if (p == NULL) +return NULL; for (i = 0; i len; i++) { register char ch = string[i]; if (ch == ' ') @@ -73,6 +72,11 @@ ch = tolower(Py_CHARMASK(ch)); p[i] = ch; } +p[i] = '\0'; +v = PyUnicode_FromString(p); +if (v == NULL) +return NULL; +PyMem_Free(p); return v; } @@ -112,7 +116,7 @@ v = normalizestring(encoding); if (v == NULL) goto onError; -PyString_InternInPlace(v); +PyUnicode_InternInPlace(v); /* First, try to lookup the name in the registry dictionary */ result = PyDict_GetItem(interp-codec_search_cache, v); @@ -193,7 +197,7 @@ if (errors) { PyObject *v; - v = PyString_FromString(errors); + v = PyUnicode_FromString(errors); if (v == NULL) { Py_DECREF(args); return NULL; Index: Python/structmember.c === --- Python/structmember.c (revision 58468) +++ Python/structmember.c (working copy) @@ -51,13 +51,13 @@ v = Py_None; } else - v = PyString_FromString(*(char**)addr); + v = PyUnicode_FromString(*(char**)addr); break; case T_STRING_INPLACE: - v = PyString_FromString((char*)addr); + v = PyUnicode_FromString((char*)addr); break; case T_CHAR: - v = PyString_FromStringAndSize((char*)addr, 1); + v = PyUnicode_FromStringAndSize((char*)addr, 1); break; case T_OBJECT: v = *(PyObject **)addr; @@ -225,8 +225,8 @@ Py_XDECREF(oldv); break; case T_CHAR: - if (PyString_Check(v) PyString_Size(v) == 1) { - *(char*)addr = PyString_AsString(v)[0]; + if (PyUnicode_Check(v) PyUnicode_GetSize(v) == 1) { + *(char*)addr = PyUnicode_AsString(v)[0]; } else { PyErr_BadArgument(); Index: Objects/unicodeobject.c === --- Objects/unicodeobject.c (revision 58468) +++ Objects/unicodeobject.c (working copy) @@ -6224,16 +6224,6 @@ if (PyUnicode_Check(left) PyUnicode_Check(right)) return unicode_compare((PyUnicodeObject *)left, (PyUnicodeObject *)right); -if ((PyString_Check(left) PyUnicode_Check(right)) || -(PyUnicode_Check(left) PyString_Check(right))) { -if (PyUnicode_Check(left)) -left = _PyUnicode_AsDefaultEncodedString(left, NULL); -if (PyUnicode_Check(right)) -right = _PyUnicode_AsDefaultEncodedString(right, NULL); -assert(PyString_Check(left)); -assert(PyString_Check(right)); -return PyObject_Compare(left, right); -} PyErr_Format(PyExc_TypeError, Can't compare %.100s and %.100s,
[issue1279] os.system() oddity under Windows XP SP2
New submission from Stefan Sonnenberg-Carstens: When doing such os.system(a command wich writes a outfile) f = open(the file the command before wrote) the file is empty. If I do this: os.popen(a command wich writes a outfile) f = open(the file the command before wrote) everything is fine -- components: Interpreter Core messages: 56439 nosy: pythonmeister severity: major status: open title: os.system() oddity under Windows XP SP2 type: behavior versions: Python 2.3 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1279 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1074462] Irregular behavior of datetime.__str__()
Zooko O'Whielacronx added the comment: I meant that it special-cases .microseconds == 0. If I want to produce a custom output format using Python Standard Library, I expect to have to slice, add my own fields and so forth, but I don't expect to need an if to handle a special-case that is there for improving the appearance to human readers. That's something I had to do a lot more often when I worked in Perl. Even if the cost of changing the definition of isoformat() is too high at this point, I still wanted to post my code from http://allmydata.org as an example to other users so that they can use isoformat() safely. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1074462 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1279] os.system() oddity under Windows XP SP2
Tim Golden added the comment: Not, apparently, on my (XP SP2) box: dump Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import os os.system (python -c f=open ('temp.txt','w');f.write('hello');f.close ()); print open (temp.txt).read () 0 hello /dump Perhaps you could provide a runnable piece of code which demonstrates the problem? -- nosy: +tim.golden __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1279 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1074462] Irregular behavior of datetime.__str__()
Skip Montanaro added the comment: Zooko I meant that it special-cases .microseconds == 0. Tim indicated in his comment that the behavior is both by design and documented and isn't going to change. In an earlier comment I showed how to achieve the result you ased for in one line. Here's another example using your desire for millisecond display resolution: dt.replace(microsecond=0).strftime(%Y-%m-%dT%H:%M:%S) + .%03dZ % (dt.microsecond//1000) '2007-10-15T08:24:02.509Z' Also, I have a patch for py3k which adds a %f format specifier to strftime. I still have to make some other additions, but you're more than welcome to review what's there now: http://bugs.python.org/issue1158 Skip _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1074462 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1280] PEP 3137: Make PyString's indexing and iteration return integers
New submission from Alexandre Vassalotti: Here a preliminary patch to make PyString return integers on indexing and iteration. There is still quite a few XXX in the patch, that I would like to fix. However, the good thing is all tests passes. -- components: Interpreter Core files: string_iter_ret_ints.patch messages: 56442 nosy: alexandre.vassalotti severity: normal status: open title: PEP 3137: Make PyString's indexing and iteration return integers versions: Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1280 __Index: Objects/stringobject.c === --- Objects/stringobject.c (revision 58458) +++ Objects/stringobject.c (working copy) @@ -1233,23 +1233,13 @@ static PyObject * string_item(PyStringObject *a, register Py_ssize_t i) { - char pchar; - PyObject *v; + if (i 0) + i += Py_Size(a); if (i 0 || i = Py_Size(a)) { PyErr_SetString(PyExc_IndexError, string index out of range); return NULL; } - pchar = a-ob_sval[i]; - v = (PyObject *)characters[pchar UCHAR_MAX]; - if (v == NULL) - v = PyString_FromStringAndSize(pchar, 1); - else { -#ifdef COUNT_ALLOCS - one_strings++; -#endif - Py_INCREF(v); - } - return v; + return PyInt_FromLong((unsigned char)a-ob_sval[i]); } static PyObject* @@ -5150,8 +5140,8 @@ assert(PyString_Check(seq)); if (it-it_index PyString_GET_SIZE(seq)) { - item = PyString_FromStringAndSize( - PyString_AS_STRING(seq)+it-it_index, 1); + item = PyInt_FromLong( + (unsigned char)seq-ob_sval[it-it_index]); if (item != NULL) ++it-it_index; return item; Index: Lib/modulefinder.py === --- Lib/modulefinder.py (revision 58458) +++ Lib/modulefinder.py (working copy) @@ -367,7 +367,7 @@ consts = co.co_consts LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME while code: -c = code[0] +c = chr(code[0]) if c in STORE_OPS: oparg, = unpack('H', code[1:3]) yield store, (names[oparg],) Index: Lib/encodings/__init__.py === --- Lib/encodings/__init__.py (revision 58458) +++ Lib/encodings/__init__.py (working copy) @@ -54,7 +54,10 @@ chars = [] punct = False -for c in encoding: +# 'encoding' is a bytes (PyString) object, thus its iterator returns +# integers. So, convert 'encoding' to Unicode before iterating over it. +# XXX Should _PyCodec_Lookup() pass a Unicode object, instead? +for c in str(encoding): if c.isalnum() or c == '.': if punct and chars: chars.append('_') Index: Lib/test/test_set.py === --- Lib/test/test_set.py (revision 58458) +++ Lib/test/test_set.py (working copy) @@ -72,7 +72,7 @@ self.assertEqual(type(u), self.thetype) self.assertRaises(PassThru, self.s.union, check_pass_thru()) self.assertRaises(TypeError, self.s.union, [[]]) -for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: +for C in set, frozenset, dict.fromkeys, str, list, tuple: self.assertEqual(self.thetype('abcba').union(C('cdc')), set('abcd')) self.assertEqual(self.thetype('abcba').union(C('efgfe')), set('abcefg')) self.assertEqual(self.thetype('abcba').union(C('ccb')), set('abc')) @@ -96,7 +96,7 @@ self.assertEqual(self.s, self.thetype(self.word)) self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.intersection, check_pass_thru()) -for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: +for C in set, frozenset, dict.fromkeys, str, list, tuple: self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc')) self.assertEqual(self.thetype('abcba').intersection(C('efgfe')), set('')) self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc')) @@ -121,7 +121,7 @@ self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.difference, check_pass_thru()) self.assertRaises(TypeError, self.s.difference, [[]]) -for C in set, frozenset, dict.fromkeys, str, str8, list, tuple: +for C in set, frozenset, dict.fromkeys, str, list, tuple: self.assertEqual(self.thetype('abcba').difference(C('cdc')), set('ab')) self.assertEqual(self.thetype('abcba').difference(C('efgfe')), set('abc')) self.assertEqual(self.thetype('abcba').difference(C('ccb')), set('a')) @@ -146,7 +146,7 @@ self.assertEqual(type(i), self.thetype) self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru()) self.assertRaises(TypeError,
[issue1074462] Irregular behavior of datetime.__str__()
Zooko O'Whielacronx added the comment: Thank you for the one-liner. I was about to use it in the allmydata.org project, but I remembered that my programming partner would probably prefer the larger but more explicit if:else: over the clever one-liner. Perhaps it will be useful to someone else. I'll have a look at issue1158. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1074462 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Christian Heimes added the comment: Here is an updated patch which applies cleanly and fixes some additional unit tests and removes one that doesn't make sense any more (re.compile doesn't accept bytes). The unit tests profile, cProfile and doctest fail w/ and w/o this patch. They seem to suffer from the latest changes of our previous patch and additional calls to utf_8_decode(). __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __Index: Lib/email/generator.py === --- Lib/email/generator.py (revision 58469) +++ Lib/email/generator.py (working copy) @@ -288,7 +288,7 @@ for part in msg.walk(): maintype = part.get_content_maintype() if maintype == 'text': -print(part.get_payload(decode=True), file=self) +print(part.get_payload(decode=False), file=self) elif maintype == 'multipart': # Just skip this pass ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1031213] Use correct encoding for printing SyntaxErrors
Guido van Rossum added the comment: atsuo ishimoto added the comment: That's fine with me. Please replace PyErr_Print() with PyErr_Clear(). Done. Committed revision 58471. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1031213 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Guido van Rossum added the comment: Hm? This is a one-word patch to email/generator.py. On 10/15/07, Christian Heimes [EMAIL PROTECTED] wrote: Christian Heimes added the comment: Here is an updated patch which applies cleanly and fixes some additional unit tests and removes one that doesn't make sense any more (re.compile doesn't accept bytes). The unit tests profile, cProfile and doctest fail w/ and w/o this patch. They seem to suffer from the latest changes of our previous patch and additional calls to utf_8_decode(). __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1253] IDLE - Percolator overhaul
Kurt B. Kaiser added the comment: Thanks for the patch, it will definitely be applied once I finish reviewing it! Good job splitting off TkTextPercolator and inheriting from Delegator. -- assignee: - kbk priority: - normal __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1253 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1280] PEP 3137: Make PyString's indexing and iteration return integers
Changes by Martin v. Löwis: -- keywords: +patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1280 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1276] LookupError: unknown encoding: X-MAC-JAPANESE
Guido van Rossum added the comment: Marc-Andre, do you understand this issue? Your name is in Tools/unicode/Makefile; the patch deletes the line $(RM) build/mac_japanese.* from the apple target, which seems rather arbitrary. -- assignee: - lemburg nosy: +gvanrossum, lemburg __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1276 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1277] mailbox.Maildir: factory not used
Guido van Rossum added the comment: Patch please? -- nosy: +gvanrossum __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1277 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Guido van Rossum added the comment: Can you suggest a patch? Adding Brett Cannon to the list, possibly his import-in-python would supersede this? -- nosy: +brett.cannon, gvanrossum __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1263] PEP 3137 patch - str8/str comparison should return false
Guido van Rossum added the comment: I'll look at this at some point. One quick comment: the lnotab and bytecode should use PyString, which will be 'bytes' in 3.0a2. They must be immutable because code objects must be immutable (it must not be possible to modify an existing code object). On 10/15/07, Thomas Lee [EMAIL PROTECTED] wrote: Thomas Lee added the comment: Hack to make Python/codecs.c use Unicode strings internally. I recognize the way I have fixed it here is probably not ideal (basically ripped out PyString_*, replaced with a PyMem_Malloc/PyMem_Free call) but it fixes 10-12 tests that were failing with my earlier changes. If anybody can recommend a nice way to fix this, I'm all ears. The following still fail for me with this patch applied: -- test_compile This is due to PyString_*/PyUnicode_*/PyBytes_* confusion in the assembler struct (specifically: a_lnotab and a_bytecode) in Python/compile.c - tried replacing PyString_* calls with PyBytes_* calls, but this raises a TypeError because PyBytes is not hashable ... not sure what exactly is causing this. -- test_ctypes Looks like a simple case of ctypes using str8 instead of str. Appears to be an easy fix. -- test_modulefinder Failing because str8 = str is now an invalid operation -- test_set This test needs some love. -- test_sqlite Not sure what's going on here. -- test_str This one is a little tricky: str8/str with __str__/__unicode__ ... how is this test supposed to behave with the fix in this patch? -- test_struct unpack/pack not transitive - what does that mean? -- test_subprocess Like modulefinder, this is probably just due to the use of str8 over str internally in the subprocess module. Likely to be an easy fix. The following tests fail for me irrespective of whether or not I have r4 of my patch applied: -- test_doctest -- test_email -- test_nis -- test_pty If anybody can give this new patch a try and let me know the result it would be much appreciated. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1263 __ __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1263 __I#39;ll look at this at some point. One quick comment: the lnotab and bytecode should use PyString, which will be #39;bytes#39; in 3.0a2. They must be immutable because code objects must be immutable (it must not be possible to modify an existing code object). brbrdivspan class=gmail_quoteOn 10/15/07, b class=gmail_sendernameThomas Lee/b lt;a href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/agt; wrote:/spanblockquote class=gmail_quote style=border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex; brThomas Lee added the comment:brbrHack to make Python/codecs.c use Unicode strings internally. I recognizebrthe way I have fixed it here is probably not ideal (basically ripped outbrPyString_*, replaced with a PyMem_Malloc/PyMem_Free call) but it fixes br10-12 tests that were failing with my earlier changes. If anybody canbrrecommend a quot;nicequot; way to fix this, I#39;m all ears.brbrThe following still fail for me with this patch applied:brbr-- test_compile brbrThis is due to PyString_*/PyUnicode_*/PyBytes_* confusion in thebrassembler struct (specifically: a_lnotab and a_bytecode) inbrPython/compile.c - tried replacing PyString_* calls with PyBytes_*brcalls, but this raises a TypeError because PyBytes is not hashable ... brnot sure what exactly is causing this.brbr-- test_ctypesbrLooks like a simple case of ctypes using str8 instead of str. Appears tobrbe an easy fix.brbr-- test_modulefinderbrFailing because str8 gt;= str is now an invalid operation brbr-- test_setbrThis test needs some love.brbr-- test_sqlitebrNot sure what#39;s going on here.brbr-- test_strbrbrThis one is a little tricky: str8/str with __str__/__unicode__ ... howbris this test supposed to behave with the fix in this patch? brbr-- test_structbrquot;unpack/pack not transitivequot; - what does that mean?brbr-- test_subprocessbrLike modulefinder, this is probably just due to the use of str8 over strbrinternally in the subprocess module. Likely to be an easy fix. brbrThe following tests fail for me irrespective of whether or not I have r4brof my patch applied:brbr-- test_doctestbr-- test_emailbr-- test_nisbr-- test_ptybrbrIf anybody can give this new patch a try and let me know the result it brwould be much appreciated.brbr__brTracker lt;a href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/agt;brlt;a href=http://bugs.python.org/issue1263;http://bugs.python.org/issue1263 /agt;br__br/blockquote/divbrbr clear=allbr-- br--Guido van Rossum (home page: a href=http://www.python.org/~guido/;http://www.python.org/~guido//a) ___ Python-bugs-list mailing list
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Christian Heimes added the comment: Can you suggest a patch? Adding Brett Cannon to the list, possibly his import-in-python would supersede this? No, I can't suggest a patch. I don't know how we could get the encoding from the tokenizer or AST. Brett is obviously the best man to fix the problem. :) Christian __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1251] ssl module doesn't support non-blocking handshakes
Bill Janssen added the comment: Perhaps we shouldn't expose this at the application level. We could check, in the C module's sslwrap, whether the socket is blocking or not, and do the right thing there, so that sslwrap would always succeed in one call. Since we are releasing the GIL whenever we do SSL_accept() or SSL_connect(), other threads get a chance to run, so doing it transparently shouldn't affect the Python program's liveness. And it would reduce the chances for application error. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1251 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1276] LookupError: unknown encoding: X-MAC-JAPANESE
Marc-Andre Lemburg added the comment: My name appears in that Makefile because I wrote it and used it to create the charmap codecs. The reason why the Mac Japanese codec was not created for 2.x was the size of the mapping table. Ideal would be to have the C version of the CJK codecs support the Mac Japanese encoding as well. Adding back the charmap based Mac Japanese codec would be a compromise. The absence of the Mac Japanese codec causes (obvious) problems for many Japanese Python users running Mac OS X. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1276 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1276] LookupError: unknown encoding: X-MAC-JAPANESE
Marc-Andre Lemburg added the comment: Adding Python 2.6 as version target. -- versions: +Python 2.6 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1276 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Guido van Rossum added the comment: No, I can't suggest a patch. I don't know how we could get the encoding from the tokenizer or AST. Try harder. :-) Look at the code that accomplishes this feat in the regular parser... __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Christian Heimes added the comment: Try harder. :-) Look at the code that accomplishes this feat in the regular parser... I've already found the methods that find the encoding in Parser/tokenizer.c: check_coding_spec() and friends. But it seems like a waste of time to use PyTokenizer_FromFile() just to find the encoding. *reading* Mmh ... It's not a waste of time if I can stop the tokenizer. I think it may be possible to use the tokenizer to get the encoding efficiently. I could read until tok_state-read_coding_spec or tok_state-indent != 0. Do you know a better way to stop the tokenizer when the line isn't a special comment line # -*-? Christian __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1281] type in docutmentatio section 14.3.3.4
New submission from Ben Sherman: If, a little later on, -tracks=4 is seen, it does: options.tracks.append(int(4)) That should read --tracks=4, not -tracks=4 Found at http://docs.python.org/lib/optparse-standard-option-actions.html -- components: Documentation messages: 56460 nosy: bsherman severity: normal status: open title: type in docutmentatio section 14.3.3.4 versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1281 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Guido van Rossum added the comment: Call PyTokenizer_Get until the line number is 2? On 10/15/07, Christian Heimes [EMAIL PROTECTED] wrote: Christian Heimes added the comment: Try harder. :-) Look at the code that accomplishes this feat in the regular parser... I've already found the methods that find the encoding in Parser/tokenizer.c: check_coding_spec() and friends. But it seems like a waste of time to use PyTokenizer_FromFile() just to find the encoding. *reading* Mmh ... It's not a waste of time if I can stop the tokenizer. I think it may be possible to use the tokenizer to get the encoding efficiently. I could read until tok_state-read_coding_spec or tok_state-indent != 0. Do you know a better way to stop the tokenizer when the line isn't a special comment line # -*-? Christian __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Brett Cannon added the comment: No, my work has the exact same problem. Actually, this bug report has confirmed for me why heapq could not be imported when I accidentally forced all open text files to use UTF-8. I just have not gotten around to trying to solve this issue yet. But since importlib just uses open() directly it has the same problems. Since it looks like TextIOWrapper does not let one change the encoding after it has been set, some subclass might need to be written that reads Looks for the the stanza or else immediately stops and uses the expected encoding (UTF-8 in the case of Py3K or ASCII for 2.6). That or expose some C function that takes a file path or open file that returns a code object. But I have bigger fish to fry as my attempt to get around open() being defined in site.py is actually failing once I clobbered my .pyc files as codecs requires importing modules, even for ASCII encoding. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1281] type in docutmentation - lib ref section 14.3.3.4
Ben Sherman added the comment: Typos corrected. -- title: type in docutmentatio section 14.3.3.4 - type in docutmentation - lib ref section 14.3.3.4 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1281 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1267] Py3K cannot run as ``python -S``
Christian Heimes added the comment: I've some code around which sets sys.stdin, out and err in C code. The code is far from perfect and I haven't checked it for reference leaks yet. I like to get your comment on the style and error catching. -- nosy: +tiran __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1267 __Index: Python/pythonrun.c === --- Python/pythonrun.c (revision 58477) +++ Python/pythonrun.c (working copy) @@ -51,6 +51,7 @@ /* Forward */ static void initmain(void); static void initsite(void); +static int initsysstd(void); static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *, PyCompilerFlags *, PyArena *); static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, @@ -241,8 +242,11 @@ initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ + if (initsysstd() 0) + Py_FatalError(Py_Initialize: can't initialize sys std streams); if (!Py_NoSiteFlag) initsite(); /* Module site */ + /* auto-thread-state API, if available */ #ifdef WITH_THREAD @@ -676,6 +680,93 @@ } } +/* Initialize sys.stdin, stdout and stderr */ +static int +initsysstd(void) +{ + PyObject *io=NULL, *iod, *open; + PyObject *bi=NULL, *bid; + PyObject *m, *wrapper; + PyObject *std, *args=NULL, *kwargs=NULL; + + /* Hack to avoid a nasty recursion issue when Python is invoked + in verbose mode: pre-import the Latin-1 and UTF-8 codecs */ + if ((m = PyImport_ImportModule(encodings.utf_8)) == NULL) + return -1; + Py_DECREF(m); + + if ((m = PyImport_ImportModule(encodings.latin_1)) == NULL) + return -1; + Py_DECREF(m); + + if ((bi = PyImport_ImportModule(__builtin__)) == NULL) + goto error; + if ((bid = PyModule_GetDict(bi)) == NULL) + goto error; + + if ((io = PyImport_ImportModule(io)) == NULL) + goto error; + if ((iod = PyModule_GetDict(io)) == NULL) + goto error; + + if ((wrapper = PyDict_GetItemString(iod, OpenWrapper)) == NULL) + goto error; + Py_INCREF(wrapper); + if (PyDict_SetItemString(bid, open, wrapper) == -1) { + Py_DECREF(wrapper); /* ??? */ + goto error; + } + + if ((open = PyDict_GetItemString(iod, open)) == NULL) + goto error; + + if ((kwargs = PyDict_New()) == NULL) + goto error; + if (PyDict_SetItemString(kwargs, newline, PyString_FromString(\n)) + == -1) + goto error; + + /* stdin */ + if ((args = Py_BuildValue((is), 0, r)) == NULL) + goto error; + if ((std = PyObject_Call(open, args, kwargs)) == NULL) + goto error; + PySys_SetObject(__stdin__, std); + PySys_SetObject(stdin, std); + Py_DECREF(std); + Py_DECREF(args); + + /* stdout */ + if ((args = Py_BuildValue((is), 1, w)) == NULL) + goto error; + if ((std = PyObject_Call(open, args, kwargs)) == NULL) + goto error; + PySys_SetObject(__stdout__, std); + PySys_SetObject(stdout, std); + Py_DECREF(std); + Py_DECREF(args); + + /* stderr */ + if ((args = Py_BuildValue((is), 2, w)) == NULL) + goto error; + if ((std = PyObject_Call(open, args, kwargs)) == NULL) + goto error; + PySys_SetObject(__stderr__, std); + PySys_SetObject(stderr, std); + Py_DECREF(std); + Py_DECREF(args); + + return 0; + + error: + Py_XDECREF(bi); + Py_XDECREF(io); + Py_XDECREF(kwargs); + Py_XDECREF(args); + return -1; + +} + /* Parse input from a file and execute it */ int Index: Lib/site.py === --- Lib/site.py (revision 58477) +++ Lib/site.py (working copy) @@ -433,7 +433,7 @@ sethelper() aliasmbcs() setencoding() -installnewio() +#installnewio() execsitecustomize() # Remove sys.setdefaultencoding() so that users cannot change the # encoding after initialization. The test for presence is needed when Index: Lib/io.py === --- Lib/io.py (revision 58477) +++ Lib/io.py (working copy) @@ -178,6 +178,16 @@ return text +class OpenWrapper: +Wrapper for __builtin__.open + +Trick so that open won't become a bound method when stored +as a class variable (as dumbdbm does) + +def __new__(cls, *args, **kwargs): +return open(*args, **kwargs) + + class UnsupportedOperation(ValueError, IOError): pass ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1267] Py3K cannot run as ``python -S``
Changes by Brett Cannon: -- assignee: - brett.cannon keywords: +patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1267 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1261] PEP 3137: make bytesobject.c methods
Guido van Rossum added the comment: Is it worth my time to review this yet? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1261 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Changes by Guido van Rossum: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Guido van Rossum added the comment: The unit tests profile, cProfile and doctest fail w/ and w/o this patch. They seem to suffer from the latest changes of our previous patch and additional calls to utf_8_decode(). Any details on those? They don't fail for me. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1261] PEP 3137: make bytesobject.c methods
Changes by Gregory P. Smith: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1261 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Guido van Rossum added the comment: I'll check this in as soon as there's agreement on the list about this. Not that I expect disagreement, but I just realized it was never brought up and it isn't in PEP 3137 (yet). __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Christian Heimes added the comment: Any details on those? They don't fail for me. Here you are. $ ./python Lib/test/test_cProfile.py 121 function calls (101 primitive calls) in 1.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 10.0000.0001.0001.000 string:1(module) 80.0640.0080.0800.010 test_cProfile.py:103(subhelper) 280.0280.0010.0280.001 test_cProfile.py:115(__getattr__) 10.2700.2701.0001.000 test_cProfile.py:30(testfunc) 23/30.1500.0070.1700.057 test_cProfile.py:40(factorial) 200.0200.0010.0200.001 test_cProfile.py:53(mul) 20.0400.0200.6000.300 test_cProfile.py:60(helper) 40.1160.0290.1200.030 test_cProfile.py:78(helper1) 20.0000.0000.1400.070 test_cProfile.py:89(helper2_indirect) 80.3120.0390.4000.050 test_cProfile.py:93(helper2) 10.0000.0000.0000.000 utf_8.py:15(decode) 10.0000.0000.0000.000 {_codecs.utf_8_decode} 10.0000.0001.0001.000 {exec} 120.0000.0000.0120.001 {hasattr} 40.0000.0000.0000.000 {method 'append' of 'list' objects} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} 40.0000.0000.0000.000 {sys.exc_info} Ordered by: standard name Function called... ncalls tottime cumtime string:1(module) - 10.270 1.000 test_cProfile.py:30(testfunc) test_cProfile.py:103(subhelper) - 160.016 0.016 test_cProfile.py:115(__getattr__) test_cProfile.py:115(__getattr__) - test_cProfile.py:30(testfunc) - 10.014 0.130 test_cProfile.py:40(factorial) 20.040 0.600 test_cProfile.py:60(helper) test_cProfile.py:40(factorial)-20/30.130 0.147 test_cProfile.py:40(factorial) 200.020 0.020 test_cProfile.py:53(mul) test_cProfile.py:53(mul) - test_cProfile.py:60(helper) - 40.116 0.120 test_cProfile.py:78(helper1) 20.000 0.140 test_cProfile.py:89(helper2_indirect) 60.234 0.300 test_cProfile.py:93(helper2) test_cProfile.py:78(helper1) - 40.000 0.004 {hasattr} 40.000 0.000 {method 'append' of 'list' objects} 40.000 0.000 {sys.exc_info} test_cProfile.py:89(helper2_indirect) - 20.006 0.040 test_cProfile.py:40(factorial) 20.078 0.100 test_cProfile.py:93(helper2) test_cProfile.py:93(helper2) - 80.064 0.080 test_cProfile.py:103(subhelper) 80.000 0.008 {hasattr} utf_8.py:15(decode) - 10.000 0.000 {_codecs.utf_8_decode} {_codecs.utf_8_decode}- {exec}- 10.000 1.000 string:1(module) 10.000 0.000 utf_8.py:15(decode) {hasattr} - 120.012 0.012 test_cProfile.py:115(__getattr__) {method 'append' of 'list' objects} - {method 'disable' of '_lsprof.Profiler' objects} - {sys.exc_info}- Ordered by: standard name Function was called by... ncalls tottime cumtime string:1(module) - 10.000 1.000 {exec} test_cProfile.py:103(subhelper) - 80.064 0.080 test_cProfile.py:93(helper2) test_cProfile.py:115(__getattr__) - 160.016 0.016 test_cProfile.py:103(subhelper) 120.012 0.012 {hasattr} test_cProfile.py:30(testfunc) - 10.270 1.000 string:1(module) test_cProfile.py:40(factorial)- 10.014 0.130 test_cProfile.py:30(testfunc) 20/30.130 0.147 test_cProfile.py:40(factorial)
[issue1258] Removal of basestring type
Guido van Rossum added the comment: BTW we need a 2to3 fixer for this. Should be trivial -- just replace *all* occurrences of basestring with str. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1282] re module needs to support bytes / memoryview well
New submission from Guido van Rossum: Once PEP 3137 is fully implemented, the re module needs to be fixed so that the regex argument, the substitution argument, and the argument being searched/replaced are allowed to be arbitrary bytes arrays; where hashing is needed a copy in an immutable bytes object can be made. -- messages: 56472 nosy: gvanrossum severity: normal status: open title: re module needs to support bytes / memoryview well versions: Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1282 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Guido van Rossum added the comment: Even before this patch, the re module doesn't work very well on byte strings. IMO this should be fixed. I've filed a separate bug to remind us: bug 1282. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1258] Removal of basestring type
Christian Heimes added the comment: Guido van Rossum wrote: BTW we need a 2to3 fixer for this. Should be trivial -- just replace *all* occurrences of basestring with str. I believe you that it's trivial for *you* but I've never dealt with the fixers or the grammar. Fortunately for me I was able to copy the fixer for standarderror. It toke just some minor tweaks :) Let's see if the mail interface can handle attachments. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1258 __# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. Fixer for basestring - str # Local imports from fixes import basefix from fixes.util import Name class FixBasestr(basefix.BaseFix): PATTERN = 'basestring' def transform(self, node, results): return Name(str, prefix=node.get_prefix()) ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1251] ssl module doesn't support non-blocking handshakes
Chris Stawarz added the comment: Bill, You seem to be missing the whole point of doing non-blocking I/O, which is to handle multiple concurrent, I/O-bound tasks in a single OS thread. The application must be able to try the handshake, detect that it didn't complete because I/O needs to take place, and then retry it at a later time of its choosing (presumably when select() says it's OK to read from the socket). And between now and that later time, it can do other things, like read or write to other sockets. The point is that the *application* must have control over when it does I/O, when it waits for sockets to be ready for I/O, and what it does in between. There's just no way it can do this if the sslwrap() function doesn't return until the handshaking is complete. sslwrap() can't do the right thing, because the right thing is to return control to the application until it's ready to try the handshake again. And this has nothing to do with the GIL or multiple threads. Like I said, the point of doing non-blocking I/O with select() is to *avoid* the need for multiple threads. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1251 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1261] PEP 3137: make bytesobject.c methods
Guido van Rossum added the comment: Very impressive! (Apologies if these lines are occasionally out of order.) +extern PyObject* _bytes_isspace(const char *cptr, const Py_ssize_t len); IMO all these functions should have names starting with _Py or _Py_, since they are visible to the linker. Also, why 'const Py_ssize_t'? It's a scalar! +/* these store their len sized answer in the given preallocated *result arg */ Mind using a Capital first letter? +extern const char isspace__doc__[]; This needs a _Py or _Py_ prefix too. +extern const unsigned int ctype_table[256]; Now this is no longer static, it also needs a _Py or _Py_ prefix. +extern const unsigned char ctype_tolower[256]; +extern const unsigned char ctype_toupper[256]; Ditto (the macros are fine though, since they are only visible to code that #includes this file, which is only a few files). +Return True if all characters in S are whitespace\n\ Shouldn't that be bytes instead of characters (and consistently throughout)? And probably use B for the variable name instead of S. +/* --- GPS - */ What's this? Your initials? :-) I don't think it's needed. I'm guessing you /* The nullbytes are used by the stringlib during partition. * If partition is removed from bytes, nullbytes and its helper This comment block refers to something that ain't gonna happen (partition being removed). IMO the whole comment block can go, it's a red herring. +/* XXX: this depends on a signed integer overflow to 0 */ +/* C compilers, including gcc, do -NOT- guarantee this. */ (And repeated twice more.) Wouldn't it be better to write this in a way that doesn't require this XXX comment? ISTR that we already had one area where we had to fight with gcc because it had proved to itself that something could never be negative, even though it could be due to overflow. The GCC authors won. :-( +/* TODO(gps): Don't you mean XXX(gps)? :-) + * These methods still need implementing (porting over from stringobject.c): + * + * IN PROGRESS: + * .capitalize(), .title(), .upper(), .lower(), .center(), .zfill(), + * .expandtabs(), .ljust(), .rjust(), .swapcase(), .splitlines(), + */ + Hmmm... Aren't these done now? +/* XXX(gps): the docstring above says any iterable int will do but the + * bytes_setslice code only accepts something supporting PEP 3118. + * Is a list or tuple of 0 = ints = 255 also supposed to work? */ Yes, it is, and it's a bug that it currently doesn't. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1261 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1283] PyBytes (buffer) .extend method needs to accept any iterable of ints
New submission from Gregory P. Smith: The PyBytes (pep3137 buffer) .extend() method currently only accepts as input something supporting the pep3118 buffer API. It also needs to accept an iterable of ints in the 0..255 range. -- keywords: py3k messages: 56478 nosy: gregory.p.smith severity: normal status: open title: PyBytes (buffer) .extend method needs to accept any iterable of ints versions: Python 3.0 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1283 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1261] PEP 3137: make bytesobject.c methods
Changes by Gregory P. Smith: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1261 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1261] PEP 3137: make bytesobject.c methods
Changes by Gregory P. Smith: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1261 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1284] typo in lib doc 7.3.2.1 MaildirMessage
New submission from Eric Wollesen: get_subdir( ) Return either new (if the message should be stored in the new subdirectory) or cur (if the message should be stored in the cur subdirectory). Note: A message is typically moved from new to cur after its mailbox has been accessed, whether or not the message is has been read. A message msg has been read if S not in msg.get_flags() is True. The last sentence above is incorrect. The not should be removed. It should read: A message msg has been read if S in msg.get_flags() is True. -- components: Documentation messages: 56481 nosy: encoded severity: minor status: open title: typo in lib doc 7.3.2.1 MaildirMessage type: rfe versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1284 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-
Changes by Alexandre Vassalotti: -- nosy: +alexandre.vassalotti __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1278 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1272] Decode __file__ and co_filename to unicode using fs default
Alexandre Vassalotti added the comment: I wrote in msg56419: It is not perfect, since the extra function calls in the codecs module causes test_profile and test_doctest to fail. How this was resolved? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1272 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1267] Py3K cannot run as ``python -S``
Christian Heimes added the comment: I've carefully checked and tested the initstdio() method. I'm sure that I've catched every edged case. The unit tests pass w/o complains. I've also added a PyErr_Display() call to Py_FatalError(). It's still hard to understand an error in io.py but at least the dependency on site.py is removed. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1267 __Index: Python/pythonrun.c === --- Python/pythonrun.c (revision 58477) +++ Python/pythonrun.c (working copy) @@ -51,6 +51,7 @@ /* Forward */ static void initmain(void); static void initsite(void); +static int initstdio(void); static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *, PyCompilerFlags *, PyArena *); static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, @@ -241,8 +242,12 @@ initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ + if (initstdio() 0) + Py_FatalError(Py_Initialize: can't initialize sys standard +streams); if (!Py_NoSiteFlag) initsite(); /* Module site */ + /* auto-thread-state API, if available */ #ifdef WITH_THREAD @@ -676,6 +681,103 @@ } } +/* Initialize sys.stdin, stdout, stderr and __builtins__.open */ +static int +initstdio(void) +{ + PyObject *iomod=NULL, *open, *wrapper; + PyObject *bimod=NULL; + PyObject *m; + PyObject *std=NULL, *args=NULL, *kwargs=NULL; + int status = 0; + + /* Hack to avoid a nasty recursion issue when Python is invoked + in verbose mode: pre-import the Latin-1 and UTF-8 codecs */ + if ((m = PyImport_ImportModule(encodings.utf_8)) == NULL) { + goto error; + } + Py_DECREF(m); + + if (!(m = PyImport_ImportModule(encodings.latin_1))) { + goto error; + } + Py_DECREF(m); + + if (!(bimod = PyImport_ImportModule(__builtin__))) { + goto error; + } + + if (!(iomod = PyImport_ImportModule(io))) { + goto error; + } + if (!(wrapper = PyObject_GetAttrString(iomod, OpenWrapper))) { + goto error; + } + if (!(open = PyObject_GetAttrString(iomod, open))) { + goto error; + } + + if (PyObject_SetAttrString(bimod, open, wrapper) == -1) { + goto error; + } + + /* Add __builtin__.open */ + if (!(kwargs = PyDict_New())) { + goto error; + } + if (PyDict_SetItemString(kwargs, newline, PyString_FromString(\n)) + == -1) { + goto error; + } + + /* Set sys.stdin */ + if (!(args = Py_BuildValue((is), 0, r))) { + goto error; + } + if (!(std = PyObject_Call(open, args, kwargs))) { + goto error; + } + PySys_SetObject(__stdin__, std); + PySys_SetObject(stdin, std); + Py_DECREF(std); + Py_DECREF(args); + + /* Set sys.stdout */ + if (!(args = Py_BuildValue((is), 1, w))) { + goto error; + } + if (!(std = PyObject_Call(open, args, kwargs))) { + goto error; + } + PySys_SetObject(__stdout__, std); + PySys_SetObject(stdout, std); + Py_DECREF(std); + Py_DECREF(args); + + /* Set sys.stderr */ + if (!(args = Py_BuildValue((is), 2, w))) { + goto error; + } + if (!(std = PyObject_Call(open, args, kwargs))) { + goto error; + } + PySys_SetObject(__stderr__, std); + PySys_SetObject(stderr, std); + Py_DECREF(std); + Py_DECREF(args); + + goto finally; + +error: + status = -1; + Py_XDECREF(args); +finally: + Py_XDECREF(kwargs); + Py_XDECREF(bimod); + Py_XDECREF(iomod); + return status; +} + /* Parse input from a file and execute it */ int @@ -1146,10 +1248,10 @@ int err = 0; PyObject *f = PySys_GetObject(stderr); Py_INCREF(value); - if (f == NULL) + if (f == NULL) { _PyObject_Dump(value); - if (f == NULL) fprintf(stderr, lost sys.stderr\n); + } else { fflush(stdout); if (tb tb != Py_None) @@ -1589,6 +1691,9 @@ Py_FatalError(const char *msg) { fprintf(stderr, Fatal Python error: %s\n, msg); + if (PyErr_Occurred()) { + PyErr_Print(); + } #ifdef MS_WINDOWS OutputDebugString(Fatal Python error: ); OutputDebugString(msg); Index: Lib/site.py === --- Lib/site.py (revision 58477) +++ Lib/site.py (working copy) @@ -402,23 +402,6 @@ (err.__class__.__name__, err)) -def installnewio(): -Install new I/O library as default. -import io -# Hack to avoid a nasty recursion issue when Python is invoked -# in verbose mode: pre-import the Latin-1 and UTF-8 codecs -from encodings import latin_1, utf_8 -# Trick so that open won't become a bound method when stored -# as a class variable (as dumbdbm does) -class open: -def __new__(cls, *args, **kwds): -return io.open(*args, **kwds) -__builtin__.open = open -sys.__stdin__ = sys.stdin = io.open(0, r, newline='\n') -sys.__stdout__ = sys.stdout = io.open(1, w, newline='\n') -sys.__stderr__ = sys.stderr = io.open(2, w, newline='\n') - - def main(): abs__file__() paths_in_sys = removeduppaths() @@ -433,7 +416,6 @@
[issue1251] ssl module doesn't support non-blocking handshakes
Bill Janssen added the comment: You seem to be missing the whole point of doing non-blocking I/O, You know, I think that's right. I'm so used to using threads by now that the whole select-based approach seems very odd to me by now. OK, I've folded your patch into the PyPI version, ssl 1.8. It will meander into the trunk and 3K version as well. Thanks for the help! Bill On 10/15/07, Chris Stawarz [EMAIL PROTECTED] wrote: Chris Stawarz added the comment: Bill, You seem to be missing the whole point of doing non-blocking I/O, which is to handle multiple concurrent, I/O-bound tasks in a single OS thread. The application must be able to try the handshake, detect that it didn't complete because I/O needs to take place, and then retry it at a later time of its choosing (presumably when select() says it's OK to read from the socket). And between now and that later time, it can do other things, like read or write to other sockets. The point is that the *application* must have control over when it does I/O, when it waits for sockets to be ready for I/O, and what it does in between. There's just no way it can do this if the sslwrap() function doesn't return until the handshaking is complete. sslwrap() can't do the right thing, because the right thing is to return control to the application until it's ready to try the handshake again. And this has nothing to do with the GIL or multiple threads. Like I said, the point of doing non-blocking I/O with select() is to *avoid* the need for multiple threads. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1251 __ __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1251 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1261] PEP 3137: make bytesobject.c methods
Guido van Rossum added the comment: Good! Check it in before I change my mind. :-) The words can be tweaked later. 04b is the same as 04, i just fixed the docstrings that i had missed in stringlib/transmogrify.h to use 'B' instead of 'S' and say they return a modified copy of B instead of a string wording could probably be improved further if anyone has any ideas. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1261 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1267] Py3K cannot run as ``python -S``
Guido van Rossum added the comment: I've carefully checked and tested the initstdio() method. I'm sure that I've catched every edged case. The unit tests pass w/o complains. I've also added a PyErr_Display() call to Py_FatalError(). It's still hard to understand an error in io.py but at least the dependency on site.py is removed. Very cool! Some final suggestions: + Py_FatalError(Py_Initialize: can't initialize sys standard + streams); Break this differently: Py_FatalError( Py_); Don't call open() with keyword arg for newline=\r; open() takes positional args too. This is done specifically to simplify life for C code calling it. :-) Perhaps one of the PyFunction_Call(..) variants makes it easier to call it without having to explicitly construct the tuple for the argument list. (All this because you're leaking the value of PyString_FromString(\n). :-) I would change the error handling to avoid the 'finally' label, like this: if (0) { error: status = -1; Py_XDECREF(args); } I would add a comment see initstdio() in pythonrun.c to the OpenWrapper class, which otherwise looks a bit mysterious (as it's not used anywhere in the Python code). Thanks for doing this!!! __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1267 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1259] string find and rfind methods give a TypeError that is misleading
Robert Collins added the comment: The error message is wrong: it's a TypeError, but the message should say something like... TypeError: slice indices must be integers or have an __index__ method This would be a false message, as, as my report demonstrated, slice indices *can* be None. And there is a very good reason for accepting None in the second parameter in slice notation as there is no value for '-0' to represent the end of the region being sliced, and None meaning 'default' fills that need most effectively. Surely the right fix is as Barry noted, to handle None correctly within this function? __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1259 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1663329] subprocess/popen close_fds perform poor if SC_OPEN_MAX is hi
Mike Klaas added the comment: This problem has also afflicted us. Attached is a patch which adds closerange(fd_low, fd_high) to the posix (and consequently os) module, and modifies subprocess to use it. Patch is against trunk but should work for 2.5maint. I don't really think that this is useful enough to add to the public api, but it results in a huge performance benefit for subprocess: [python-trunk]$ ./python -m timeit -s 'import python_close' 'python_close.go(10)' 10 loops, best of 3: 358 msec per loop [python-trunk]$ ./python -m timeit -s 'import os' 'os.closerange(4, 10)' 10 loops, best of 3: 20.7 msec per loop [python-trunk]$ ./python -m timeit -s 'import python_close' 'python_close.go(30)' 10 loops, best of 3: 1.05 sec per loop [python-trunk]$ ./python -m timeit -s 'import os' 'os.closerange(4, 30)'10 loops, best of 3: 63 msec per loop [python-trunk]$ cat python_close.py import os, sys def go(N): for i in xrange(4, N): try: os.close(i) except: pass -- nosy: +klaas _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1663329 _ posix_closerange.patch Description: Binary data ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1663329] subprocess/popen close_fds perform poor if SC_OPEN_MAX is hi
Mike Klaas added the comment: I see that some spaces crept in to the patch. I can fix that (and perhaps rename the function to start with an underscore) if desired. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1663329 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1663329] subprocess/popen close_fds perform poor if SC_OPEN_MAX is hi
Mike Klaas added the comment: Finally, I did not include any platform-specific optimizations, as I don't have AIX or solaris boxes on which to test them (and they can easily be added later). An order-mag speedup on all *nix platforms is a good start. _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1663329 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1663329] subprocess/popen close_fds perform poor if SC_OPEN_MAX is hi
Changes by Martin v. Löwis: -- keywords: +patch _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1663329 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1267] Py3K cannot run as ``python -S``
Christian Heimes added the comment: Guido van Rossum wrote: Don't call open() with keyword arg for newline=\r; open() takes positional args too. This is done specifically to simplify life for C code calling it. :-) Perhaps one of the PyFunction_Call(..) variants makes it easier to call it without having to explicitly construct the tuple for the argument list. (All this because you're leaking the value of PyString_FromString(\n). :-) I need a way to open a file with a specific encoding for imp.find_module(), too. I found PyFile_FromFile(). It uses io.open but it doesn't accept the additional arguments. I like to add another function PyFile_FromFileEx() to the API. PyObject * PyFile_FromFileEx(FILE *fp, char *name, char *mode, int (*close)(FILE *), int buffering, char *encoding, char *newline) Some people may also miss the PyFile_FromString() function but that's a different story. With the my new function I can create sys.stdin with: PyFile_FromFileEx(stdin, stdin, r, fclose, -1, NULL, \n) I kinda like it :) I would change the error handling to avoid the 'finally' label, like this: if (0) { error: status = -1; Py_XDECREF(args); } Wow, that's tricky. :) I would add a comment see initstdio() in pythonrun.c to the OpenWrapper class, which otherwise looks a bit mysterious (as it's not used anywhere in the Python code). That sounds like a good idea! The code for const char *PyTokenizer_FindEncoding(FILE *fp) and imp.find_module() is also finished and works. Christian __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1267 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1267] Py3K cannot run as ``python -S``
Christian Heimes added the comment: The patch is a combined patch for the imp.find_module() problem and initstdio. Both patches depend on the new PyFile_FromFileEx() function. I hope you don't mind. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1267 __Index: Python/pythonrun.c === --- Python/pythonrun.c (revision 58477) +++ Python/pythonrun.c (working copy) @@ -51,6 +51,7 @@ /* Forward */ static void initmain(void); static void initsite(void); +static int initstdio(void); static PyObject *run_mod(mod_ty, const char *, PyObject *, PyObject *, PyCompilerFlags *, PyArena *); static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *, @@ -241,6 +242,9 @@ initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ + if (initstdio() 0) + Py_FatalError( + Py_Initialize: can't initialize sys standard streams); if (!Py_NoSiteFlag) initsite(); /* Module site */ @@ -676,6 +680,84 @@ } } +/* Initialize sys.stdin, stdout, stderr and __builtin__.open */ +static int +initstdio(void) +{ + PyObject *iomod=NULL, *open, *wrapper; + PyObject *bimod=NULL; + PyObject *m; + PyObject *std=NULL; + int status = 0; + + /* Hack to avoid a nasty recursion issue when Python is invoked + in verbose mode: pre-import the Latin-1 and UTF-8 codecs */ + if ((m = PyImport_ImportModule(encodings.utf_8)) == NULL) { + goto error; + } + Py_DECREF(m); + + if (!(m = PyImport_ImportModule(encodings.latin_1))) { + goto error; + } + Py_DECREF(m); + + if (!(bimod = PyImport_ImportModule(__builtin__))) { + goto error; + } + + if (!(iomod = PyImport_ImportModule(io))) { + goto error; + } + if (!(wrapper = PyObject_GetAttrString(iomod, OpenWrapper))) { + goto error; + } + if (!(open = PyObject_GetAttrString(iomod, open))) { + goto error; + } + + /* Set __builtin__.open */ + if (PyObject_SetAttrString(bimod, open, wrapper) == -1) { + goto error; + } + + /* Set sys.stdin */ + if (!(std = PyFile_FromFileEx(stdin, stdin, r, fclose, -1, + NULL, \n))) { + goto error; + } + PySys_SetObject(__stdin__, std); + PySys_SetObject(stdin, std); + Py_DECREF(std); + + /* Set sys.stdout */ + if (!(std = PyFile_FromFileEx(stdout, stdout, w, fclose, -1, + NULL, \n))) { +goto error; +} + PySys_SetObject(__stdout__, std); + PySys_SetObject(stdout, std); + Py_DECREF(std); + + /* Set sys.stderr */ + if (!(std = PyFile_FromFileEx(stderr, stderr, w, fclose, -1, + NULL, \n))) { +goto error; +} +PySys_SetObject(__stderr__, std); + PySys_SetObject(stderr, std); + Py_DECREF(std); + +if (0) { + error: +status = -1; +} + + Py_XDECREF(bimod); + Py_XDECREF(iomod); + return status; +} + /* Parse input from a file and execute it */ int @@ -1146,10 +1228,10 @@ int err = 0; PyObject *f = PySys_GetObject(stderr); Py_INCREF(value); - if (f == NULL) + if (f == NULL) { _PyObject_Dump(value); - if (f == NULL) fprintf(stderr, lost sys.stderr\n); + } else { fflush(stdout); if (tb tb != Py_None) @@ -1589,6 +1671,9 @@ Py_FatalError(const char *msg) { fprintf(stderr, Fatal Python error: %s\n, msg); + if (PyErr_Occurred()) { + PyErr_Print(); + } #ifdef MS_WINDOWS OutputDebugString(Fatal Python error: ); OutputDebugString(msg); Index: Python/import.c === --- Python/import.c (revision 58477) +++ Python/import.c (working copy) @@ -91,6 +91,9 @@ /* This table is defined in config.c: */ extern struct _inittab _PyImport_Inittab[]; +/* Method from Parser/tokenizer.c */ +extern const char * PyTokenizer_FindEncoding(FILE *fp); + struct _inittab *PyImport_Inittab = _PyImport_Inittab; /* these tables define the module suffixes that Python recognizes */ @@ -2558,6 +2561,7 @@ struct filedescr *fdp; char pathname[MAXPATHLEN+1]; FILE *fp = NULL; + const char *encoding = NULL; pathname[0] = '\0'; if (path == Py_None) @@ -2566,7 +2570,11 @@ if (fdp == NULL) return NULL; if (fp != NULL) { - fob = PyFile_FromFile(fp, pathname, fdp-mode, fclose); + encoding = PyTokenizer_FindEncoding(fp); + encoding = (encoding != NULL) ? encoding : + PyUnicode_GetDefaultEncoding(); + fob = PyFile_FromFileEx(fp, pathname, fdp-mode, fclose, + -1, (char*)encoding, NULL); if (fob == NULL) { fclose(fp); return NULL; Index: Include/fileobject.h === --- Include/fileobject.h (revision 58477) +++ Include/fileobject.h (working copy) @@ -9,6 +9,9 @@ #define PY_STDIOTEXTMODE b PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, int (*)(FILE*)); +PyAPI_FUNC(PyObject *) PyFile_FromFileEx(FILE *, char *, char *, + int (*)(FILE *), int, char *, + char *);