Issue1718

classification
Title: PEP 3101 implementation
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: amak, fwierzbicki, nriley, pjenvey, yole
Priority: normal Keywords: patch

Created on 2011-03-15.18:26:33 by yole, last changed 2012-08-10.21:01:18 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
pep3101.patch yole, 2011-03-15.18:26:32
Messages
msg6437 (view) Author: Dmitry Jemerov (yole) Date: 2011-03-15.18:26:32
Attached is a somewhat complete implementation of PEP 3101 (string.format) for Jython 2.6 which passes a certain number of the tests in the standard library testsuite. :)

Stuff that's still missing:
 - implement __format__ for floats
 - implement 'n' formatting type for integers
 - implement __format__ for datetime
 - limit recursion level for recursive format specs
 - implement remaining checks for error conditions
 - check str/unicode difference
 - handle classes inherited from int/long/string/float overriding __format__
 - anything else I haven't figured out yet :)
msg6438 (view) Author: Philip Jenvey (pjenvey) Date: 2011-03-15.20:31:12
I'll also note that we're not quite sure how to handle 'n' yet as its locale dependent
msg6445 (view) Author: Philip Jenvey (pjenvey) Date: 2011-03-21.05:59:17
I've applied this in r7257, thanks again!

FYI I'll probably be applying just a few small coding standard changes to it over the next few days. I'll keep this open for the ongoing missing features
msg6448 (view) Author: Philip Jenvey (pjenvey) Date: 2011-03-22.02:43:03
I applied some minor changes, mostly coding standards in r7261

The only other suggestion I might make is to maybe have the internal stringlib classes throw Py.ValueErrors instead of InvalidArgumentExceptions which propagate up as ValueErrors anyway

To limit recursion you probably just need to surround those potential recursive calls in:

threadState.enterRecursiveCall(" in foo");
try {
    recursiveCall.__call__()
} finally {
    threadState.leaveRecursiveCall();
}

To handle subclasses overriding __format__ we probably just need an entry for __format__ added to src/templates/object.derived and to regenerate our derived subclasses with gderved.py in the same directory
msg6704 (view) Author: Alan Kennedy (amak) Date: 2011-11-05.18:16:32
Since the patch has already been committed, does this issue need to be kept open? Or can it be closed?
msg6707 (view) Author: Philip Jenvey (pjenvey) Date: 2011-11-05.21:41:50
Might as well leave it open to track the missing features of the PEP
msg6708 (view) Author: Philip Jenvey (pjenvey) Date: 2011-11-05.21:42:13
oops I didn't want to close it..
msg6776 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-02-10.18:54:44
I updated some fields in hopes that this one will stop showing up in the "waiting for review" section of the tracker email.
msg6952 (view) Author: Nicholas Riley (nriley) Date: 2012-03-21.20:40:28
I've implemented a few more of the items, as well as some 2.6 -> 2.7 changes (bug fixes, thousands separators and {}).

 - implement 'n' formatting type for integers
 - implement remaining checks for error conditions
 - limit recursion level for recursive format specs

Nearly all of the tests from 2.7 pass.  Notably still remaining from the original list:

 - implement __format__ for floats
 - implement __format__ for datetime
msg7378 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-08-10.21:01:18
I think this one can be closed now, thanks Dmitry!
History
Date User Action Args
2012-08-10 21:01:18fwierzbickisetstatus: open -> closed
messages: + msg7378
2012-03-21 20:40:29nrileysetnosy: + nriley
messages: + msg6952
2012-02-10 18:54:45fwierzbickisetpriority: normal
assignee: pjenvey
resolution: accepted
messages: + msg6776
nosy: + fwierzbicki
2011-11-05 21:42:13pjenveysetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg6708
2011-11-05 21:41:50pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg6707
2011-11-05 18:16:32amaksetnosy: + amak
messages: + msg6704
2011-03-22 02:43:03pjenveysetmessages: + msg6448
2011-03-21 05:59:17pjenveysetmessages: + msg6445
2011-03-15 20:31:13pjenveysetnosy: + pjenvey
messages: + msg6438
2011-03-15 18:26:33yolecreate