[issue43332] Make http.client._tunnel send one byte string over the network

2021-03-07 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +23549
pull_request: https://github.com/python/cpython/pull/24783

___
Python tracker 

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



[issue43332] Make http.client._tunnel send one byte string over the network

2021-03-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:


New changeset c25910a135c2245accadb324b40dd6453015e056 by Gregory P. Smith in 
branch 'master':
bpo-43332: Buffer proxy connection setup packets before sending. (GH-24780)
https://github.com/python/cpython/commit/c25910a135c2245accadb324b40dd6453015e056


--

___
Python tracker 

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



[issue43431] Subprocess timeout causes output to be returned as bytes in text mode

2021-03-07 Thread Jordan Macdonald


New submission from Jordan Macdonald :

Passing the argument `text=True` to `subprocess.run()` is supposed to mean that 
any captured output of the called process is automatically decoded and retuned 
to the user as test instead of bytes.

However, if you give a timeout and that timeout expires, the raised 
`subprocess.TimeoutExpired` exception will have the captured output as as bytes 
even if text mode is enabled.

Test output:
bash-5.0$ python3 test_subprocess.py
Version and interpreter information: namespace(_multiarch='x86_64-linux-gnu', 
cache_tag='cpython-37', hexversion=50792432, name='cpython', 
version=sys.version_info(major=3, minor=7, micro=7, releaselevel='final', 
serial=0))
Completed STDOUT Type: 
Completed STDOUT Content: 'Start\nDone\n'
Timeout STDOUT Type: 
Timeout STDOUT Content: b'Start\n'

--
components: Library (Lib)
files: test_subprocess.py
messages: 388257
nosy: macdjord
priority: normal
severity: normal
status: open
title: Subprocess timeout causes output to be returned as bytes in text mode
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file49856/test_subprocess.py

___
Python tracker 

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



[issue31466] No easy way to change float formatting when subclassing encoder.JSONEncoder

2021-03-07 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue43420] Optimize rational arithmetics

2021-03-07 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

On Sun, Mar 07, 2021 at 10:34:24PM +, Aaron Meurer wrote:
> I'm surprised to hear that the "typical use-case" of Fraction
> is fractions converted from floats.

For statistics module - that may be true.  Unfortunately, no
(other) practical applications, using Fraction's, were proposed by
my reviewers so far.

> By the way, the "algorithm" here really isn't that
> complicated. I didn't even realize it had a name.

Rather "algorithms"; everything is there in the II-nd volume of
the Knuth, section 4.5 - Rational Arithmetic.  Probably, this
is even a better reference, since it explains gcd==1 case
for addition.  Both, however, reference the Henrici article.

> It's far less complicated than, for example, Lehmer's gcd
> algorithm (which is implemented in math.gcd).

Or Karatsuba multiplication.

BTW, low-denominators performance may be restored (at least
partially), using same approach (like KARATSUBA_CUTOFF - but
checking the maximal denominator).  I don't like this idea, but...

--

___
Python tracker 

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



[issue43332] Make http.client._tunnel send one byte string over the network

2021-03-07 Thread Senthil Kumaran


Change by Senthil Kumaran :


--
versions: +Python 3.8, Python 3.9

___
Python tracker 

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



[issue43430] Exception raised when attempting to create Enum via functional API

2021-03-07 Thread Ethan Furman


Change by Ethan Furman :


--
assignee:  -> ethan.furman

___
Python tracker 

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



[issue43430] Exception raised when attempting to create Enum via functional API

2021-03-07 Thread Suhail S.


Change by Suhail S. :


--
nosy: +barry, eli.bendersky, ethan.furman

___
Python tracker 

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



[issue43430] Exception raised when attempting to create Enum via functional API

2021-03-07 Thread Suhail S.


New submission from Suhail S. :

It is possible to create custom Enum classes with a metaclass that is a subtype 
of EnumMeta. It is also possible to inherit from such an enumeration to create 
another enumeration. However, attempting to do so via the functional API raises 
an exception. See attached file that highlights minimal failing test case.

--
components: Library (Lib)
files: test.py
messages: 388255
nosy: suhailsingh247
priority: normal
severity: normal
status: open
title: Exception raised when attempting to create Enum via functional API
type: crash
versions: Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file49855/test.py

