[issue1031213] Use correct encoding for printing SyntaxErrors

2007-10-11 Thread atsuo ishimoto

atsuo ishimoto added the comment:

Codecs would hardly ever raises exception here. 
Usually, exception raised here would be a MemoryError. The unicode 
string we are trying to encode is just decoded by same codec. If codec
raises exception other than MemoryError, the codec will likely have problem.

I attached a script to print exception raised by codec. I wrote a "buggy" 
encoder, which never return string but raises an exception.

_
Tracker <[EMAIL PROTECTED]>

_import codecs
def encoder(s, errors="strict"):
raise RuntimeError("dummy error")

def decoder(s, errors="strict"):
return unicode(s, 'ascii', errors), len(s)


def dmy_search(encoding):
if encoding == "dmyencoding":
return (encoder, decoder, codecs.StreamWriter, codecs.StreamReader)

def test():
codecs.register(dmy_search)
src = """#! -*- coding: dmyencoding -*-\n
print 'hello
"""
compile(src, "", "exec")

test()
___
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 use PEP 3118 buffer API

2007-10-11 Thread Gregory P. Smith

New submission from Gregory P. Smith:

This makes all existing bytesobject.c methods use the buffer API rather
than explicitly requiring bytes objects as input.  It also fixes input
to append() and remove() that was not strict enough and improves a few
unit tests in that area.

