Re: Another 2 to 3 mail encoding problem

2020-08-31 Thread Peter J. Holzer
On 2020-08-27 09:34:47 +0100, Chris Green wrote: > Peter J. Holzer wrote: > > The problem is that the message contains a '\ufeff' character (byte > > order mark) where email/generator.py expects only ASCII characters. > > > > I see two possible reasons for this: [...] > > Both reasons are weird.

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread MRAB
On 2020-08-27 17:29, Barry Scott wrote: On 26 Aug 2020, at 16:10, Chris Green wrote: UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in position 4: ordinal not in range(128) So what do I need to do to the message I'm adding with mbx.add(msg) to fix this? (I assume

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Barry Scott
> On 26 Aug 2020, at 16:10, Chris Green wrote: > > UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in > position 4: ordinal not in range(128) > > So what do I need to do to the message I'm adding with mbx.add(msg) to > fix this? (I assume that's what I need to do). >>>

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Barry
> On 27 Aug 2020, at 10:40, Chris Green wrote: > > Karsten Hilbert wrote: >>> Terry Reedy wrote: > On 8/26/2020 11:10 AM, Chris Green wrote: > >> I have a simple[ish] local mbox mail delivery module as follows:- > ... >> It has run faultlessly for many years under

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Richard Damon wrote: > On 8/27/20 4:31 AM, Chris Green wrote: > > While an E-Mail body possibly *shouldn't* have non-ASCII characters in > > it one must be able to handle them without errors. In fact haven't > > the RFCs changed such that the message body should be 8-bit clean? > > Anyway I

Aw: Re: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> > > Because of this, the Python 3 str type is not suitable to store an email > > > message, since it insists on the string being Unicode encoded, > > > > I should greatly appreciate to be enlightened as to what > > a "string being Unicode encoded" is intended to say ? > > > > A Python 3 "str" or

Re: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Angelico
On Thu, Aug 27, 2020 at 11:10 PM Karsten Hilbert wrote: > > > Because of this, the Python 3 str type is not suitable to store an email > > message, since it insists on the string being Unicode encoded, > > I should greatly appreciate to be enlightened as to what > a "string being Unicode encoded"

Aw: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> Because of this, the Python 3 str type is not suitable to store an email > message, since it insists on the string being Unicode encoded, I should greatly appreciate to be enlightened as to what a "string being Unicode encoded" is intended to say ? Thanks, Karsten --

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Richard Damon
On 8/27/20 4:31 AM, Chris Green wrote: > While an E-Mail body possibly *shouldn't* have non-ASCII characters in > it one must be able to handle them without errors. In fact haven't > the RFCs changed such that the message body should be 8-bit clean? > Anyway I think the Python 3 mail handling

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Karsten Hilbert wrote: > > Terry Reedy wrote: > > > On 8/26/2020 11:10 AM, Chris Green wrote: > > > > > > > I have a simple[ish] local mbox mail delivery module as follows:- > > > ... > > > > It has run faultlessly for many years under Python 2. I've now > > > > changed the calling program to

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Cameron Simpson
On 27Aug2020 09:31, Chris Green wrote: >I can provoke the error simply by sending myself an E-Mail with >accented characters in it. I'm pretty sure my Linux system is set up >correctly for UTF8 characters, I certainly seem to be able to send and >receive these to others and I even get to see

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Peter Otten
Chris Green wrote: > To add a little to this, the problem is definitely when I receive a > message with UTF8 (or at least non-ascci) characters in it. My code > is basically very simple, the main program reads an E-Mail message > received from .forward on its standard input and makes it into an

Aw: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> Terry Reedy wrote: > > On 8/26/2020 11:10 AM, Chris Green wrote: > > > > > I have a simple[ish] local mbox mail delivery module as follows:- > > ... > > > It has run faultlessly for many years under Python 2. I've now > > > changed the calling program to Python 3 and while it handles most > >

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Peter J. Holzer wrote: > The problem is that the message contains a '\ufeff' character (byte > order mark) where email/generator.py expects only ASCII characters. > > I see two possible reasons for this: > > * The mbox writing code assumes that all messages with non-ascii >characters are

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Terry Reedy wrote: > On 8/26/2020 11:10 AM, Chris Green wrote: > > > I have a simple[ish] local mbox mail delivery module as follows:- > ... > > It has run faultlessly for many years under Python 2. I've now > > changed the calling program to Python 3 and while it handles most > > E-Mail OK I

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Terry Reedy
On 8/26/2020 11:10 AM, Chris Green wrote: I have a simple[ish] local mbox mail delivery module as follows:- ... It has run faultlessly for many years under Python 2. I've now changed the calling program to Python 3 and while it handles most E-Mail OK I have just got the following error:-

