This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: optparse tests fail under Jython
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gward Nosy List: ajaksu2, akuchling, chrish42, drtimcouper, eric.araujo, gward, nilovna, pjenvey, python-dev, r.david.murray, sandro.tosi
Priority: normal Keywords: easy, patch

Created on 2007-04-20 16:50 by drtimcouper, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_optparse.patch drtimcouper, 2007-04-20 16:50 test_optparse.py mod. for jython review
jython.diff chrish42, 2014-04-15 14:50 Add test_support.impl_detail() guard on test that relies on sys.getrefcount().
Messages (18)
msg52484 - (view) Author: Tim Couper (drtimcouper) Date: 2007-04-20 16:50
Extension of test code for jython
msg59774 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2008-01-12 01:47
The patch would need to be checked against Jython's last release and/or
the current trunk.
msg87791 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-05-15 02:12
Can someone ping the Jython tracker for help on this?
msg88695 - (view) Author: Greg Ward (gward) (Python committer) Date: 2009-06-02 00:17
I just took a look at the original patch uploaded by drtimcouper.  IMHO
it would be cleaner and simpler to modify optparse.py so that it behaves
as consistently as possible under Jython and CPython.  For example,
optparse should catch the ValueError raised when a user supplies a bad
integer input and raise a new exception with a consistent error message.
 That sort of thing.

drtimcouper: if you're still out there and reading this, would you mind
submitting a new patch?
msg88698 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-06-02 00:45
This looks like it was against Jython 2.2? Jython 2.5 passes 2.5's 
test_optparse with only fixing __builtins__ and disabling the weakref test

So uses of __builtins__ should should be importing __builtin__ and use 
that instead. sys.platform.startswith('java') should be 
test_support.is_jython instead. And on 2.6/3.2 you can now decorate 
test_refleak with @test_support.impl_check('Relies on sys.getrefcount', 
cpython=True) to skip it
msg116664 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-17 13:49
How do we find out which versions of optparse and test_optparse jython is currently using?
msg128325 - (view) Author: Sandro Tosi (sandro.tosi) * (Python committer) Date: 2011-02-10 18:20
Hi, since optparse is now deprecated (in favor of argparse) and in a year and half there was not progress on this, I'm closing this report.
msg128410 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-11 17:44
Hi Sandro.  I think you may have closed too fast here: optparse is deprecated in docs only, it’s not the recommendation anymore, but IIUC bugs should still be fixed.  A year and a half is sadly not a very long time for a Python bug, time is usually not a criterion for closing.

David, please correct any inaccuracy in my message :)
msg128415 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-02-11 18:28
Making the tests pass on Jython is certainly worthwhile, if anyone wants to do it.  At a quick glance it looks like the optparse tests just need to be updated and made a bit more lenient.  Since Jython is lagging CPython by so much a fix isn't going to help them for a quite a while even if it gets done now.

Really, this is a candidate bug to be moved to the library tracker if/when the CPython/library split happens.  So I suppose we should leave it open in anticipation of that move happening some day :)
msg216182 - (view) Author: Christian Hudon (chrish42) * Date: 2014-04-14 19:13
Which version of Jython should I concentrate on to make these tests pass? The 2.5.4 release candidate, or the 2.7 beta?
msg216202 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-04-14 20:26
I'm guessing they've got a local fix in the release candidate and won't change even their test code there, so I'd guess the beta.  But the jython folks would really be the ones to ask.  Perhaps they will respond here (they are not at pycon).
msg216220 - (view) Author: Christian Hudon (chrish42) * Date: 2014-04-14 21:11
I'll use Jython 2.7. The Jython people can backport the fix to 2.5.4, if they want it there too.

So... this is marked as related to Python 3.2, but Jython is on Python 2 of course. I'll just take the version as being wrong. So, what should the patch that fixes this be based on? Not Python 3, obviously. But CPython 2.7's latest? Or the Jython 2.7 repository? And where should the fix be committed? In CPython's repository, or in Jython?
msg216259 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-04-15 01:08
Well, we want it to apply to python3 as well, since we want to see jython support python3 eventually :)