___
Python tracker 

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



[issue43428] Sync importlib_metadata enhancements through 3.7.

2021-03-07 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
keywords: +patch
pull_requests: +23548
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24782

___
Python tracker 

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



[issue43379] Pasting multiple lines in the REPL is broken since 3.9

2021-03-07 Thread Ned Deily


Ned Deily  added the comment:

It certainly could be an issue with using GNU readline vs libedit and Terry is 
correct that you should follow up with Homebrew. But I don't think you stated 
from which code editor application you were copying from; that could also make 
a difference. In any case, good luck!

--

___
Python tracker 

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



[issue42600] Cancelling tasks waiting for asyncio.Conditions crashes w/ RuntimeError: Lock is not acquired.

2021-03-07 Thread Daniele Varrazzo


Daniele Varrazzo  added the comment:

I have stumbled in this bug, or something similar, implementing psycopg3 async 
connection pool. A function such as the following fails but only in Python 3.6 
(tested 3.6.12):

async def wait(self, timeout: float) -> AsyncConnection:
"""Wait for a connection to be set and return it.
Raise an exception if the wait times out or if fail() is called.
"""
async with self._cond:
if not (self.conn or self.error):
try:
await asyncio.wait_for(self._cond.wait(), timeout)
except asyncio.TimeoutError:
# HERE
self.error = PoolTimeout(
f"couldn't get a connection after {timeout} sec"
)

In python 3.6, printing self._cond.locked() in the HERE position gives False, 
even if it's inside the with block. Everything grinds to a halt afterwards.

However I don't have the same problem in other Python versions (3.7.10, 3.8.5 
among the ones tested) so I'm not sure it is the same issue.

Is this a manifestation of the same bug or a different one? Is there any 
workaround or should I make the async pool just not supported on Python 3.6?

--
nosy: +piro

___
Python tracker 

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



[issue43429] mmap.size() raises OSError on Unix for anonymous memory

2021-03-07 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
pull_requests: +23547
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24781

___
Python tracker 

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



[issue43429] mmap.size() raises OSError on Unix for anonymous memory

2021-03-07 Thread Zackery Spytz


New submission from Zackery Spytz :

For anonymous memory, mmap.size() works without issue on Windows, but it raises 
OSError on Unix.

--
components: Extension Modules
messages: 388252
nosy: ZackerySpytz
priority: normal
severity: normal
status: open
title: mmap.size() raises OSError on Unix for anonymous memory
type: behavior
versions: Python 3.10

___
Python tracker 

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



[issue43379] Pasting multiple lines in the REPL is broken since 3.9

2021-03-07 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Thank you for retesting with the python.org installer.  Since this is Homebrew 
specific, please open an issue with them, with the updated debug information.

--
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue43428] Sync importlib_metadata enhancements through 3.7.

2021-03-07 Thread Jason R. Coombs


New submission from Jason R. Coombs :

importlib metadata has added a few important 
[changes](https://importlib-metadata.readthedocs.io/en/latest/history.html#v3-7-0)
 since the last sync in issue42382 (importlib_metadata 3.3):

- Performance enhancements to distribution discovery.
- `entry_points` only returns unique distributions.
- Introduces new ``EntryPoints`` object for containing a set of entry points 
with convenience methods for selecting entry points by group or name.
- Added packages_distributions function to return a mapping of packages to the 
distributions that provide them.

--
assignee: jaraco
components: Library (Lib)
messages: 388250
nosy: jaraco
priority: normal
severity: normal
status: open
title: Sync importlib_metadata enhancements through 3.7.
versions: Python 3.10

___
Python tracker 

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



[issue42382] No easy way to get the distribution which provided a importlib.metadata.EntryPoint

2021-03-07 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
versions: +Python 3.10

___
Python tracker 

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



[issue42382] No easy way to get the distribution which provided a importlib.metadata.EntryPoint

2021-03-07 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue43406] Possible race condition between signal catching and signal.signal

2021-03-07 Thread Antoine Pitrou


Change by Antoine Pitrou :


--
pull_requests: +23546
pull_request: https://github.com/python/cpython/pull/24755