Unsubscrip (Re: Another 2 to 3 mail encoding problem)

2020-08-26 Thread Terry Reedy
On 8/26/2020 11:27 AM, Alexa Oña wrote: Don’t send me more emails -- https://mail.python.org/mailman/listinfo/python-list Unsubscribe yourself by going to the indicated url. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Michael Torrie
On 8/26/20 9:27 AM, Alexa Oña wrote: > Don’t send me more emails > > https://mail.python.org/mailman/listinfo/python-list ^ Please unsubscribe from the mailing list. Click on the link above. Thank you. --

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Peter J. Holzer
On 2020-08-26 16:10:35 +0100, Chris Green wrote: > I'm unearthing a few issues here trying to convert my mail filter and > delivery programs from 2 to 3! > > I have a simple[ish] local mbox mail delivery module as follows:- > [...] > class mymbox(mailbox.mbox): > def

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Python
Alexa Oña wrote: Don’t send me more emails Obtener Outlook para iOS You are the one spamming the mailing list with unrelated posts. STOP. -- https://mail.python.org/mailman/listinfo/python-list

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Chris Green
To add a little to this, the problem is definitely when I receive a message with UTF8 (or at least non-ascci) characters in it. My code is basically very simple, the main program reads an E-Mail message received from .forward on its standard input and makes it into an mbox message as follows:-

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Alexa Oña
Don’t send me more emails Obtener Outlook para iOS<https://aka.ms/o0ukef> De: Python-list en nombre de Chris Green Enviado: Wednesday, August 26, 2020 5:10:35 PM Para: python-list@python.org Asunto: Another 2 to 3 mail encoding problem I'm unearthing

Another 2 to 3 mail encoding problem

2020-08-26 Thread Chris Green
I'm unearthing a few issues here trying to convert my mail filter and delivery programs from 2 to 3! I have a simple[ish] local mbox mail delivery module as follows:- import mailbox import logging import logging.handlers import os import time # # # Class

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2019-04-01 Thread Inada Naoki
Change by Inada Naoki : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.7, Python 3.8 -Python 3.4, Python 3.5, Python 3.6 ___ Python tracker

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2019-04-01 Thread Inada Naoki
Inada Naoki added the comment: New changeset 8384670615a90418fc52c3881242b7c10d1f2b13 by Inada Naoki in branch '3.7': bpo-20844: open script file with "rb" mode (GH-12616) https://github.com/python/cpython/commit/8384670615a90418fc52c3881242b7c10d1f2b13 --

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2019-04-01 Thread Inada Naoki
Change by Inada Naoki : -- pull_requests: +12579 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2019-04-01 Thread Inada Naoki
Inada Naoki added the comment: New changeset 10654c19b5e6efdf3c529ff9bf7bcab89bdca1c1 by Inada Naoki in branch 'master': bpo-20844: open script file with "rb" mode (GH-12616) https://github.com/python/cpython/commit/10654c19b5e6efdf3c529ff9bf7bcab89bdca1c1 -- nosy: +inada.naoki

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2019-03-29 Thread Inada Naoki
Change by Inada Naoki : -- keywords: +patch pull_requests: +12552 stage: -> patch review ___ Python tracker ___ ___

[issue35140] encoding problem: coding:gbk cause syntaxError

2018-11-11 Thread Emmanuel Arias
Emmanuel Arias added the comment: I can not reproduce this issue on my Debian9. -- nosy: +eamanu ___ Python tracker ___ ___

[issue35140] encoding problem: coding:gbk cause syntaxError

2018-11-11 Thread Steve Dower
Steve Dower added the comment: Yes, seems like we should be opening the file in binary mode, though I haven't tried it. The CRT's interpretation of text mode really isn't compatible with Python's own interpretation of text mode, and chaining them makes even less sense. --

