Issue1783844

classification
Title: Patch: String has not __cmp__ attribute
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, david-perez
Priority: normal Keywords: patch

Created on 2007-08-29.08:23:48 by david-perez, last changed 2007-08-30.06:40:21 by david-perez.

Files
File name Uploaded Description Edit Remove
PyString.java.patch david-perez, 2007-08-29.08:23:48
test_string.py.patch david-perez, 2007-08-29.11:00:32
test_string.py.patch david-perez, 2007-08-30.06:40:21
Messages
msg2854 (view) Author: David Pérez (david-perez) Date: 2007-08-29.08:23:48
This patch solves this issue:

If I run this code from the Jython 2.2 interactive console :
  'a'.__cmp__('b')
this is what happens:
  AttributeError: 'string' object has no attribute '__cmp__'

This used to work in Jython 2.1. 

I have tested in my own code.
msg2855 (view) Author: David Pérez (david-perez) Date: 2007-08-29.11:00:32
Updated test!
File Added: test_string.py.patch
msg2856 (view) Author: David Pérez (david-perez) Date: 2007-08-30.06:40:21
Updated test!
File Added: test_string.py.patch
msg2857 (view) Author: Charlie Groves (cgroves) Date: 2007-08-30.07:17:08
This actually isn't a bug.  Python added rich comparison methods(__eq__, __gt__, __le__ and so on) in 2.1, and Jython's str uses those in 2.2 instead of __cmp__.  CPython exhibits the same behavior.  You can get equivalent functionality to __cmp__ with the builtin cmp function: cmp('a', 'b')
History
Date User Action Args
2007-08-29 08:23:48david-perezcreate