___
Python tracker 

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



[issue43420] Optimize rational arithmetics

2021-03-07 Thread Aaron Meurer


Aaron Meurer  added the comment:

I'm surprised to hear that the "typical use-case" of Fraction is fractions 
converted from floats. Do you have evidence in the wild to support that? 

I would expect any application that uses fractions "generically" to run into 
the same sorts of problems SymPy does. The issue is that the sum or product of 
two unrelated fractions has a denominator that is ~ the product of the 
denominators of each term. So they tend to grow large, unless there is some 
structure in the terms that results in lots of cancellation. That's why real 
world numeric typically doesn't use exact arithmetic, but there are legitimate 
use-cases for it (computer algebra being one).

This actually also applies even if the denominators are powers of 2. That's why 
arbitrary precision floating point numbers like Decimal or mpmath.mpf limit the 
precision, or effectively, the power of 2 in the denominator. 

By the way, the "algorithm" here really isn't that complicated. I didn't even 
realize it had a name. The idea is that for a/b * c/d, if a/b and c/d are 
already in lowest terms, then the only cancellation that can happen is from a/d 
or from c/b. So instead of computing gcd(a*c, b*d), we only compute gcd(a, d) 
and gcd(c, b) and cancel them off the corresponding terms. It turns out to be 
faster to take two gcds of smaller numbers than one gcd of big ones. The 
algorithm for addition is a bit more complicated, at least to see that it is 
correct, but is still not that bad (the paper linked in the OP explains it 
clearly in one paragraph). It's far less complicated than, for example, 
Lehmer's gcd algorithm (which is implemented in math.gcd).

--

___
Python tracker 

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



[issue43379] Pasting multiple lines in the REPL is broken since 3.9

2021-03-07 Thread Romain Vincent


Romain Vincent  added the comment:

The lack of dots was something I noticed.

So from your questions (Ned Deily) I have been testing out several things and 
found a "wae"!

But first, to answer your questions:

1. both LF and CRLF and it didn't change anything.

2. Running "import readline;print(readline.__doc__)" prints
"... GNU readline", with python 3.7, 3.8 and 3.9.

3. I am using iTerm2, but the problem also happens on MacOS's native 
Terminal.app. Versions of python were installed with **homebrew**.


Maybe worth to mention: if I paste my code in a multi line string to execute 
with python -c, then it works properly.

e.g.

---

python3.9 -i -c 'a = 42
if a:
  print("hello world")
'
hello world
>>>

---

The example is different because I realized I had the same problem on python3.7 
and python3.8 when the 2 first lines were at the same level of indentation 
(Note sure if this gives a hint as to what the problem is).



HOWEVER, if I use python versions directly downloaded from 
https://www.python.org/, then I don't have the problem at all!

Demonstration:

---
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline;print(readline.__doc__)
Importing this module enables command line editing using libedit readline.
>>> a = 42
>>> if a:
...   print("hello world")
... 
hello world
>>> 

---

Same for python3.9

--

___
Python tracker 

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



[issue43332] Make http.client._tunnel send one byte string over the network

2021-03-07 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
assignee:  -> gregory.p.smith

___
Python tracker 

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



[issue43332] Make http.client._tunnel send one byte string over the network

2021-03-07 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
keywords: +patch
pull_requests: +23545
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/24780

___
Python tracker 

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



[issue43216] Removal of @asyncio.coroutine in Python 3.10

2021-03-07 Thread Mariusz Felisiak


Change by Mariusz Felisiak :


--
nosy: +felixxm

___
Python tracker 

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



[issue24800] exec docs should note that the no argument form in a local scope is really the two argument form

2021-03-07 Thread Eryk Sun


Eryk Sun  added the comment:

So there are a couple things to clarify here. When the documentation says "if 
the optional parts are omitted, the code is executed in the current scope", I 
think it should explicitly state that this is equivalent to calling 
exec(object, globals(), locals()). This should help to disabuse the reader of 
any assumption that the compiled code will extend the nested scoping (i.e. 
lexical closures) of the calling context.