[issue35140] encoding problem: coding:gbk cause syntaxError

2018-11-10 Thread Ma Lin
Ma Lin added the comment: I debugged, this is a duplicate of issue 20844 and issue 27797. Eryk Sun analyzed this detailedly, it's a problem of Windows CRT. -- versions: +Python 3.5, Python 3.6, Python 3.8 ___ Python tracker

[issue35140] encoding problem: coding:gbk cause syntaxError

2018-11-02 Thread Windson Yang
Change by Windson Yang : -- title: encoding problem: gbk -> encoding problem: coding:gbk cause syntaxError ___ Python tracker <https://bugs.python.org/issu

[issue35140] encoding problem: gbk

2018-11-02 Thread Windson Yang
Windson Yang added the comment: It's fine @anmikf, keep practice :D. Let's recap what happened: Run encoding_problem_gbk.py on Windows10 using Python 3.7.0 will cause "SyntaxError: encoding problem: gbk". But it will run as expected if 1. The file has less than less than 15 lines.

[issue35140] encoding problem: gbk

2018-11-02 Thread Tim Golden
Tim Golden added the comment: I'm afraid you'll have to use English in this forum so that all current and future readers have the best chance of understanding the situation. Thank you very much for making the effort this far. If anyone on this issue knows of a Chinese-language forum where

[issue35140] encoding problem: gbk

2018-11-02 Thread 安迷
安迷 added the comment: I'm sorry for my english. Can I use Chinese? -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue35140] encoding problem: gbk

