Detlef Lannert wrote:
Kann mir von den Experten hier jemand erklären, warum überhaupt der gesamte Quelltext _vor_ der Syntaxanalyse umcodiert werden soll? (Sonst wären ja Kommentare syntaktisch zu erkennen und könnten ignoriert werden.) Die Python-Quellen selbst durften ja schon bisher außerhalb von Strings und Kommentaren nur ASCII pur enthalten;
Tatsaechlich darf eine Python-Quelle nach Spezifikation bis und mit 2.2 ausschliesslich ASCII enthalten, egal ob innerhalb oder ausserhalb von String-Literals und Kommentaren. Der Parser war bisher so zwar freundlich (oder nachlaessig), Abweichendes trotzdem zu schlucken, dieses Verhalten ist aber als Bug zu klassifizieren, welcher mit 2.3 nun behoben wird. Es hat ja ohnehin nur fuer diejenigen (vorwiegend westlichen) Sprachen "funktioniert", welche alle ihre Zeichen in 8 Bits unterbringen koennen. Nicht-ASCII Zeichensaetze koennen darum ohne Kennzeichnung nicht zugelassen werden, weil dann z.B. in gewissen Faellen nicht mehr erkennbar waere, wo die Zeilen aufhoeren. Bei Zeichensaetzen mit Multibyte-Codierung kann durchaus mal ein '\n' oder sonst etwas Unangenehmes als Teil eines 2-Byte Zeichens auch in der Mitte der Zeile vorkommen. Ohne Zeichensatz-Deklaration hat der Parser aber nicht die geringste Chance, den Unterschied zu erkennen. Die einzige Alternative stellen Unicode-Quellen in UTF-16 mit BOM dar, weil damit schon grundsaetzlich keine Mehrdeutigkeit mehr moeglich ist.
Dies soll keine rhetorische (sprich trollige) Frage sein; ich sehe im 2.3-Verhalten von Python aber sogar ein potentielles Sicherheitsproblem, weil in den (lästigen!) Warnungsmeldungen die erste Zeile auftaucht, die Umlaute o.ä. hat. Wenn sie Paßwörter oder abfällige Bemerkungen enthält -- was bisher in einigen Einsatzfällen unkritisch war --, hat der Autor Ärger am Hals.
Der Aerger ist in solchen Faellen wohl redlich verdient. ;) -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ _______________________________________________ Python-de maillist - Python-de@starship.python.net http://starship.python.net/mailman/listinfo/python-de