When it says that if "exec gets two separate objects as globals and locals, the 
code will be executed as if it were embedded in a class definition", I think 
this can be misleading. exec() compiles top-level code. It extends module-like 
execution, allowing globals and locals to differ and defaulting to the current 
scope. This sharply contrasts to code that's compiled for a `class` statement 
in the same context.

--
type: behavior -> enhancement
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.4, Python 3.5, Python 
3.6

___
Python tracker 

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



[issue29982] tempfile.TemporaryDirectory fails to delete itself

2021-03-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

SGTM

--

___
Python tracker 

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



[issue43422] Revert _decimal C API changes

2021-03-07 Thread hai shi


hai shi  added the comment:

+1 from me. 3.10.0 final haven't been released, so no one will be affected.

--
nosy: +shihai1991, vstinner

___
Python tracker 

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



[issue22790] some class attributes missing from dir(Class)

2021-03-07 Thread Eryk Sun


Eryk Sun  added the comment:

>> Why are __flags__, __basicsize__, __itemsize__, 
>>__dictoffset__, and __weakrefoffset__ interesting?
>
> I haven't said they are, but on the other hand I don't see 
> why consistency is a bad thing.

IMO, they're not interesting because they're not documented attributes in 
Python's data model. They don't exist in other implementations, such as PyPy. 
So I'd prefer to hide them and, as much as possible, discourage developers from 
thinking it's okay to use them. They may be interesting attributes while 
developing extension modules that define new types, but anyone working at that 
level surely doesn't need the help of dir() to know what attributes are 
available.

--
components: +Interpreter Core -Documentation
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.4, Python 3.5

___
Python tracker 

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



[issue43425] test_peg_generator.test_c_parser emits DeprecationWarning due to distutils

2021-03-07 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the clarification. As per issue41282 I thought disutils will be 
removed. The accepted PEP 632 states this scenario so I guess silencing the 
warning is good enough.

> The final dependency on distutils is CPython itself, which uses it to build 
> native extension modules in the standard library (except on Windows). Because 
> this is a CPython build-time dependency, it is possible to continue to use 
> distutils for this specific case without it being part of the standard 
> library.

--

___
Python tracker 

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



[issue43425] test_peg_generator.test_c_parser emits DeprecationWarning due to distutils

2021-03-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

We just need to suppress the warning unless I am missing somey. Distutils will 
still be used internally by CPython.

--

___
Python tracker 

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



[issue43427] Possible error on the descriptor howto guide

2021-03-07 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +rhettinger

___
Python tracker 

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



[issue8304] time.strftime() and Unicode characters on Windows

2021-03-07 Thread Eryk Sun


Eryk Sun  added the comment:

Update since msg255133:

Python 3.8+ now calls setlocale(LC_CTYPE, "") at startup in Windows, as 3.x has 
always done in POSIX. So decoding the output of C strftime("%Z") with 
PyUnicode_DecodeLocaleAndSize() 'works' again, since both default to the 
process code page. The latter is usually the system code page, unless 
overridden to UTF-8 in the application manifest.

But calling C strftime() as a workaround is still a fragile solution, since it 
requires that the process code page is able to encode the process or thread UI 
language. In general, the system code page, the current user locale, and 
current user preferred language are independent settings in Windows. 

Calling C strftime() also unnecessarily limits the format string to characters 
in the current LC_CTYPE locale encoding, which requires hacky workarounds.

Starting with Windows 10 v2004 (build 19041), ucrt uses an internal 
wide-character version of the time-zone name that gets returned by an internal 
__wide_tzname() call and used for "%Z" in wcsftime(). The wide-character value 
gets updated by _tzset() and kept in sync with _tzname.

If Python switched to using wcsftime() in Windows 10 2004+, then the current 
locale encoding would no longer be a problem for any UI language. 

Also, bpo-36779 switched to setting time.tzname by directly calling WinAPI 
GetTimeZineInformation(). time.tzset() should be implemented in order to keep 
the value of time.tzname in sync with time.strftime("%Z").

--
components: +Extension Modules
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.4, Python 3.5, Python 
3.6

___
Python tracker 

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



[issue43427] Possible error on the descriptor howto guide

2021-03-07 Thread Marcos M


Marcos M  added the comment:

Let me provide a link to ease finding this piece of documentation

https://docs.python.org/3/howto/descriptor.html#static-methods