2018-11-02 Thread 安迷
安迷 added the comment: this problem not exist on macOS. this problem not exist in python2. Windows10x64 Python 3.7.0 (v3.7.0:1bf9cc5093 script have no problem with 15 blank lines. script haveproblem with fist line '#coding:gbk' and 14 blank lines. --

[issue35140] encoding problem: gbk

2018-11-02 Thread Ma Lin
Ma Lin added the comment: Yes, I can reproduce on my Windows 10 (Simplfied Chinese). The file is a pure ASCII file, and doesn't have a BOM prefix. -- ___ Python tracker ___

[issue35140] encoding problem: gbk

2018-11-02 Thread Windson Yang
Windson Yang added the comment: Thank you, Lin. Can you reproduce on your machine, I guess it is related to terminal encoding or text file ending. However, I can't reproduce on macOS. -- ___ Python tracker

[issue35140] encoding problem: gbk

2018-11-02 Thread Ma Lin
Ma Lin added the comment: Let me give an explanation. Run encoding_problem_gbk.py, get an error: D:\>encoding_problem_gbk.py File "D:\encoding_problem_gbk.py", line 1 SyntaxError: encoding problem: gbk If remove the comment line, run as expected. --

[issue35140] encoding problem: gbk

2018-11-02 Thread Windson Yang
Windson Yang added the comment: If I understand your question correctly, you should save the file(the one contain Chinese chars) with GBK encoding using your editor. Otherwise, your editor would save it using the default encoding which led to python can't decode it correctly. --

[issue35141] encoding problem: gbk

2018-11-01 Thread Karthikeyan Singaravelan
. Thanks! -- nosy: +xtreak resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> encoding problem: gbk ___ Python tracker <https://bugs.python

[issue35141] encoding problem: gbk

2018-11-01 Thread 安迷
severity: normal status: open title: encoding problem: gbk type: behavior versions: Python 3.7 Added file: https://bugs.python.org/file47902/encoding_problem_gbk.py ___ Python tracker <https://bugs.python.org/issue35

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2017-08-08 Thread Mark Lawrence
Changes by Mark Lawrence : -- nosy: -BreamoreBoy ___ Python tracker ___ ___

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2017-08-08 Thread Steven Winfield
44.py", line 1 SyntaxError: encoding problem: iso-8859-1 * File length > 4096, with no leading spaces in the docstring: File "issue20844.py", line 56 x""" ^ SyntaxError: EOF while scanning tripl

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2014-12-27 Thread Ned Batchelder
Ned Batchelder added the comment: This bug just bit me. Changing # coding: utf8 to # coding: utf-8 works around it. -- nosy: +nedbat ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20844 ___

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2014-12-27 Thread Ned Batchelder
Ned Batchelder added the comment: (oops: with Python 3.4.1 on Windows) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20844 ___ ___

[issue20844] SyntaxError: encoding problem: iso-8859-1 on Windows

2014-07-30 Thread Mark Lawrence
Mark Lawrence added the comment: I've tried to make the title more meaningful, feel free to change it if you can think of something better. -- components: +Interpreter Core nosy: +tim.golden, zach.ware title: coding bug remains in 3.3.5rc2 - SyntaxError: encoding problem: iso-8859-1

Re: Encoding problem in python

2013-08-21 Thread electron
If you use Arabic frequently on your system, I suggest to change your windows system locale from Region and Language in control panel (Administrative tab) and set to Arabic. -- http://mail.python.org/mailman/listinfo/python-list

Encoding problem in python

2013-03-04 Thread yomnasalah91
I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? -- http://mail.python.org/mailman/listinfo/python-list

Re: Encoding problem in python

2013-03-04 Thread Laszlo Nagy
On 2013-03-04 10:37, yomnasala...@gmail.com wrote: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? Maybe it is not Python related. Did you get an exception? Can

Re: Encoding problem in python

2013-03-04 Thread Steven D'Aprano
On Mon, 04 Mar 2013 01:37:42 -0800, yomnasalah91 wrote: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? Firstly, please show the COMPLETE error,

Re: Encoding problem in python

2013-03-04 Thread Vlastimil Brom
2013/3/4 yomnasala...@gmail.com: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? -- http://mail.python.org/mailman/listinfo/python-list Hi, I guess, you

[issue13395] Python ISO-8859-1 encoding problem

2011-11-13 Thread Hugo Silva
New submission from Hugo Silva hugo...@gmail.com: Hi all, I'm facing a huge encoding problem in Python when dealing with ISO-8859-1 / Latin-1 character set. When using os.listdir to get the contents of a folder I'm getting the strings encoded in ISO-8859-1 (ex: ''Ol\xe1 Mundo''), however

[issue13395] Python ISO-8859-1 encoding problem

2011-11-13 Thread Ezio Melotti
Ezio Melotti ezio.melo...@gmail.com added the comment: This doesn't seem a bug to me, so you should ask for help somewhere else. You can try to pass a unicode arg to listdir to get unicode back, and double check what the input actually is. -- resolution: - invalid stage: -

[issue13395] Python ISO-8859-1 encoding problem

2011-11-13 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Apparently, you are using the interactive shell on Microsoft Windows. This will use the OEM code page; which one that is depends on the exact Windows regional version you are using. You shouldn't decode the string with 'latin-1', but with

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-08 Thread Nobody
On Wed, 05 Oct 2011 21:39:17 -0700, Greg wrote: Here is the final code for those who are struggling with similar problems: ## open and decode file # In this case, the encoding comes from the charset argument in a meta tag # e.g. meta charset=iso-8859-2 fileObj = open(filePath,r).read()

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread Ulrich Eckhardt
Am 06.10.2011 05:40, schrieb Steven D'Aprano: (4) Do all your processing in Unicode, not bytes. (5) Encode the text into bytes using UTF-8 encoding. (6) Write the bytes to a file. Just wondering, why do you split the latter two parts? I would have used codecs.open() to open the file and

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread Chris Angelico
On Thu, Oct 6, 2011 at 8:29 PM, Ulrich Eckhardt ulrich.eckha...@dominalaser.com wrote: Just wondering, why do you split the latter two parts? I would have used codecs.open() to open the file and define the encoding in a single step. Is there a downside to this approach? Those two steps still

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread jmfauth
On 6 oct, 06:39, Greg gregor.hochsch...@googlemail.com wrote: Brilliant! It worked. Thanks! Here is the final code for those who are struggling with similar problems: ## open and decode file # In this case, the encoding comes from the charset argument in a meta tag # e.g. meta

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread xDog Walker
On Thursday 2011 October 06 10:41, jmfauth wrote: or  (Python2/Python3) import io with io.open('abc.txt', 'r', encoding='iso-8859-2') as f: ...     r = f.read() ... repr(r) u'a\nb\nc\n' with io.open('def.txt', 'w', encoding='utf-8-sig') as f: ...     t = f.write(r) ...

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread John Gordon
In mailman.1785.1317928997.27778.python-l...@python.org xDog Walker thud...@gmail.com writes: What is this io of which you speak? It was introduced in Python 2.6. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted

encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Hi, I am having some encoding problems when I first parse stuff from a non-english website using BeautifulSoup and then write the results to a txt file. I have the text both as a normal (text) and as a unicode string (utext): print repr(text) 'Branie zak\xc2\xb3adnik\xc3\xb3w' print repr(utext)

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 16:35:59 -0700, Greg wrote: Hi, I am having some encoding problems when I first parse stuff from a non-english website using BeautifulSoup and then write the results to a txt file. If you haven't already read this, you should do so:

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Brilliant! It worked. Thanks! Here is the final code for those who are struggling with similar problems: ## open and decode file # In this case, the encoding comes from the charset argument in a meta tag # e.g. meta charset=iso-8859-2 fileObj = open(filePath,r).read() fileContent =

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 3:39 PM, Greg gregor.hochsch...@googlemail.com wrote: Brilliant! It worked. Thanks! Here is the final code for those who are struggling with similar problems: ## open and decode file # In this case, the encoding comes from the charset argument in a meta tag # e.g.

Re: the stupid encoding problem to stdout

2011-06-13 Thread Sérgio Monteiro Basto
Ian Kelly wrote: If you want your output to behave that way, then all you have to do is specify that with an explicit encode step. ok If we want we change default for whatever we want, but without this default change Python should not change his behavior depending on output. yeah I prefer

Re: the stupid encoding problem to stdout

2011-06-13 Thread Chris Angelico
2011/6/14 Sérgio Monteiro Basto sergi...@sapo.pt: And see, I can send ascii and utf-8 to utf-8 output and never have problems, but if I send ascii and utf-8 to ascii files sometimes got encode errors. If something fits inside 7-bit ASCII, it is by definition valid UTF-8. This is not a

Re: the stupid encoding problem to stdout

2011-06-10 Thread Laurent Claessens
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit : hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode(utf-8) print u chmod +x test.py ../test.py moçambique moçambique The following tries to encode before to print. If you pass an already

Re: the stupid encoding problem to stdout

2011-06-10 Thread Sérgio Monteiro Basto
Ben Finney wrote: What should it decode to, then? UTF-8, as in tty But when you explicitly redirect to a file, it's not going to a TTY. It's going to a file whose encoding isn't known unless you specify it. ok after thinking about this, this problem exist because Python want be smart

Re: the stupid encoding problem to stdout

2011-06-10 Thread Ian Kelly
2011/6/10 Sérgio Monteiro Basto sergi...@sapo.pt: ok after thinking about this, this problem exist because Python want be smart with ttys, which is in my point of view is wrong, should not encode to utf-8, because tty is in utf-8. Python should always encode to the same thing. If the default

Re: the stupid encoding problem to stdout

2011-06-10 Thread Chris Angelico
2011/6/11 Sérgio Monteiro Basto sergi...@sapo.pt: ok after thinking about this, this problem exist because Python want be smart with ttys The *anomaly* (not problem) exists because Python has a way of being told a target encoding. If two parties agree on an encoding, they can send characters to

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Benjamin Kaplan wrote: 2011/6/8 Sérgio Monteiro Basto sergi...@sapo.pt: hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode(utf-8) print u chmod +x test.py ./test.py moçambique moçambique ./test.py output.txt Traceback (most recent call

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Ben Finney wrote: Sérgio Monteiro Basto sergi...@sapo.pt writes: ./test.py moçambique moçambique In this case your terminal is reporting its encoding to Python, and it's capable of taking the UTF-8 data that you send to it in both cases. ./test.py output.txt Traceback (most recent

Re: the stupid encoding problem to stdout

2011-06-09 Thread Nobody
On Thu, 09 Jun 2011 22:14:17 +0100, Sérgio Monteiro Basto wrote: Exactly the opposite , if python don't know the encoding should not try decode to ASCII. What should it decode to, then? You can't write characters to a stream, only bytes. I want python don't care about encoding terminal and

Re: the stupid encoding problem to stdout

2011-06-09 Thread Ben Finney
Sérgio Monteiro Basto sergi...@sapo.pt writes: Ben Finney wrote: In this case your shell has no preference for the encoding (since you're redirecting output to a file). How I say to python that I want that write in utf-8 to files ? You already did: In the first print statement you

Re: the stupid encoding problem to stdout

2011-06-09 Thread Terry Reedy
On 6/9/2011 5:46 PM, Nobody wrote: On Thu, 09 Jun 2011 22:14:17 +0100, Sérgio Monteiro Basto wrote: Exactly the opposite , if python don't know the encoding should not try decode to ASCII. What should it decode to, then? You can't write characters to a stream, only bytes. I want python

Re: the stupid encoding problem to stdout

2011-06-09 Thread Mark Tolonen
Sérgio Monteiro Basto sergi...@sapo.pt wrote in message news:4df137a7$0$30580$a729d...@news.telepac.pt... How I change sys.stdout.encoding always to UTF-8 ? at least have a consistent sys.stdout.encoding There is an environment variable that can force Python I/O to be a specfic encoding:

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Nobody wrote: Exactly the opposite , if python don't know the encoding should not try decode to ASCII. What should it decode to, then? UTF-8, as in tty, how I change this default ? You can't write characters to a stream, only bytes. ok got the point . Thanks, --

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Mark Tolonen wrote: Sérgio Monteiro Basto sergi...@sapo.pt wrote in message news:4df137a7$0$30580$a729d...@news.telepac.pt... How I change sys.stdout.encoding always to UTF-8 ? at least have a consistent sys.stdout.encoding There is an environment variable that can force Python I/O to

Re: the stupid encoding problem to stdout

2011-06-09 Thread Ben Finney
Sérgio Monteiro Basto sergi...@sapo.pt writes: Nobody wrote: Exactly the opposite , if python don't know the encoding should not try decode to ASCII. Are you advocating that Python should refuse to write characters unless the encoding is specified? I could sympathise with that, but

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Ben Finney wrote: Exactly the opposite , if python don't know the encoding should not try decode to ASCII. Are you advocating that Python should refuse to write characters unless the encoding is specified? I could sympathise with that, but currently that's not what Python does; instead

Re: the stupid encoding problem to stdout

2011-06-09 Thread Laurent Claessens
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit : hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode(utf-8) print u chmod +x test.py ../test.py moçambique moçambique The following tries to encode before to print. If you pass an already

Re: the stupid encoding problem to stdout

2011-06-09 Thread Laurent Claessens
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit : hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode(utf-8) print u chmod +x test.py ../test.py moçambique moçambique The following tries to encode before to print. If you pass an already

the stupid encoding problem to stdout

2011-06-08 Thread Sérgio Monteiro Basto
hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode(utf-8) print u chmod +x test.py ./test.py moçambique moçambique ./test.py output.txt Traceback (most recent call last): File ./test.py, line 5, in module print u UnicodeEncodeError: 'ascii'

Re: the stupid encoding problem to stdout

2011-06-08 Thread Ben Finney
Sérgio Monteiro Basto sergi...@sapo.pt writes: ./test.py moçambique moçambique In this case your terminal is reporting its encoding to Python, and it's capable of taking the UTF-8 data that you send to it in both cases. ./test.py output.txt Traceback (most recent call last): File

Re: the stupid encoding problem to stdout

2011-06-08 Thread Benjamin Kaplan
2011/6/8 Sérgio Monteiro Basto sergi...@sapo.pt: hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode(utf-8) print u chmod +x test.py ./test.py moçambique moçambique ./test.py output.txt Traceback (most recent call last):  File ./test.py,

Re: Encoding problem when launching Python27 via DOS

2011-04-11 Thread Jean-Pierre M
Thanks a lot for this quick answer! It is very clear! Ti better understand what the difference between encoding and decoding is I found the following website: http://www.evanjones.ca/python-utf8.html http://www.evanjones.ca/python-utf8.htmlI change the program to (changes are in bold): *# -*-

Encoding problem when launching Python27 via DOS

2011-04-10 Thread Jean-Pierre M
I created a simple program which writes in a unicode files some french text with accents! *# -*- coding: cp1252 -*-* *#!/usr/bin/python* *'''* *Created on 27 déc. 2010* * * *@author: jpmena* *'''* *from datetime import datetime* *import locale* *import codecs* *import os,sys* * * *class

Re: Encoding problem when launching Python27 via DOS

2011-04-10 Thread MRAB
On 10/04/2011 13:22, Jean-Pierre M wrote: I created a simple program which writes in a unicode files some french text with accents! [snip] This line: l.p(premier message de Log à accents) passes a bytestring to the method, and inside the method, this line: unicode_str=u'%s : %s \n'

Re: nntplib encoding problem

2011-02-28 Thread Laurent Duchesne
Hi, Thanks it's working! But is it normal for a string coming out of a module (nntplib) to crash when passed to print or write? I'm just asking to know if I should open a bug report or not :) I'm also wondering which strings should be re-encoded using the surrogateescape parameter and which

nntplib encoding problem

2011-02-27 Thread Laurent Duchesne
Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group(alt.binaries.cd.lossless) nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer - Anamorphosee (Japan Edition) 1995 [02/41] Back.jpg yEnc (1/3)' ... overview =

Re: nntplib encoding problem

2011-02-27 Thread MRAB
On 28/02/2011 01:31, Laurent Duchesne wrote: Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group(alt.binaries.cd.lossless) nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer - Anamorphosee (Japan Edition) 1995 [02/41]

Re: nntplib encoding problem

2011-02-27 Thread Thomas L. Shinnick
At 08:12 PM 2/27/2011, you wrote: On 28/02/2011 01:31, Laurent Duchesne wrote: Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group(alt.binaries.cd.lossless) nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer -

Encoding problem - or bug in couchdb-0.8-py2.7.egg??

2010-09-20 Thread Ian Hobson
Hi all, I have hit a problem and I don't know enough about python to diagnose things further. Trying to use couchDB from Python. This script:- # coding=utf8 import couchdb from couchdb.client import Server server = Server() dbName = 'python-tests' try: db = server.create(dbName) except

Re: Encoding problem - or bug in couchdb-0.8-py2.7.egg??

2010-09-20 Thread Diez B. Roggisch
Ian Hobson i...@ianhobson.co.uk writes: Hi all, I have hit a problem and I don't know enough about python to diagnose things further. Trying to use couchDB from Python. This script:- # coding=utf8 import couchdb from couchdb.client import Server server = Server() dbName = 'python-tests'

Re: Encoding problem - or bug in couchdb-0.8-py2.7.egg??

2010-09-20 Thread Ian
Thanks Diez, Removing, rebooting and installing the latest version solved the problem. :) Your google-foo is better than mine. Google had not turned that up for me. Thanks again Regards Ian On 20/09/2010 17:00, Diez B. Roggisch wrote: Ian Hobsoni...@ianhobson.co.uk writes: Hi

encoding problem

2009-06-27 Thread netpork
Hello, I have ssl socket with server and client, on my development machine everything works pretty well. Database which I have to use is mssql on ms server 2003, so I decided to install the same python config there and run my python server script. Now here is the problem, server is returning

Re: encoding problem

2009-06-27 Thread Piet van Oostrum
netpork todorovic.de...@gmail.com (n) wrote: n Hello, n I have ssl socket with server and client, on my development machine n everything works pretty well. n Database which I have to use is mssql on ms server 2003, so I decided n to install the same python config there and run my python server n

Re: encoding problem

2009-06-27 Thread dejan todorović
It was problem with pymssql that not supports unicode, switched to pyodbc, everything is fine. Thanks for your swift reply. ;) On Jun 27, 7:44 pm, Piet van Oostrum p...@cs.uu.nl wrote: netpork todorovic.de...@gmail.com (n) wrote: n Hello, n I have ssl socket with server and client, on my

Re: SyntaxError: encoding problem: with BOM

2008-12-26 Thread Gabriel Genellina
En Thu, 25 Dec 2008 11:55:16 -0200, NoName zaz...@gmail.com escribió: Error C:\Documents and Settings\Ra\Рабочий стол11.py File decoding error, line 1 SyntaxError: encoding problem: with BOM No error C:\Documents and Settings\Ra\Рабочий столpython 11.py test Error when russian

  1   2   >