[issue34311] locale.format() and locale.format_string() cast Decimals to float

2018-08-04 Thread James Emerton


James Emerton  added the comment:

It looks like a bot got a bit excited when I mentioned this issue in the PR for 
bpo-33731. I unlinked the PR but this issue still got flagged for review.

--

___
Python tracker 
<https://bugs.python.org/issue34311>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34311] locale.format() and locale.format_string() cast Decimals to float

2018-08-04 Thread James Emerton


Change by James Emerton :


--
pull_requests:  -8166

___
Python tracker 
<https://bugs.python.org/issue34311>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34311] locale.format() and locale.format_string() cast Decimals to float

2018-08-04 Thread James Emerton


Change by James Emerton :


--
keywords: +patch
pull_requests: +8166
stage:  -> patch review

___
Python tracker 
<https://bugs.python.org/issue34311>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread James Emerton


James Emerton  added the comment:

@rhettinger See #34311 about formatting Decimals using locale.format(). I'd 
like to see the problem fixed in one place or the other.

Also, this is seems relatively straightforward to implement as it's really just 
a combination of the fixed precision 'f' and the locale specific 'n' format 
types.

--

___
Python tracker 
<https://bugs.python.org/issue33731>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread James Emerton


James Emerton  added the comment:

So far, I've implemented this for Decimal

--

___
Python tracker 
<https://bugs.python.org/issue33731>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread James Emerton


Change by James Emerton :


--
nosy: +jemerton

___
Python tracker 
<https://bugs.python.org/issue33731>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34311] locale.format() and locale.format_string() cast Decimals to float

2018-08-01 Thread James Emerton


James Emerton  added the comment:

Certainly adding another letter to the format spec would solve my issue and 
would in fact be somewhat preferable to using local.format directly.

I think this could be fixed in the locale module by transforming the format 
spec and using new-style formatting, but I'm not familiar enough with the 
corner cases to know if its practical to cover all the possible cases; 
particularly those coming from format_string().

--

___
Python tracker 
<https://bugs.python.org/issue34311>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34311] locale.format() and locale.format_string() cast Decimals to float

2018-08-01 Thread James Emerton


New submission from James Emerton :

We use locale.format('%.2f', x, True) to convert Decimal values to strings for 
display. Unfortunately, the locale module is using %-formatting to generate the 
initial string before applying locale specific formatting. As a result, any 
value which cannot be accurately represented as a float will produce incorrect 
results.

I've built some formatting that uses new-style string formatting (and some 
internal locale functions) which corrects the problem.

Unfortunately, making this change in the locale module would require converting 
the input format string to the new syntax, so '%.2f' would become '{:.2f}'.

See also #33731

--
components: Library (Lib)
messages: 322885
nosy: jemerton
priority: normal
severity: normal
status: open
title: locale.format() and locale.format_string() cast Decimals to float
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue34311>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1677872] Efficient reverse line iterator

2014-04-15 Thread James Emerton

James Emerton added the comment:

Attached is an implementation of BufferedReader.readprevline(), as suggested by 
Antoine.

At this point, it seems to be working but I would like to improve the tests 
when a single result spans multiple chunks. I would particularly like to ensure 
correct behaviour when a newline ends up as the last byte of a new chunk.

--
nosy: +jemerton
Added file: http://bugs.python.org/file34894/readprevline-20140415.diff

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