--

___
Python tracker 

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



[issue43427] Possible error on the descriptor howto guide

2021-03-07 Thread Marcos M


New submission from Marcos M :

> To recap, functions have a __get__() method so that they can be converted to 
> a method when accessed as attributes. The non-data descriptor transforms an 
> obj.f(*args) call into f(obj, *args). Calling cls.f(*args) becomes f(*args).

I THINK it should say

cls.f(*args) becomes f(cls, *args)

as stated in the table that follows that paragraph.

--
assignee: docs@python
components: Documentation
messages: 388239
nosy: docs@python, marcosmodenesi
priority: normal
severity: normal
status: open
title: Possible error on the descriptor howto guide
type: enhancement
versions: Python 3.9

___
Python tracker 

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



[issue43216] Removal of @asyncio.coroutine in Python 3.10

2021-03-07 Thread Kamil Turek


Change by Kamil Turek :


--
nosy: +kamilturek

___
Python tracker 

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



[issue43319] A possible misleading expression in the Virtual Environment Tutorial

2021-03-07 Thread Kamil Turek


Change by Kamil Turek :


--
nosy: +kamilturek

___
Python tracker 

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



[issue10653] test_time test_strptime fails on windows

2021-03-07 Thread Eryk Sun


Eryk Sun  added the comment:

> decoding the output of strftime("%Z") with PyUnicode_DecodeLocaleAndSize()
> works again since both agree on using the process active code page

At least it works as much as it ever did. It depends on the process active code 
page being compatible with the preferred UI language of the current process or 
thread. For example if the UI language is Japanese ('ja-JP') for the current 
user, but the process active code page is Latin 1252 (based on the system 
locale), then the result will be garbage. In that case, given the time-zone 
name is in Japanese, both LC_TIME and LC_CTYPE have to be changed to "ja-JP" in 
order to correctly encode (as tzname in ucrt), decode-encode (for strftime in 
ucrt) and finally decode again via PyUnicode_DecodeLocaleAndSize(). If Python 
switched back to using wcsftime() in Windows 10 2004+, then the current locale 
encoding would no longer be a problem for any UI language.

--

___
Python tracker 

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



[issue10653] test_time test_strptime fails on windows

2021-03-07 Thread Eryk Sun


Eryk Sun  added the comment:

Update since msg243660: 

Python 3.8+ now calls setlocale(LC_CTYPE, "") at startup in Windows, as it has 
always done in POSIX, so decoding the output of strftime("%Z") with 
PyUnicode_DecodeLocaleAndSize() works again since both agree on using the 
process active code page. 

In 3.7+, per bpo-36779, time.tzname is set when the module is first loaded by 
directly querying GetTimeZoneInformation(). time.tzset() is still not 
supported, despite the fact that it was always supported by ucrt, so this value 
can become stale relative to strftime("%Z").

Starting with Windows 10 v2004 (build 19041), ucrt uses an internal 
wide-character version of the time-zone name that gets returned by an internal 
__wide_tzname() call and used for "%Z" in wcsftime(). The wide-character value 
gets updated by _tzset() and kept in sync with _tzname.

--

___
Python tracker 

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



[issue43420] Optimize rational arithmetics

2021-03-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

> There is one exception I've found: stdlib's statistics module uses
> Fraction's in the _sum() helper, exactly in a paradigm "sum a lot
> of values".

That's an interesting example: it does indeed satisfy the "sum of a lot of 
values" part, but not the "incompatible denominators" part. :-) The typical use 
there is that those fractions have been converted from floats, and so all 
denominators will be a smallish power of two. So we don't encounter the same 
coefficient explosion problem that we do when summing fractions with unrelated 
denominators. I have many similar use-cases in my own code, where numerators 
and denominators don't tend to ever get beyond a few hundred digits, and 
usually not more than tens of digits.

Thanks for the timings! So assuming that wasn't a specially-chosen best case 
example, the crossover is somewhere around numerators and denominators of ten 
digits or so.

> It's not going to be complicated so much

For me, the big difference is that the current code is obviously correct at a 
glance, while the proposed code takes study and thought to make sure that no 
corner cases are missed.

Shrug. Put me down as -0.

