I upgraded my Python to 2.7.11 and the problem solved!

This might be a bug!


On Tuesday, June 21, 2016 at 11:14:56 AM UTC+4:30, Kiran Subbaraman wrote:
>
> That's the expected output. And also the code that you executed is the 
> crux of the rss(feed) encoding code. 
> So, am not sure why you are still seeing the Error, when you use 
> serializers.rss()
>
> I do not have a python 2.7.5 environment to try this out. In the meantime, 
> was taking a look at the release notes of 2.7.6 to see if this issue 
> existed in 2.7.5: 
> https://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS . A cursory 
> browse didn't help me spot anything applicable. You may also want to take a 
> look.
>
> Other than that, am out of ideas. 
>
> ________________________________________
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Tue, 21-06-2016 11:47 AM, Sepehr Mohamadi wrote:
>
> I get this on Python 2.7 Console:
>
> 'Some unicode here \xd8\xa2\xd8\xb2\xd9\x85\xd8\xa7\xdb\x8c\xd8\xb4 
>> \xd8\xb2\xd8\xa8\xd8\xa7\xd9\x86 \xd9\x81\xd8\xa7\xd8\xb1\xd8\xb3\xdb\x8c'
>
>
> And you remember the error:
>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position 18: 
> ordinal 
>> not in range(128)
>
>
>
>
>
> On Tuesday, June 21, 2016 at 10:40:23 AM UTC+4:30, Kiran Subbaraman wrote: 
>>
>> Weird ... am not aware of 2.7.5 unicode issues.
>> In any case, if you try just this on your console (ipython / python), 
>> what do you see?
>>
>> u'Some unicode here آزمایش زبان فارسی'.encode('utf-8', 'replace')
>>
>> ________________________________________ 
>>
>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>
>> On Tue, 21-06-2016 10:46 AM, Sepehr Mohamadi wrote: 
>>
>> Thanks, 
>> I compared your code and mine! I have first line as it is default in 
>> web2py: 
>>
>> # -*- coding: utf-8 -*-
>>
>> the only difference I understand is that my Python version is 2.7.5 and 
>> yours is 2.7.10
>> Is that can be a clue?
>> On Tuesday, June 21, 2016 at 8:52:27 AM UTC+4:30, Kiran Subbaraman wrote: 
>>>
>>> This is the code I tried, from within my IDE, and also from within 
>>> ipython. My environment: Version 
>>> 2.14.5-stable+timestamp.2016.04.13.22.22.13,  Python 2.7.10 (default, May 
>>> 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] Notice the encoding at the 
>>> top of the file - this defines the source code's encoding (
>>> https://www.python.org/dev/peps/pep-0263/) 
>>>
>>> # -*- coding: utf-8 -*-
>>>
>>> import gluon.serializers as se
>>>
>>> feed = {'description': 'my first feed',
>>>         'entries': [{'description': u'Some unicode here آزمایش زبان فارسی',
>>>                      'link': 'http://feed.example.com',
>>>                      'title': 'my feed'}],
>>>         'link': 'http://feed.example.com',
>>>         'title': 'my feed'}
>>>
>>> print(se.rss(feed))
>>>
>>> *I see this output*: <?xml version="1.0" encoding="utf8"?> <rss 
>>> version="2.0"><channel><title>my feed</title><link>
>>> http://feed.example.com</link><description>my first 
>>> feed</description><lastBuildDate>Tue, 21 Jun 2016 09:44:28 
>>> GMT</lastBuildDate><generator>PyRSS2Gen-1.1.0</generator><docs>
>>> http://blogs.law.harvard.edu/tech/rss</docs><item><title>my 
>>> feed</title><link>http://feed.example.com</link><description>Some 
>>> unicode here آزمایش زبان فارسی</description><pubDate>Tue, 21 Jun 2016 
>>> 09:44:28 GMT</pubDate></item></channel></rss> 
>>>
>>> ________________________________________
>>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>>
>>> On Tue, 21-06-2016 1:20 AM, Sepehr Mohamadi wrote: 
>>>
>>> description = u"Some unicode here آزمایش زبان فارسی"
>>>
>>> -- Resources: - http://web2py.com - http://web2py.com/book 
>> (Documentation) - http://github.com/web2py/web2py (Source code) - 
>> https://code.google.com/p/web2py/issues/list (Report Issues) --- You 
>> received this message because you are subscribed to the Google Groups 
>> "web2py-users" group. To unsubscribe from this group and stop receiving 
>> emails from it, send an email to [email protected]. For more 
>> options, visit https://groups.google.com/d/optout. 
>>
>> -- Resources: - http://web2py.com - http://web2py.com/book 
> (Documentation) - http://github.com/web2py/web2py (Source code) - 
> https://code.google.com/p/web2py/issues/list (Report Issues) --- You 
> received this message because you are subscribed to the Google Groups 
> "web2py-users" group. To unsubscribe from this group and stop receiving 
> emails from it, send an email to [email protected] 
> <javascript:>. For more options, visit https://groups.google.com/d/optout. 
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to