Also, optparse is present in python3 for backward compatibility reasons only...there were very few changes between the time python3 branched from python2 and argparse superceeded optparse.  So the differences between the two code bases should be minimal.  Obviously you can't test against jython3, since it doesn't exist, but what you can do is make the patch based on the python2 optparse, and then see if the patch applies cleanly to python3.  It probably won't, but as far as I can see from a quick diff, most of the changes will be related to the changes between python2 syntax and python3 syntax, and will be easy to forward port even without being able to test it directly against jython.
msg216300 - (view) Author: Christian Hudon (chrish42) * Date: 2014-04-15 14:50
Actually, the only optparse test failing on jython 2.7 beta 1 currently is the one that relies on sys.getrefcount. Adding a test_support.impl_detail() guard makes all the tests pass. (See attached patch.)

I'd propose adding this patch to both the python3 and python2 tips, as it would make the life of other, non-cpython implementations easier, and then closing this bug.
msg216310 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2014-04-15 15:36
Patch to add impl_detail() looks fine to me.
msg216383 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-15 20:44
New changeset a1ef419c0cfb by Andrew Kuchling in branch '2.7':
#1704474: mark refleak test as specific to CPython
http://hg.python.org/cpython/rev/a1ef419c0cfb
msg216414 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-16 01:16
New changeset c76d782cb9df by Andrew Kuchling in branch '3.4':
#1704474: mark refleak test as specific to CPython
http://hg.python.org/cpython/rev/c76d782cb9df
msg216417 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2014-04-16 01:33
Committed to 2.7, 3.4, and default.  Thanks for your patch!
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44875
2014-04-16 01:33:34akuchlingsetstatus: open -> closed
resolution: fixed
messages: + msg216417
2014-04-16 01:16:57python-devsetmessages: + msg216414
2014-04-15 20:44:51python-devsetnosy: + python-dev
messages: + msg216383
2014-04-15 15:36:17akuchlingsetmessages: + msg216310
versions: + Python 2.7, Python 3.5, - Python 3.2
2014-04-15 14:50:58chrish42setfiles: + jython.diff

messages: + msg216300
2014-04-15 01:08:48r.david.murraysetmessages: + msg216259
2014-04-14 21:11:05chrish42setmessages: + msg216220
2014-04-14 20:26:32r.david.murraysetmessages: + msg216202
2014-04-14 19:13:45chrish42setnosy: + chrish42
messages: + msg216182
2014-03-14 19:17:43nilovnasetnosy: + nilovna
2011-02-11 18:28:59r.david.murraysetstatus: closed -> open
type: enhancement -> behavior
messages: + msg128415

nosy: akuchling, gward, ajaksu2, drtimcouper, pjenvey, eric.araujo, r.david.murray, sandro.tosi
resolution: wont fix -> (no value)
2011-02-11 17:44:03eric.araujosetnosy: + eric.araujo, r.david.murray, - BreamoreBoy
messages: + msg128410
2011-02-10 18:20:20sandro.tosisetstatus: open -> closed

nosy: + sandro.tosi
messages: + msg128325

resolution: wont fix
stage: resolved
2010-09-17 13:49:32BreamoreBoysetnosy: + BreamoreBoy

messages: + msg116664
versions: - Python 2.7
2009-06-02 00:45:57pjenveysetnosy: + pjenvey
messages: + msg88698
2009-06-02 00:18:01gwardsetnosy: akuchling, gward, ajaksu2, drtimcouper
components: + Library (Lib), - Tests
title: test_optparse.py mod. for jython -> optparse tests fail under Jython
2009-06-02 00:17:18gwardsetmessages: + msg88695
2009-05-15 02:12:26ajaksu2setversions: + Python 2.7, Python 3.2, - Python 2.6
nosy: + ajaksu2

messages: + msg87791

type: enhancement
2008-01-12 01:47:54akuchlingsetkeywords: + easy
nosy: + akuchling
messages: + msg59774
2007-04-20 16:50:54drtimcoupercreate