--

___
Python tracker 

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



[issue43420] Optimize rational arithmetics

2021-03-07 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

> I'd prefer to keep the code simplicity

It's not going to be complicated so much and algorithms are well known,
but I see your point.

> and the speed for small inputs here

Speed loss is not so big, 10-20%.

> Python's needs aren't the same as SymPy's needs or SAGE's needs

So, for which needs it will serve?

Sorry, I can't suggest an application, which does use builtin
Fraction's (not sure if even SAGE uses them, as a fallback).  SymPy doesn't,
for sure (but it could - it's PythonRational class uses same optimizations,
except for g == 1 branches in _add/_sub, I think).

There is one exception I've found: stdlib's statistics module uses Fraction's
in the _sum() helper, exactly in a paradigm "sum a lot of values".

> not all of the fractions.Fraction use-cases involve summing lots of values 
> with incompatible denominators.

No need for a lots of values (i.e. 1000): denominator of the sum will grow very 
fast, that
why modern CAS use modular GCD algorithms, for example.

> Could you give some idea of the crossover point for a single addition?

$ ./python -m timeit -r11 -s 'from fractions import Fraction as F' -s 
'a=F(10,31011021112)' -s 'b=F(86,11011021115)' 'a + b'
2 loops, best of 11: 12.4 usec per loop
$ ./python -m timeit -r11 -s 'from patched import Fraction as F' -s 
'a=F(10,31011021112)' -s 'b=F(86,11011021115)' 'a + b'
2 loops, best of 11: 12.5 usec per loop

--

___
Python tracker 

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



[issue43060] Convert _decimal C API from pointer array to struct

2021-03-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

Just a note that #43422 would make this moot.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue41324] Add a minimal decimal capsule API

2021-03-07 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

@mattip, see issue43422

--
assignee: skrah -> 

___
Python tracker 

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



[issue43420] Optimize rational arithmetics

2021-03-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

Personally, I'd prefer to keep the code simplicity, and the speed for small 
inputs here. Python's needs aren't the same as SymPy's needs or SAGE's needs, 
and not all of the fractions.Fraction use-cases involve summing lots of values 
with incompatible denominators.

> With big denominators (~10**6) this really does matter, my local
> benchmarks suggest the order of magnitude difference for
> summation of several such numbers.

Could you give some idea of the crossover point for a single addition? At 
roughly what size numerator/denominator do we start seeing a performance 
benefit?

--

___
Python tracker 

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



[issue43422] Revert _decimal C API changes

2021-03-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

+1 for reverting these before 3.10. See also @mattip's comments on #41324, and 
#43060.

--

___
Python tracker 

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



[issue41369] Update to libmpdec-2.5.1

2021-03-07 Thread Mark Dickinson


Mark Dickinson  added the comment:

Sounds fine to me. If I'm understanding right, what we have in master right now 
is somewhere between libmpdec 2.5.0 and libmpdec 2.5.1; is that right? If so, 
it definitely makes sense to update to 2.5.1.

--

___
Python tracker 

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



[issue43372] ctypes: test_frozentable fails when make regen-frozen

2021-03-07 Thread Miro Hrončok

Miro Hrončok  added the comment:

Thanks for the fixer!

--

___
Python tracker 

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



[issue1814] Victor Stinner's GMP patch for longs

2021-03-07 Thread Sergey B Kirpichev


Change by Sergey B Kirpichev :


--
nosy: +Sergey.Kirpichev

___
Python tracker 

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



[issue21922] PyLong: use GMP

2021-03-07 Thread Sergey B Kirpichev


Change by Sergey B Kirpichev :


--
nosy: +Sergey.Kirpichev

___
Python tracker 

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



[issue43319] A possible misleading expression in the Virtual Environment Tutorial

2021-03-07 Thread miss-islington


miss-islington  added the comment:


New changeset 8d00462850b32da4649c3403692ed5515e6a96d1 by cmhzc in branch 
'master':
bpo-43319: Fixed the tutorial on venv about standard library (GH-24740)
https://github.com/python/cpython/commit/8d00462850b32da4649c3403692ed5515e6a96d1


--
nosy: +miss-islington

___
Python tracker 

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