[issue13600] rot_13 codec not working

2011-12-14 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Issue #7475 discusses fixing the error messages, too.

--
components: +Library (Lib)
resolution:  -> duplicate
stage: committed/rejected -> 
status: open -> closed
superseder:  -> codecs missing: base64 bz2 hex zlib hex_codec ...

___
Python tracker 

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



[issue13600] rot_13 codec not working

2011-12-14 Thread Ram Rachum

Ram Rachum  added the comment:

Then I suggest replacing this error message:

encoder did not return a bytes object (type=str)

and this one:

'memoryview' object has no attribute 'translate'

With something like:

Please use `codecs.lookup('rot-13').encode`

--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python
resolution: invalid -> 
status: closed -> open

___
Python tracker 

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



[issue13600] rot_13 codec not working

2011-12-14 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Ram Rachum wrote:
> The `rot_13` codec is supposed to work like this, no?

No it isn't. In Python 3, str.encode() always encodes to bytes and 
bytes.decode() always decodes to str. IOW, str.encode() encodes text (Unicode) 
to data (bytes), and bytes.decode() decodes data to text. ROT-13 is not a 
character encoding, so it cannot be used in this manner.

It's still available in the codecs module, though:

>>> import codecs
>>> codecs.lookup('rot-13').encode('qwerty')
('djregl', 6)

Other text->text and bytes->bytes codecs are also available there.

--
nosy: +petri.lehtinen
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue13600] rot_13 codec not working

2011-12-14 Thread Ezio Melotti

Ezio Melotti  added the comment:

See #7475.

--
nosy: +ezio.melotti

___
Python tracker 

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



[issue13600] rot_13 codec not working

2011-12-14 Thread Ram Rachum

New submission from Ram Rachum :

The `rot_13` codec is supposed to work like this, no?

>>> 'qwerty'.encode('utf-8')
b'qwerty'
>>> 'qwerty'.encode('rot_13')
Traceback (most recent call last):
  File "", line 1, in 
'qwerty'.encode('rot_13')
TypeError: encoder did not return a bytes object (type=str)

>>> b'qwerty'.decode('utf-8')
'qwerty'
>>> b'qwerty'.decode('rot_13')
Traceback (most recent call last):
  File "", line 1, in 
b'qwerty'.decode('rot_13')
  File "C:\Python32\lib\encodings\rot_13.py", line 19, in decode
return (input.translate(rot13_map), len(input))
AttributeError: 'memoryview' object has no attribute 'translate'

--
components: Library (Lib)
messages: 149431
nosy: cool-RR
priority: normal
severity: normal
status: open
title: rot_13 codec not working
versions: Python 3.3

___
Python tracker 

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