NOTE: this patch likely depends on http://bugs.python.org/issue1260
removing the buffer API from the unicode type in order for all unit
tests to pass (i only tested it with that applied since thats where
we're headed).

--
files: bytes-methods-use-buffer-api-01.diff.txt
keywords: patch, py3k
messages: 56341
nosy: gregory.p.smith
severity: normal
status: open
title: PEP 3137: make bytesobject.c methods use PEP 3118 buffer API
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/bytesobject.c
===
--- Objects/bytesobject.c   (revision 58412)
+++ Objects/bytesobject.c   (working copy)
@@ -37,15 +37,20 @@
 static int
 _getbytevalue(PyObject* arg, int *value)
 {
-PyObject *intarg = PyNumber_Int(arg);
-if (! intarg)
+long face_value;
+
+if (PyInt_Check(arg)) {
+face_value = PyInt_AsLong(arg);
+if (face_value < 0 || face_value >= 256) {
+PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
+return 0;
+}
+} else {
+PyErr_Format(PyExc_TypeError, "an integer is required");
 return 0;
-*value = PyInt_AsLong(intarg);
-Py_DECREF(intarg);
-if (*value < 0 || *value >= 256) {
-PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
-return 0;
 }
+
+*value = face_value;
 return 1;
 }
 
@@ -80,9 +85,7 @@
 {
 PyBufferProcs *buffer = Py_Type(obj)->tp_as_buffer;
 
-if (buffer == NULL ||
-PyUnicode_Check(obj) ||
-buffer->bf_getbuffer == NULL)
+if (buffer == NULL || buffer->bf_getbuffer == NULL)
 {
 PyErr_Format(PyExc_TypeError,
  "Type %.100s doesn't support the buffer API",
@@ -1088,6 +1102,23 @@
 return res;
 }
 
+/* TODO(gps):
+ * These methods need implementing (porting over from stringobject.c):
+ *
+ * .capitalize(), .center(), 
+ * .expandtabs(), .isalnum(), .isalpha(), .isdigit(),
+ * .islower(), .isspace(), .istitle(), .isupper(), 
+ * .rjust(), 
+ * .splitlines(), .swapcase(), .title(),
+ * .upper(), .zfill()
+ *
+ * XXX(gps) the code is -shared- for so many of these, thats gross.  I wish
+ * we had templates or generics or OO inheritance here.  A .h file with the
+ * methods as big CPP macros as templates would work but is ugly (especially
+ * when debugging).  Or can we do an (evil?) common substructure hack to
+ * allow us to write generic methods that work on both buffer (PyBytes_*)
+ * and bytes (PyString_*) objects?
+ */
 
 PyDoc_STRVAR(find__doc__,
 "B.find(sub [,start [,end]]) -> int\n\
@@ -1118,27 +1149,25 @@
 bytes_count(PyBytesObject *self, PyObject *args)
 {
 PyObject *sub_obj;
-const char *str = PyBytes_AS_STRING(self), *sub;
-Py_ssize_t sub_len;
+const char *str = PyBytes_AS_STRING(self);
 Py_ssize_t start = 0, end = PY_SSIZE_T_MAX;
+Py_buffer vsub;
+PyObject *count_obj;
 
 if (!PyArg_ParseTuple(args, "O|O&O&:count", &sub_obj,
 _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end))
 return NULL;
 
-if (PyBytes_Check(sub_obj)) {
-sub = PyBytes_AS_STRING(sub_obj);
-sub_len = PyBytes_GET_SIZE(sub_obj);
-}
-/* XXX --> use the modern buffer interface */
-else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len))
+if (_getbuffer(sub_obj, &vsub) < 0)
 return NULL;
 
 _adjust_indices(&start, &end, PyBytes_GET_SIZE(self));
 
-return PyInt_FromSsize_t(
-stringlib_count(str + start, end - start, sub, sub_len)
+count_obj = PyInt_FromSsize_t(
+stringlib_count(str + start, end - start, vsub.buf, vsub.len)
 );
+PyObject_ReleaseBuffer(sub_obj, &vsub);
+return count_obj;
 }
 
 
@@ -1210,36 +1239,39 @@
  Py_ssize_t end, int direction)
 {
 Py_ssize_t len = PyBytes_GET_SIZE(self);
-Py_ssize_t slen;
-const char* sub;
 const char* str;
+Py_buffer vsubstr;
+int rv;
 
-if (PyBytes_Check(substr)) {
-sub = PyBytes_AS_STRING(substr);
-slen = PyBytes_GET_SIZE(substr);
-}
-/* XXX --> Use the modern buffer interface */
-else if (PyObject_AsCharBuffer(substr, &sub, &slen))
-return -1;
 str = PyBytes_AS_STRING(self);
 
+if (_getbuffer(substr, &vsubstr) < 0)
+return -1;
+
 _adjust_indices(&start, &end, len);
 
 if (direction < 0) {
 /* startswith */
-if (start+slen > len)
-return 0;
+if (start+vsubstr.len > len) {
+rv = 0;
+goto done;
+}
 } else {

[issue1262] IDLE does not start if windows environment variable containing 'German Umlaute: äöü' exists

2007-10-11 Thread Reto Wehrli

New submission from Reto Wehrli:

C:\devtools\Python30\Lib\idlelib>set
...
eRoomOfflineFiles=Z:\Documents and Settings\tgdwere3\My Documents\eRoom
Dateien
für die Offline-Bearbeitung\
...

C:\devtools\Python30\Lib\idlelib>..\..\python.exe idle.pyw
object  : UnicodeDecodeError('utf8', b'Z:\\Documents and
Settings\\tgdwere3\\My
Documents\\eRoom Dateien f\xfcr die Offline-Bearbeitung\\', 63, 69, 'u
nsupported Unicode code range')
type: UnicodeDecodeError
refcount: 4
address : 00B825B0
lost sys.stderr

after removing the env variable idle starts

--
components: IDLE
messages: 56342
nosy: reto
severity: normal
status: open
title: IDLE does not start if windows environment variable containing 'German 
Umlaute: äöü' exists
type: crash
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Thomas Lee

New submission from Thomas Lee:

The main patch - while exactly what is needed to make str8/str equality
checks return False - breaks a bunch of tests due to PyString_* still
being used elsewhere when it should be using PyUnicode.

The second patch modifies structmember.c to use PyUnicode_* where it was
previously using PyString_*, which fixes the first problem I stumbled
across in trying to get test_unicode to run.

Unfortunately, similar errors are present in Python/codecs.c and other
places (maybe Python/modsupport.c too? not 100% sure yet) - these still
need to be fixed!

--
components: Interpreter Core
files: unicode-string-eq-false-r2.patch
messages: 56343
nosy: thomas.lee
severity: normal
status: open
title: PEP 3137 patch - str8/str comparison should return false
type: rfe
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/unicodeobject.c
===
--- Objects/unicodeobject.c	(revision 58389)
+++ Objects/unicodeobject.c	(working copy)
@@ -6191,16 +6191,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",
  left->ob_type->tp_name,
Index: Lib/stringprep.py
===
--- Lib/stringprep.py	(revision 58389)
+++ Lib/stringprep.py	(working copy)
@@ -5,6 +5,8 @@
 and mappings, for which a mapping function is provided.
 """
 
+import sys
+
 from unicodedata import ucd_3_2_0 as unicodedata
 
 assert unicodedata.unidata_version == '3.2.0'
Index: Lib/test/test_unicode.py
===
--- Lib/test/test_unicode.py	(revision 58389)
+++ Lib/test/test_unicode.py	(working copy)
@@ -200,6 +200,10 @@
 self.checkequalnofix('[EMAIL PROTECTED]', 'one!two!three!', 'replace', '!', '@', 1)
 self.assertRaises(TypeError, 'replace'.replace, "r", 42)
 
+def test_str8_comparison(self):
+self.assertEqual('abc' == str8('abc'), False)
+self.assertEqual('abc' != str8('abc'), True)
+
 def test_comparison(self):
 # Comparisons:
 self.assertEqual('abc', 'abc')
___
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

2007-10-11 Thread Thomas Lee

Changes by Thomas Lee:


__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Thomas Lee

Thomas Lee added the comment:

Oops - use unicode-string-eq-false-r3.patch, not
unicode-string-eq-false-r2.patch.

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/unicodeobject.c
===
--- Objects/unicodeobject.c	(revision 58389)
+++ Objects/unicodeobject.c	(working copy)
@@ -6191,16 +6191,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",
  left->ob_type->tp_name,
Index: Lib/test/test_unicode.py
===
--- Lib/test/test_unicode.py	(revision 58389)
+++ Lib/test/test_unicode.py	(working copy)
@@ -200,6 +200,10 @@
 self.checkequalnofix('[EMAIL PROTECTED]', 'one!two!three!', 'replace', '!', '@', 1)
 self.assertRaises(TypeError, 'replace'.replace, "r", 42)
 
+def test_str8_comparison(self):
+self.assertEqual('abc' == str8('abc'), False)
+self.assertEqual('abc' != str8('abc'), True)
+
 def test_comparison(self):
 # Comparisons:
 self.assertEqual('abc', 'abc')
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1264] __file__ and co_filename as unicode

2007-10-11 Thread Christian Heimes

New submission from Christian Heimes:

This is a *preliminary* patch for __file__ and co_filename which decodes
char* / PyString using the FS default encoding. I'm still working on it.

--
components: Interpreter Core
files: py3k_file_fsenc.patch
messages: 56345
nosy: tiran
severity: normal
status: open
title: __file__ and co_filename as unicode
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__Index: Python/pythonrun.c
===
--- Python/pythonrun.c	(revision 58412)
+++ Python/pythonrun.c	(working copy)
@@ -867,7 +867,8 @@
 		return -1;
 	d = PyModule_GetDict(m);
 	if (PyDict_GetItemString(d, "__file__") == NULL) {
-		PyObject *f = PyString_FromString(filename);
+		PyObject *f;
+f = _PyUnicode_DecodeFSDefault(filename, strlen(filename), NULL);
 		if (f == NULL)
 			return -1;
 		if (PyDict_SetItemString(d, "__file__", f) < 0) {
Index: Python/import.c
===
--- Python/import.c	(revision 58412)
+++ Python/import.c	(working copy)
@@ -652,9 +652,11 @@
 	/* Remember the filename as the __file__ attribute */
 	v = NULL;
 	if (pathname != NULL) {
-		v = PyString_FromString(pathname);
-		if (v == NULL)
+		v = _PyUnicode_DecodeFSDefault(pathname, strlen(pathname), NULL);
+		if (v == NULL) {
 			PyErr_Clear();
+printf("__file__ error");
+}
 	}
 	if (v == NULL) {
 		v = ((PyCodeObject *)co)->co_filename;
@@ -983,7 +985,7 @@
 		PySys_WriteStderr("import %s # directory %s\n",
 			name, pathname);
 	d = PyModule_GetDict(m);
-	file = PyString_FromString(pathname);
+	file = _PyUnicode_DecodeFSDefault(pathname, strlen(pathname), NULL);
 	if (file == NULL)
 		goto error;
 	path = Py_BuildValue("[O]", file);
Index: Python/importdl.c
===
--- Python/importdl.c	(revision 58412)
+++ Python/importdl.c	(working copy)
@@ -62,7 +62,9 @@
 		return NULL;
 	}
 	/* Remember the filename as the __file__ attribute */
-	if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
+PyObject *path;
+path = _PyUnicode_DecodeFSDefault(pathname, strlen(pathname), NULL);
+	if (PyModule_AddObject(m, "__file__", path) < 0)
 		PyErr_Clear(); /* Not important enough to report */
 
 	if (_PyImport_FixupExtension(name, pathname) == NULL)
Index: Include/unicodeobject.h
===
--- Include/unicodeobject.h	(revision 58412)
+++ Include/unicodeobject.h	(working copy)
@@ -154,6 +154,7 @@
 # define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII
 # define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap
 # define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1
+# define _PyUnicode_DecodeFSDefault _PyUnicodeUCS2_DecodeFSDefault
 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape
 # define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32
 # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful
@@ -245,6 +246,7 @@
 # define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII
 # define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap
 # define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1
+# define _PyUnicode_DecodeFSDefault _PyUnicodeUCS4_DecodeFSDefault
 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape
 # define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32
 # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful
@@ -641,6 +643,20 @@
 PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
 PyObject *, const char *);
 
+/* Decode a string to a Python unicode object using either
+   Py_FileSystemDefaultEncoding or UTF-8 if the default encoding isn't given.
+
+   *** Exported for internal use by the interpreter only !!! ***
+
+*/
+
+PyAPI_FUNC(PyObject*) _PyUnicode_DecodeFSDefault(
+const char *string, 	/* encoded string */
+Py_ssize_t length,	 	/* size of string */
+const char *errors		/* error handling */
+);
+
+
 /* Return a char* holding the UTF-8 encoded value of the
Unicode object.
 
Index: Objects/codeobject.c
===
--- Objects/codeobject.c	(revision 58412)
+++ Objects/codeobject.c	(working copy)
@@ -59,7 +59,7 @@
 	freevars == NULL || !PyTuple_Check(freevars) ||
 	cellvars == NULL || !PyTuple_Check(cellvars) ||
 	name == NULL || (!PyString_Check(name) && !PyUnicode_Check(name)) ||
-	filename == NULL || !PyString_Check(filename) ||
+	filename == NULL || (!PyString_Check(name) && !PyUnicode_Check(name)) ||
 	lnotab == NULL || !PyString_Check(lnotab) ||
 	!PyObject_CheckReadBuffer(code)) {
 		PyErr_BadInternalCall();
@@ -72,6 +72,20 @@
 	} else {
 		Py_INCREF(name);
 	}
+	if (PyString_Check(filename)) {
+/* We don't have enough infrastructure h

[issue1265] pdb bug with "with" statement

2007-10-11 Thread Christian Heimes

New submission from Christian Heimes:

found a pretty annoying bug caused by with blocks. A with block
terminates the debugging session and the program keeps running. It's not
possible to go to the next line with 'n'. 's' steps into the open() call.

# pdbtest.py
import pdb
pdb.set_trace()
print("before with")
with open("/etc/passwd") as fd:
data = fd.read()
print("after with")
print("end of program")

$ ./python pdbtest.py
> /home/heimes/dev/python/py3k/pdbtest.py(3)()
-> print("before with")
(Pdb) n
before with
> /home/heimes/dev/python/py3k/pdbtest.py(4)()
-> with open("/etc/passwd") as fd:
(Pdb) n
after with
end of program

--
components: Interpreter Core, Library (Lib)
messages: 56346
nosy: tiran
severity: normal
status: open
title: pdb bug with "with" statement
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__
___
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 use PEP 3118 buffer API

2007-10-11 Thread Guido van Rossum

Changes by Guido van Rossum:


--
assignee:  -> gvanrossum
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1260] PEP 3137: Remove the buffer API from PyUnicode

2007-10-11 Thread Guido van Rossum

Changes by Guido van Rossum:


--
assignee:  -> gvanrossum
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Guido van Rossum

Changes by Guido van Rossum:


--
assignee:  -> gvanrossum
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Guido van Rossum

Guido van Rossum added the comment:

There are tons of situations where such an exception will be
suppressed, ofr better or for worse. I don't think this one deserves
such a radical approach.

On 10/11/07, atsuo ishimoto <[EMAIL PROTECTED]> wrote:
>
> atsuo ishimoto added the comment:
>
> Codecs would hardly ever raises exception here.
> Usually, exception raised here would be a MemoryError. The unicode
> string we are trying to encode is just decoded by same codec. If codec
> raises exception other than MemoryError, the codec will likely have problem.
>
> I attached a script to print exception raised by codec. I wrote a "buggy"
> encoder, which never return string but raises an exception.
>
> _
> Tracker <[EMAIL PROTECTED]>
> 
> _
>

_
Tracker <[EMAIL PROTECTED]>

_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1265] pdb bug with "with" statement

2007-10-11 Thread Guido van Rossum

Changes by Guido van Rossum:


--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1266] segfault in curses when calling redrawwin() before refresh()

2007-10-11 Thread Thorben

New submission from Thorben:

attached file makes python 2.5.1 segfault

--
components: Library (Lib)
files: curses-01.py
messages: 56348
nosy: Thorben
severity: critical
status: open
title: segfault in curses when calling redrawwin() before refresh()
type: crash
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

__import readline, curses

def foobar(stdscr):
winmain = curses.newwin(50,50,50,50)
winmain.redrawwin()
stdscr.refresh()

curses.wrapper(foobar)


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1203] ctypes doesn't work on Mac with --disable-toolbox-glue

2007-10-11 Thread Thomas Heller

Thomas Heller added the comment:

IMO os.uname() is preferable.
Committed as SVN rev 58415 in trunk.
Thanks.

--
assignee:  -> theller
resolution:  -> accepted
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1264] __file__ and co_filename as unicode

2007-10-11 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue756576] Recursion limit too high for MacOSX

2007-10-11 Thread Brett Cannon

Changes by Brett Cannon:


--
status: open -> closed


Tracker <[EMAIL PROTECTED]>


___
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``

2007-10-11 Thread Brett Cannon

New submission from Brett Cannon:

If Py3K is executed without importing site, it fails horribly.  This is
because site.py sets __builtins__.open, sys.stdout, sys.stderr, and
sys.stdin.

The setting of sys.stderr is especially bad as exception printing
requires sys.stderr, otherwise it reports that sys.stderr was lost. 
This prevents debugging any exceptions thrown when site.py isn't/can't
be imported (e.g., trying to debug bootstrapping importlib).

--
components: Interpreter Core
keywords: py3k
messages: 56350
nosy: brett.cannon
severity: normal
status: open
title: Py3K cannot run as ``python -S``
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Gregory P. Smith

Changes by Gregory P. Smith:


__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Guido van Rossum

Guido van Rossum added the comment:

> Patch updated.  It now implements the is*() methods for PyBytes.  It
> moves common code into a shared bytes_ctype.c and .h file so that
> stringobject.c and bytesobject.c can share as much as possible.

Did you move this into the stringlib subdirectory? That's more for
sharing between PyString and PyUnicode, but I think there are more
opportunities for sharing still, and PyString/PyBytes sharing makes
sense separately.

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1268] array unittest problems with UCS4 build

2007-10-11 Thread Christian Heimes

New submission from Christian Heimes:

The array module is using a different typecode for unicode array
depending on UCS2 or UCS4:

#define Py_UNICODE_SIZE 4

#if Py_UNICODE_SIZE >= 4
#define Py_UNICODE_WIDE
#endif

#ifdef Py_UNICODE_WIDE
#define PyArr_UNI 'w'
#define PyArr_UNISTR "w"
#else
#define PyArr_UNI 'u'
#define PyArr_UNISTR "u"
#endif

It's causing a bunch of unit test to fail which depend on 'u' as the
type code for an unicode array. I don't see the benefit from specifying
an alternative typecode for wide unicode arrays. It may be useful to
have an additional typecode that fails for UCS-2 builds.

My patch keeps 'u' in every build and adds 'w' as an alias for 'u' in
UCS-4 builds only. It also introduces the new module variable typecodes
which is a unicode string containing all valid typecodes.

--
components: Extension Modules
files: py3k_array_typecode.patch
messages: 56353
nosy: tiran
severity: normal
status: open
title: array unittest problems with UCS4 build
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/codeobject.c
===
--- Objects/codeobject.c	(Revision 58412)
+++ Objects/codeobject.c	(Arbeitskopie)
@@ -59,7 +59,7 @@
 	freevars == NULL || !PyTuple_Check(freevars) ||
 	cellvars == NULL || !PyTuple_Check(cellvars) ||
 	name == NULL || (!PyString_Check(name) && !PyUnicode_Check(name)) ||
-	filename == NULL || !PyString_Check(filename) ||
+	filename == NULL || (!PyString_Check(name) && !PyUnicode_Check(name)) ||
 	lnotab == NULL || !PyString_Check(lnotab) ||
 	!PyObject_CheckReadBuffer(code)) {
 		PyErr_BadInternalCall();
Index: Lib/test/test_codecs.py
===
--- Lib/test/test_codecs.py	(Revision 58412)
+++ Lib/test/test_codecs.py	(Arbeitskopie)
@@ -803,7 +803,7 @@
 codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
 decoder = codecs.getdecoder("unicode_internal")
 ab = "ab".encode("unicode_internal")
-ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:])),
+ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]), "ascii"),
 "UnicodeInternalTest")
 self.assertEquals(("ab", 12), ignored)
 
Index: Lib/test/test_array.py
===
--- Lib/test/test_array.py	(Revision 58412)
+++ Lib/test/test_array.py	(Arbeitskopie)
@@ -17,8 +17,18 @@
 array.array.__init__(typecode)
 
 tests = [] # list to accumulate all tests
-typecodes = "ubBhHiIlLfd"
+typecodes = array.typecodes
 
+class TypecodesTest(unittest.TestCase):
+expected_typecodes = "ubBhHiIlLfd"
+
+def test_typecodes(self):
+global typecodes
+for typecode in self.expected_typecodes:
+self.assert_(typecode in typecodes, typecode)
+
+tests.append(TypecodesTest)
+
 class BadConstructorTest(unittest.TestCase):
 
 def test_constructor(self):
@@ -773,6 +783,12 @@
 
 tests.append(UnicodeTest)
 
+class UnicodeWideTest(UnicodeTest):
+typecode = 'w'
+
+if 'w' in typecodes:
+tests.append(UnicodeWideTest)
+
 class NumberTest(BaseTest):
 
 def test_extslice(self):
Index: Lib/test/test_re.py
===
--- Lib/test/test_re.py	(Revision 58412)
+++ Lib/test/test_re.py	(Arbeitskopie)
@@ -591,7 +591,7 @@
 self.assertEqual([item.group(0) for item in iter],
  [":", "::", ":::"])
 
-def test_bug_926075(self):
+def DISABLED_test_bug_926075(self):
 self.assert_(re.compile('bug_926075') is not
  re.compile(str8('bug_926075')))
 
@@ -618,7 +618,7 @@
 def test_empty_array(self):
 # SF buf 1647541
 import array
-for typecode in 'bBuhHiIlLfd':
+for typecode in array.typecodes:
 a = array.array(typecode)
 self.assertEqual(re.compile("bla").match(a), None)
 self.assertEqual(re.compile("").match(a).groups(), ())
Index: Lib/test/test_codeccallbacks.py
===
--- Lib/test/test_codeccallbacks.py	(Revision 58412)
+++ Lib/test/test_codeccallbacks.py	(Arbeitskopie)
@@ -140,17 +140,17 @@
 sin += chr(sys.maxunicode)
 sout = b"a\\xac\\u1234\\u20ac\\u8000"
 if sys.maxunicode > 0x:
-sout += bytes("\\U%08x" % sys.maxunicode)
+sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
 self.assertEqual(sin.encode("ascii", "backslashreplace"), sout)
 
 sout = b"a\xac\\u1234\\u20ac\\u8000"
 if sys.maxunicode > 0x:
-sout += bytes("\\U%08x" % sys.maxunicode)
+sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
 self.assert

[issue1261] PEP 3137: make bytesobject.c methods

2007-10-11 Thread Gregory P. Smith

Gregory P. Smith added the comment:

> > Patch updated.  It now implements the is*() methods for PyBytes.  It
> > moves common code into a shared bytes_ctype.c and .h file so that
> > stringobject.c and bytesobject.c can share as much as possible.
>
> Did you move this into the stringlib subdirectory? That's more for
> sharing between PyString and PyUnicode, but I think there are more
> opportunities for sharing still, and PyString/PyBytes sharing makes
> sense separately.

Good idea, I haven't done that yet. At the moment it lives in
Include/bytes_ctype.h and Object/bytes_ctype.c directly.  stringlib is a
good place for it and is something I pondered but hadn't gotten to.  I'll do
that as I implement the remaining missing PyBytes_ methods to be in the next
update to this patch.

-gps

--
nosy: +gps

__
Tracker <[EMAIL PROTECTED]>

__> Patch 
updated.  It now implements the is*() methods for 
PyBytes.  It> moves common code into a shared bytes_ctype.c 
and .h file so that
> stringobject.c and bytesobject.c can share as much as 
possible.Did you move this into the stringlib subdirectory? That's 
more forsharing between PyString and PyUnicode, but I think there are 
more
opportunities for sharing still, and PyString/PyBytes sharing makessense 
separately.Good idea, I haven't done that yet. At the 
moment it lives in Include/bytes_ctype.h and Object/bytes_ctype.c 
directly.  stringlib is a good place for it and is something I pondered 
but hadn't gotten to.  I'll do that as I implement the remaining 
missing PyBytes_ methods to be in the next update to this patch.
-gps

___
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

2007-10-11 Thread Gregory P. Smith

Changes by Gregory P. Smith:


__
Tracker <[EMAIL PROTECTED]>

__
___
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

2007-10-11 Thread Gregory P. Smith

Changes by Gregory P. Smith:


--
nosy:  -gps

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1266] segfault in curses when calling redrawwin() before refresh()

2007-10-11 Thread Neal Norwitz

Neal Norwitz added the comment:

What platform are you on?  I can reproduce this with 2.5.1+ and trunk on
Ubuntu.  I can reproduce with a trivial C program that does the same
thing.  This could be a bug in the curses implementation.  Or it could
be misuse of the API.  I don't know enough to suggest which is the case.  

The C program is:

#include 

int main(int argc, char**argv) {
  WINDOW *win = initscr();
  WINDOW *win2 = newwin(50, 50, 50, 50);
  redrawwin(win2);
  return 0;
}

Perhaps a bug should be filed against curses.

--
components: +Extension Modules -Library (Lib)
nosy: +nnorwitz

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1233] bsddb.dbshelve.DbShelf.append doesn't work

2007-10-11 Thread Neal Norwitz

Neal Norwitz added the comment:

Gregory, could you take a look at this?

--
assignee:  -> gregory.p.smith
components: +Extension Modules -Library (Lib)
nosy: +gregory.p.smith, nnorwitz

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1216] Python2.5.1 fails to compile under VC.NET2002 ( 7.0 )

2007-10-11 Thread Neal Norwitz

Neal Norwitz added the comment:

Martin, it looks like you made some changes in rev 46064.  Can you
suggest anything?

--
assignee:  -> loewis
components: +Extension Modules
nosy: +loewis, nnorwitz

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com