[issue39567] Add audit for os.walk, os.fwalk, Path.glob() and Path.rglob()

2020-02-06 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

See issue38149.

There is an audit for os.scandir(), but it would be useful to have information 
about higher-level operations.

--
components: Library (Lib)
messages: 361472
nosy: serhiy.storchaka, steve.dower
priority: normal
severity: normal
status: open
title: Add audit for os.walk, os.fwalk, Path.glob() and Path.rglob()
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



[issue39567] Add audit for os.walk(), os.fwalk(), Path.glob() and Path.rglob()

2020-02-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: Add audit for os.walk, os.fwalk, Path.glob() and Path.rglob() -> Add 
audit for os.walk(), os.fwalk(), Path.glob() and Path.rglob()

___
Python tracker 

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



[issue39567] Add audit for os.walk(), os.fwalk(), Path.glob() and Path.rglob()

2020-02-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue36792] [Windows] time: crash on formatting time with de_DE locale

2020-02-06 Thread Eryk Sun


Eryk Sun  added the comment:

> Even some well known locale names still use the utf-8 code page.  Most 
> seem to uncommon, but at least es-BR (Brazil) does and would still 
> fall victim to these UCRT bugs.

es-BR is a custom locale for the Spanish language in Brazil, as opposed to the 
common Portuguese locale (pt-BR). It's a Unicode-only locale, which means its 
ANSI codepage is 0. Since 0 is CP_ACP, its effective ANSI codepage is the 
system or process ANSI codepage. 

For example:

>>> kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
>>> buf = (ctypes.c_wchar * 10)()

Portuguese in Brazil uses codepage 1252 as its ANSI codepage:

>>> n = kernel32.GetLocaleInfoEx('pt-BR', 0x1004, buf, 10)
>>> buf.value
'1252'

Spanish in Brazil uses CP_ACP:

>>> n = kernel32.GetLocaleInfoEx('es-BR', 0x1004, buf, 10)
>>> buf.value
'0'

hi-IN (Hindi, India) is a common Unicode-only locale:

>>> n = kernel32.GetLocaleInfoEx('hi-IN', 0x1004, buf, 10)
>>> buf.value
'0'

ucrt has switched to using UTF-8 for Unicode-only locales:

>>> locale.setlocale(locale.LC_CTYPE, 'hi_IN')
'hi_IN'
>>> ucrt = ctypes.CDLL('ucrtbase', use_errno=True)
>>> ucrt.___lc_codepage_func()
65001

Note that ucrt uses UTF-8 for Unicode-only locales only when using an 
explicitly named locale such as "hi_IN", "Hindi_India" or even just "Hindi". On 
the other hand, if a Unicode-only locale is used implicitly, ucrt instead uses 
the system ANSI codepage:

>>> locale.setlocale(locale.LC_CTYPE, '')
'Hindi_India.1252'
>>> ucrt.___lc_codepage_func()
1252

I suppose this is for backwards compatibility. Windows 10 at least supports 
setting the system ANSI codepage to UTF-8, or overriding the process ANSI 
codepage to UTF-8 via the application manifest "actveCodePage" setting. For the 
latter, I modified the manifest in a "python_utf8.exe" copy of the normal 
"python.exe" binary, which is simpler than having to reboot to change the 
system locale:

C:\>python_utf8 -q

>>> import locale
>>> locale.setlocale(locale.LC_CTYPE, '')
'Hindi_India.utf8'

--

___
Python tracker 

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



[issue38149] sys.audit() is called multiple times for glob.glob()

2020-02-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 54b4f14712b9350f11c983f1c8ac47a3716958a7 by Serhiy Storchaka in 
branch 'master':
bpo-38149: Call sys.audit() only once per call for glob.glob(). (GH-18360)
https://github.com/python/cpython/commit/54b4f14712b9350f11c983f1c8ac47a3716958a7


--

___
Python tracker 

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



[issue38149] sys.audit() is called multiple times for glob.glob()

2020-02-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17749
pull_request: https://github.com/python/cpython/pull/18373

___
Python tracker 

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



[issue38149] sys.audit() is called multiple times for glob.glob()

2020-02-06 Thread miss-islington


miss-islington  added the comment:


New changeset 708f472dd92f4f46c27ace710492da65da4a3319 by Miss Islington (bot) 
in branch '3.8':
bpo-38149: Call sys.audit() only once per call for glob.glob(). (GH-18360)
https://github.com/python/cpython/commit/708f472dd92f4f46c27ace710492da65da4a3319


--
nosy: +miss-islington

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-02-06 Thread hai shi


Change by hai shi :


--
pull_requests: +17750
pull_request: https://github.com/python/cpython/pull/18374

___
Python tracker 

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



[issue36792] [Windows] time: crash on formatting time with de_DE locale

2020-02-06 Thread Eryk Sun

Eryk Sun  added the comment:

That the CRT caches the tzname strings as ANSI multibyte strings is frustrating 
-- whether or not it's buggy. I would expect there to be a _wtzname cache of 
the native OS strings that wcsftime uses directly, with no potential for failed 
encodings (e.g. empty strings or mojibake).

It's also strange that it encodes the time-zone name using the system ANSI 
codepage in the C locale. Normally LC_CTYPE in the C locale uses Latin-1, due 
to simple casting between WCHAR and CHAR. This leads to mojibake when the ANSI 
time-zone name gets decoded as Latin-1 by an internal mbstowcs call in 
wcsftime. I'm not saying one or the other is necessarily right, but more care 
should haven gone into this. At the very least, if we're stuck with system ANSI 
tzname strings in the C locale, then a flag should be set that tells wcsftime 
to decode them as system ANSI strings instead of via mbstowcs.

Also, the timezone name is determined by the preferred UI language of the 
current user, which is not necessarily compatible with the system ANSI 
codepage. It's not even necessarily compatible with the user-locale ANSI 
codepage, as used by setlocale(LC_CTYPE, ""). Windows 10 at least provides an 
option to sync the user locale with the user preferred UI language. IMO, this 
is a strong argument in favor of using _wtzname wide-character strings. UI 
Language (MUI) and locale are not tightly coupled in Windows NLS.

Here's an example where the user's preferred language is Hindi, and the time 
zone name is "समन्वित वैश्विक समय" (i.e. Coordinated Universal Time), but the 
system locale is English with codepage 1252 (for Western European languages). 
This is a normal configuration if the system locale doesn't have beta UTF-8 
support enabled, or if the process ANSI codepage isn't overridden to UTF-8 via 
the "activeCodePage" manifest setting.

The tzname strings normally get set by a one-time _tzset call, and they're only 
reset if tzset is called manually. tzset uses the system ANSI encoding if 
LC_CTYPE is the "C" locale (again, normally ucrt uses Latin-1 in the "C" 
locale). Since the encoding of the Hindi timezone name to codepage 1252 
contains the default character ("?"), which is not allowed, tzset sets the 
tzname strings to empty strings.

import ctypes, locale, time
ucrt = ctypes.CDLL('ucrtbase', use_errno=True)
ucrt.__tzname.restype = ctypes.POINTER(ctypes.c_char_p)
tzname = ucrt.__tzname()

>>> locale.setlocale(locale.LC_CTYPE, 'C')
'C'
>>> ucrt._tzset()
0
>>> tzname[0], tzname[1]
(b'', b'')
>>> time.strftime('%Z')
''

If we update the LC_CTYPE category to use UTF-8, the cached tzname value 
doesn't get automatically updated, and strftime still returns an empty string:

>>> locale.setlocale(locale.LC_CTYPE, '.utf8')
'Hindi_India.utf8'

>>> tzname[0], tzname[1]
(b'', b'')
>>> time.strftime('%Z')
''

The tzname values get updated if we manually call tzset:

>>> ucrt._tzset()
0
>>> tzname[0].decode('utf-8'), tzname[1].decode('utf-8')
('समन्वित वैश्विक समय', 'समन्वित वैश्विक समय')

However, LC_TIME is still in the "C" locale. strftime uses system ANSI (1252) 
in this case, so the encoded result from the CRT strftime call ends up using 
the default character (?):

>>> time.strftime('%Z')
'??? ??? ???'

If we set LC_TIME to UTF-8, we finally get a valid result:

>>> locale.setlocale(locale.LC_TIME, '.utf8')
'Hindi_India.utf8'
>>> time.strftime('%Z')
'समन्वित वैश्विक समय'

We wouldn't have to worry about LC_TIME here if Python called C wcsftime 
instead of C strftime. The problem that bpo-10653 was trying to work around is 
a design flaw in the C runtime library, and calling strftime is not a solution. 

Here's a variation on my example in msg243660, continuing with the current 
Hindi example. The setup in this example uses UTF-8 as the system ANSI codepage 
(via python_utf8.exe) and sets LC_CTYPE to the "C" locale. This yields the 
following monstrosity:

>>> time.strftime('%Z')
'Ã\xa0¤¸Ã\xa0¤®Ã\xa0¤¨Ã\xa0Â¥Â\x8dÃ\xa0¤µÃ\xa0¤¿Ã\xa0¤¤ 
Ã\xa0¤µÃ\xa0Â¥Â\x88Ã\xa0¤¶Ã\xa0Â¥Â\x8dÃ\xa0¤µÃ\xa0¤¿Ã\xa0¤Â\x95 
Ã\xa0¤¸Ã\xa0¤®Ã\xa0¤¯'

It's due to the following sequence of encoding and decoding operations:

>>> mbs_lcctype_utf8 = 'समन्वित वैश्विक समय'.encode('utf-8')
>>> wcs_lcctype_latin1 = mbs_lcctype_utf8.decode('latin-1')
>>> mbs_lctime_utf8 = wcs_lcctype_latin1.encode('utf-8')

This last one is from PyUnicode_DecodeLocaleAndSize and mbstowcs:

>>> py_str_lcctype_latin1 = mbs_lctime_utf8.decode('latin-1')
>>> py_str_lcctype_latin1 == time.strftime('%Z')
True

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/option

[issue39564] Parsed expression has wrong col_offset when concatenating f-strings

2020-02-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

I'll see if I can dig up the patch today. If I can find it, I'll attach it to 
issue 34364.

This is really the first time I've tried to write down all of the issues 
related to tokenizing f-strings. It does seem a little daunting, but I'm not 
done noodling it through. At first blush it looks like the tokenizer would need 
to remember if it's inside an f-string or not and switch to different rules if 
so. Which doesn't exactly describe your average tokenizer, but I'm not sure how 
Python's tokenizer would need to be changed to deal with it, or how messy that 
change would be.

I should probably write an informational PEP about parsing f-strings. And I 
should include the reason I went with the "just a regular string which is later 
hand-parsed" approach: at the time, f-strings were a controversial topic (there 
were any number of reddit threads predicting doom and gloom if they were 
added). By parsing them as just regular strings with one simple added string 
prefix, it allowed existing tooling (editors, syntax highlighters, etc.) to 
easily skip over them just by recognizing 'f' as an additional string prefix.

--

___
Python tracker 

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



[issue38149] sys.audit() is called multiple times for glob.glob()

2020-02-06 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
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



[issue39541] distutils: Remove bdist_wininst (Windows .exe installers) in favor of bdist_wheel (.whl)

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

Small update, my setuptools change has been merged:

" Add support for installing scripts in environments where bdist_wininst is 
missing (i.e. Python 3.9)."

https://github.com/pypa/setuptools/commit/5d17586a56077dfa3109a5861cf0ff579095a42e

--

___
Python tracker 

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



[issue39549] The reprlib.Repr type should permit the “fillvalue” to be set by the user

2020-02-06 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
nosy: +rhettinger
versions:  -Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue39566] inspect.Signature.__init__ asks for parameters as dict but treats as list

2020-02-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

It says list in the __init__ doc : 
https://github.com/python/cpython/blob/54b4f14712b9350f11c983f1c8ac47a3716958a7/Lib/inspect.py#L2759

It says that parameters is a public property that returns a mapping of 
parameter name to object at : 
https://github.com/python/cpython/blob/54b4f14712b9350f11c983f1c8ac47a3716958a7/Lib/inspect.py#L2734
 . The change to dict was done with 2cca8efe46935c39c445f585bce54954fad2485b .

I can see the public attribute returning dictionary. Can you please point to 
the doc where it says the parameter should be a dictionary to the constructor?

--
nosy: +xtreak

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17751
pull_request: https://github.com/python/cpython/pull/18375

___
Python tracker 

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



[issue38686] WWW-Authenticate qop="auth,auth-int" rejected by urllib

2020-02-06 Thread Stephen Balousek


Change by Stephen Balousek :


--
pull_requests: +17752
pull_request: https://github.com/python/cpython/pull/18338

___
Python tracker 

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



[issue39568] FORMATTING grouping_option ValueError: Cannot specify ', ' with ...

2020-02-06 Thread Another One


New submission from Another One :

Example for binary representation:

>>> x = 123456
>>> print("{:,b}".format(x))
Traceback (most recent call last):
  File "", line 1, in 
print("{:,b}".format(x))
ValueError: Cannot specify ',' with 'b'.

Why? Comma work only with decimals?

But '_' groups delimiter properly work with any integer representation 
including decimals, hexadecimals, binaries, octals, etc..

--
messages: 361480
nosy: Another One
priority: normal
severity: normal
status: open
title: FORMATTING grouping_option ValueError: Cannot specify ',' with ...
versions: Python 3.8

___
Python tracker 

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



[issue39548] Request fails when 'WWW-Authenticate' header for Digest Authentication does not contain 'qop'

2020-02-06 Thread Stephen Balousek


Change by Stephen Balousek :


--
versions: +Python 3.7

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

I tried but failed to write a test to mimick numpy.int64 type. I tried to build 
a type which implements numbers.Rational but don't inherit from int, but there 
are way too many methods that I have to implement :-(

Morever, installing numpy on a Python 3.9 virtual environment is quite tricky. 
Lhe latest Cython release (0.29.14) isn't compatible with Python 3.9.

Miro gave me a command to install Cython on Python 3.9:

python -m pip install https://github.com/cython/cython/archive/master.tar.gz 
--install-option="--no-cython-compile"

But then "pip install numpy" tries to reinstall Cython which fails :-/

--
resolution: fixed -> 

___
Python tracker 

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



[issue39568] FORMATTING grouping_option ValueError: Cannot specify ', ' with ...

2020-02-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

No one thought it made sense to have a comma every 3 bits. Or for octal or hex, 
either.

Do you have some specific use case where it makes sense?

--
nosy: +eric.smith

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

I managed to test my PR with numpy:

$ env/bin/python 
>>> import fractions
>>> import numpy
>>> f=fractions.Fraction(numpy.int64(1*3), numpy.int64(2*3))
>>> f
Fraction(1, 2)
>>> type(f.numerator)

>>> type(f.denominator)


So it works as expected: numerator and denominator have the expected type, and 
there is no exception ;-)

I used the following commands to get numpy in a Python 3.9 virtual environment:

./python -m venv env
env/bin/python -m pip install 
https://github.com/cython/cython/archive/master.tar.gz 
--install-option="--no-cython-compile"
curl -O 
https://files.pythonhosted.org/packages/40/de/0ea5092b8bfd2e3aa6fdbb2e499a9f9adf810992884d414defc1573dca3f/numpy-1.18.1.zip
unzip -d . numpy-1.18.1.zip
cd numpy-1.18.1/
../env/bin/python setup.py install

--

___
Python tracker 

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



[issue39564] Parsed expression has wrong col_offset when concatenating f-strings

2020-02-06 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

Also note that for pegen this is a solved problem. If we decide to change the 
parser, it may not be worth it to spend too much time on a universal solution.

--

___
Python tracker 

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



[issue39350] Remove deprecated fractions.gcd()

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

FYI the full numpy test suite pass with PR 18375:

(env) vstinner@apu$ python runtests.py  -v
(...)
=== 9879 passed, 443 skipped, 180 deselected, 17 xfailed, 3 
xpassed in 305.17s (0:05:05) ===

--

___
Python tracker 

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



[issue38823] Improve stdlib module initialization error handling.

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d2f96672642cc51b92f61b951ca1b11d615c12d1 by Brandt Bucher in 
branch 'master':
bpo-38823: Fix refleaks in _ast initialization error path (GH-17276)
https://github.com/python/cpython/commit/d2f96672642cc51b92f61b951ca1b11d615c12d1


--

___
Python tracker 

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



[issue39245] Public API for Vectorcall (PEP 590)

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 3f563cea567fbfed9db539ecbbacfee2d86f7735 by Petr Viktorin in 
branch 'master':
bpo-39245: Make Vectorcall C API public (GH-17893)
https://github.com/python/cpython/commit/3f563cea567fbfed9db539ecbbacfee2d86f7735


--

___
Python tracker 

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



[issue39274] Conversion from fractions.Fraction to bool

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 427c84f13f7719e6014a21bd1b81efdc02a046fb by Sebastian Berg in 
branch 'master':
bpo-39274: Ensure Fraction.__bool__() returns a bool (GH-18017)
https://github.com/python/cpython/commit/427c84f13f7719e6014a21bd1b81efdc02a046fb


--

___
Python tracker 

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



[issue39274] Conversion from fractions.Fraction to bool

2020-02-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17753
pull_request: https://github.com/python/cpython/pull/18376

___
Python tracker 

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



[issue39274] Conversion from fractions.Fraction to bool

2020-02-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17754
pull_request: https://github.com/python/cpython/pull/18377

___
Python tracker 

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



[issue39274] Conversion from fractions.Fraction to bool

2020-02-06 Thread STINNER Victor

STINNER Victor  added the comment:

Thanks Sebastian Berg for the fix, and thanks François Durand for the bug 
report! This issue is fixed in the master branch, and backports to 3.7 and 3.8 
will land soon automatically (once the CI tests pass).

--
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



[issue39568] FORMATTING grouping_option ValueError: Cannot specify ', ' with ...

2020-02-06 Thread Another One


Another One  added the comment:

Not for 3 bits, just for 4 bits, like this:
>>> print("{:_b}".format(123456))
1_1110_0010_0100_

And as I already said: "But '_' groups delimiter properly work with any integer 
representation including decimals, hexadecimals, binaries, octals, etc.." Not 
only for binaries.
Why comma delimiter is not?
Logic must be the same. Simple use the one procedure for '_' delimiter with 
permit comma as parameter, instead of two different logic.

--

___
Python tracker 

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



[issue39274] Conversion from fractions.Fraction to bool

2020-02-06 Thread miss-islington


miss-islington  added the comment:


New changeset 0d03a1028200646479ef9bb0ad8973d0e73f9525 by Miss Islington (bot) 
in branch '3.8':
bpo-39274: Ensure Fraction.__bool__() returns a bool (GH-18017)
https://github.com/python/cpython/commit/0d03a1028200646479ef9bb0ad8973d0e73f9525


--
nosy: +miss-islington

___
Python tracker 

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



[issue39274] Conversion from fractions.Fraction to bool

2020-02-06 Thread miss-islington


miss-islington  added the comment:


New changeset 705d271d553b77fd170d27ab8d0f11f638c7f145 by Miss Islington (bot) 
in branch '3.7':
bpo-39274: Ensure Fraction.__bool__() returns a bool (GH-18017)
https://github.com/python/cpython/commit/705d271d553b77fd170d27ab8d0f11f638c7f145


--

___
Python tracker 

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



[issue39568] FORMATTING grouping_option ValueError: Cannot specify ', ' with ...

2020-02-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

Well, you asked why commas only work with decimals and I told you.

Adding "_" would require a PEP. See PEP 378 if you want to write something 
similar for "_". I think it's a decent idea. You'll have to decide between 4 
and 8 bits, and what to do with octal and hex.

But I'm going to close this issue, since it's about commas and non-base 10 
representations. If you want to pursue underscores, the next step would be to 
discuss it on the python-ideas mailing list.

--
assignee:  -> eric.smith
resolution:  -> not a bug
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



[issue39569] Is the return value of pathlib.Path.glob() sorted?

2020-02-06 Thread Björn Lindqvist

New submission from Björn Lindqvist :

It would be great if the docs were clearer on what you can assume on the 
ordering of pathlib.Path.glob() calls. Is it sorted? Is it the same in 
consecutive calls? I'm guessing you can't assume anything at all, which I think 
should be clarified in the docs.

--
assignee: docs@python
components: Documentation
messages: 361494
nosy: Björn.Lindqvist, docs@python
priority: normal
severity: normal
status: open
title: Is the return value of pathlib.Path.glob() sorted?
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



[issue39542] Cleanup object.h header

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17755
pull_request: https://github.com/python/cpython/pull/18378

___
Python tracker 

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



[issue39570] Python 3.7.3 Crash on msilib actions

2020-02-06 Thread UltraLutra


New submission from UltraLutra :

Hello,

I'm trying to read MSI files using msilib.
Some files make python crash on Record.GetString of a specific cell.
Attached is one of the files that causes the crash, and this is the code that 
is causing it to crash:
db = 
msilib.OpenDatabase('6bcd682374529631be60819d20a71d9d40c67bf0b1909faa459298eda998f833',
 msilib.MSIDBOPEN_READONLY)
query = db.OpenView(f'SELECT * FROM Registry')
query.Execute(None)
for i in range(6):
record = query.Fetch()
record.GetString(5)

The crash seems to be by trying to read the Value columns of the last row in 
the Registry table.

file: https://github.com/AsafEitani/msilib_crash

--
components: Windows
messages: 361495
nosy: UltraLutra, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Python 3.7.3 Crash on msilib actions
type: crash
versions: Python 3.7

___
Python tracker 

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



[issue21622] ctypes.util incorrectly fails for libraries without DT_SONAME

2020-02-06 Thread Natanael Copa


Change by Natanael Copa :


--
pull_requests: +17756
pull_request: https://github.com/python/cpython/pull/18380

___
Python tracker 

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



[issue39569] Is the return value of pathlib.Path.glob() sorted?

2020-02-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

See also discussion at issue38764. I guess it's not sorted as per msg356356.

--
nosy: +serhiy.storchaka, xtreak

___
Python tracker 

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



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-06 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread Sam Gross


New submission from Sam Gross :

A recent commit added a typedef for PyTypeObject in Include/object.h

https://github.com/python/cpython/commit/0e4e735d06967145b49fd00693627f3624991dbc

This duplicates the typedef in Include/cpython/object.h. Building with clang 
now issues a warning:

./Include/cpython/object.h:274:3: warning: redefinition of typedef 
'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]

This is due to the combination of `-Wall` and `-std=c99`. GCC will only warn if 
the `-pedantic` option is specified.

--
components: C API
messages: 361497
nosy: colesbury, vstinner
priority: normal
severity: normal
status: open
title: clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 
feature [-Wtypedef-redefinition]"
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



[issue1294959] Problems with /usr/lib64 builds.

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17757
pull_request: https://github.com/python/cpython/pull/18381

___
Python tracker 

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



[issue39566] inspect.Signature.__init__ asks for parameters as dict but treats as list

2020-02-06 Thread Nicholas Matthews


Nicholas Matthews  added the comment:

I originally filed an issue believing the documentation for inspect.Signature 
was incorrect; I now think I misread the documentation. (Apologies, I'm used to 
a different docstring format)

--

___
Python tracker 

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



[issue39565] Modules/signalmodule.c creates handlers for signals bound by `NSIG`; requires fudging to support realtime signals, etc

2020-02-06 Thread Enji Cooper


Change by Enji Cooper :


--
title: Modules/signalmodule.c only works with `NSIG` signals; requires fudging 
to support realtime signals, etc -> Modules/signalmodule.c creates handlers for 
signals bound by `NSIG`; requires fudging to support realtime signals, etc

___
Python tracker 

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



[issue39565] Modules/signalmodule.c creates handlers for signals bounded by `NSIG`; requires fudging to support realtime signals, etc

2020-02-06 Thread Enji Cooper


Change by Enji Cooper :


--
title: Modules/signalmodule.c creates handlers for signals bound by `NSIG`; 
requires fudging to support realtime signals, etc -> Modules/signalmodule.c 
creates handlers for signals bounded by `NSIG`; requires fudging to support 
realtime signals, etc

___
Python tracker 

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



[issue39566] inspect.Signature.__init__ asks for parameters as dict but treats as list

2020-02-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

No problem, closing it as not a bug. Feel free to reopen if needed.

--
resolution:  -> not a bug
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



[issue39569] Is the return value of pathlib.Path.glob() sorted?

2020-02-06 Thread Brett Cannon


Brett Cannon  added the comment:

The problem is you would have to say the same thing for all functions that 
return a list or touch the file system. So it's typically better to just assume 
unsorted and you can't expect idempotent results when dealing with the OS.

--
nosy: +brett.cannon

___
Python tracker 

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



[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

2020-02-06 Thread Chris Withers


Chris Withers  added the comment:

Apologies, but I'm still not sure what "the modules are published" means?
"publish "x" as a child onto the package" also doesn't mean much to me, I'm 
afraid. Are you aware of any importlib docs or some such which might be able to 
explain this to me?

When "It can still have normal Python modules as a child which aren't 
immutable", what happens when you try to patch the immutable module? What 
happens if you try to patch the mutable module below it?

When "the assignment is ignored with a warning.", what is doing that ignoring?

Unless I'm missing something, this feels like such an edge case I'm not sure 
mock.patch should be trying to support it. Should this be something that is 
handled by your immutable import thing?

--

___
Python tracker 

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



[issue39537] Change line number table format

2020-02-06 Thread Mark Shannon


Mark Shannon  added the comment:

Serhiy,
How would you handle bytecodes that have no line number?

--
nosy: +Mark.Shannon

___
Python tracker 

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



[issue39572] [typing] TypedDict's 'total' argument is undocumented

2020-02-06 Thread Brett Cannon


New submission from Brett Cannon :

The docs mention __total__, but there's no mention of how to actually set that 
attribute, nor what it actually represents.

P.S. https://github.com/python/cpython/blob/master/Lib/typing.py#L16 says 
TypedDict "may be added soon"; I think that's outdated. ;)

--
assignee: docs@python
components: Documentation
messages: 361503
nosy: brett.cannon, docs@python, gvanrossum, levkivskyi
priority: normal
severity: normal
stage: needs patch
status: open
title: [typing] TypedDict's 'total' argument is undocumented
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



[issue39551] mock patch should match behavior of import from when module isn't present in sys.modules

2020-02-06 Thread Dino Viehland


Dino Viehland  added the comment:

Sorry, publish may not necessarily be the best term.  When you do "from foo 
import bar" and foo is a package Python will set the bar module onto the foo 
module.  That leads to the common mistake of doing "import foo" and then 
"foo.bar.baz" and later removing the thing that do "from foo import bar" and 
having things blow up later.

Without additional support there's no way to patch the immutable module.  We 
can provide a mode where we enable the patching for testing and disable it in a 
production environment though.  That basically just involves passing a proxy 
object down to Mock.  And monkey patching the mutable module is perfectly fine.

The thing that's doing the ignoring of the assignment is the import system.  So 
it's now okay if the package raises an AttributeError.

There's not really a great way to work around this other than just bypassing 
mock's resolution of the object here - i.e. replacing mock.patch along with 
_get_target, _importer, and _dot_lookup and calling mock._patch directly, which 
isn't very nice (but is do-able).

And while this is a strange way to arrive at a module existing in sys.modules 
but not being on the package it is something that can happen in the normal 
course of imports, hence the reason why the import system handles this by 
checking sys.modules today.  It's also just turning what is currently an error 
while mocking into a success case with a simple few line change.

--
stage: needs patch -> patch review

___
Python tracker 

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



[issue39542] Cleanup object.h header

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 2844336e6bb0dc932d710be5f4d8c126d0768d03 by Victor Stinner in 
branch 'master':
bpo-39542: Document limited C API changes (GH-18378)
https://github.com/python/cpython/commit/2844336e6bb0dc932d710be5f4d8c126d0768d03


--

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

Sorry, I only tested GCC and I forgot that clang is more pedantic on duplicated 
typedef. I looked better with PyTypeObject, but the fix is easy: just revert my 
change: PR 18384.

--

___
Python tracker 

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



[issue39542] Cleanup object.h header

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17758
pull_request: https://github.com/python/cpython/pull/18384

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread Sam Gross


Sam Gross  added the comment:

Alternatively I think you can just remove the typedef from 
Include/cpython/object.h since Include/object.h is always included first. i.e.:

typedef struct _typeobject {
  ...
} PyTypeObject;

to simply

struct _typeobject {
  ...
};

--

___
Python tracker 

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



[issue39534] Clarify tutorial on return statement in finally clause.

2020-02-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17760
pull_request: https://github.com/python/cpython/pull/18386

___
Python tracker 

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



[issue39534] Clarify tutorial on return statement in finally clause.

2020-02-06 Thread Julien Palard


Julien Palard  added the comment:


New changeset 446463f8dbce0556be8020914f37089b63bb8ab6 by Julien Palard in 
branch 'master':
bpo-39534: Doc: Clarify return in finally (GH-18324)
https://github.com/python/cpython/commit/446463f8dbce0556be8020914f37089b63bb8ab6


--

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

> Alternatively I think you can just remove the typedef from 
> Include/cpython/object.h since Include/object.h is always included first. 
> i.e.:

Oh, nice! I proposed PR 18385. Would you mind to confirm that it fix the issue 
for you? At least, I tested manually and the clang warning goes away with this 
change.

--

___
Python tracker 

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



[issue39534] Clarify tutorial on return statement in finally clause.

2020-02-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17761
pull_request: https://github.com/python/cpython/pull/18387

___
Python tracker 

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



[issue39534] Clarify tutorial on return statement in finally clause.

2020-02-06 Thread miss-islington


miss-islington  added the comment:


New changeset 83efed9eba9e50ed2395bd3366c31628b9555b1e by Miss Islington (bot) 
in branch '3.7':
bpo-39534: Doc: Clarify return in finally (GH-18324)
https://github.com/python/cpython/commit/83efed9eba9e50ed2395bd3366c31628b9555b1e


--
nosy: +miss-islington

___
Python tracker 

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



[issue39534] Clarify tutorial on return statement in finally clause.

2020-02-06 Thread miss-islington


miss-islington  added the comment:


New changeset 97e00b3c52796cb54dd0a50548760579b9cb7b3a by Miss Islington (bot) 
in branch '3.8':
bpo-39534: Doc: Clarify return in finally (GH-18324)
https://github.com/python/cpython/commit/97e00b3c52796cb54dd0a50548760579b9cb7b3a


--

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread Sam Gross


Sam Gross  added the comment:

Yes, that fixes the warnings for me. Thanks!

--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


New submission from STINNER Victor :

Today, CPython is leaking too many implementation through its public C API. We 
cannot easily change the "default" C API, but we can enhance the "limited" C 
API (when Py_LIMITED_API macro is defined). Example of leaking implementation 
details: memory allocator, garbage collector, structure layouts, etc.

Making PyObject an opaque structure would allow in the long term of modify 
structures to implement more efficient types (ex: list specialized for small 
integers), and it can prepare CPython to experiment tagged pointers.

Longer rationale:

* https://pythoncapi.readthedocs.io/
* https://pythoncapi.readthedocs.io/bad_api.html
* https://pythoncapi.readthedocs.io/optimization_ideas.html

I propose to incremental evolve the existing limited C API towards opaque 
PyObject, by trying to reduce the risk of breakage.

We may test changes on PyQt which uses the limited C API.

Another idea would be to convert some C extensions of the standard library to 
the limited C API. It would ensure that the limited C API contains enough 
functions to be useful, but would also notify us directly if the API is broken.

--
components: C API
messages: 361513
nosy: vstinner
priority: normal
severity: normal
status: open
title: Make PyObject an opaque structure in the limited C API
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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

> Another idea would be to convert some C extensions of the standard library to 
> the limited C API. It would ensure that the limited C API contains enough 
> functions to be useful, but would also notify us directly if the API is 
> broken.

First issues that I met when I tried that:

* C code generated by Argument Clinic is incompatible the limited C API: 
METH_FASTCALL, _PyArg_CheckPositional(), static _PyArg_Parser, etc. are 
excluded from the limited C API.
* PyTypeObject is opaque and so it's not possible to implement a deallocator 
function (tp_dealloc) which calls tp_free like:
  Py_TYPE(self)->tp_free((PyObject*)self);
* _Py_IDENTIFIER() is not part of the limited C API

--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a93c51e3a8e15f1a486d11d5b55a64f3381babe0 by Victor Stinner in 
branch 'master':
bpo-39573: Use Py_REFCNT() macro (GH-18388)
https://github.com/python/cpython/commit/a93c51e3a8e15f1a486d11d5b55a64f3381babe0


--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17763
pull_request: https://github.com/python/cpython/pull/18389

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

> it can prepare CPython to experiment tagged pointers

In September 2018, Neil Schemenauer did an experiment:

* 
https://mail.python.org/archives/list/capi-...@python.org/thread/EGAY55ZWMF2WSEMP7VAZSFZCZ4VARU7L/
* https://github.com/nascheme/cpython/commits/tagged_int

More recent discussion on the capi-sig list:

https://mail.python.org/archives/list/capi-...@python.org/thread/JPUNPN3AILGXOA3C2TTSLMOFNSWJE3QX/

See also my notes:
https://pythoncapi.readthedocs.io/optimization_ideas.html#tagged-pointers-doable

Wikipedia article: https://en.wikipedia.org/wiki/Tagged_pointer

--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

In the limited C API, Py_REFCNT() should be converted to:

static inline Py_ssize_t _Py_REFCNT(const PyObject *ob)
{ return ob->ob_refcnt; }
#define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST(ob))

It would enforce the usage of newly added Py_SET_REFCNT() (PR 18389) and 
advertise that the object is not modified (const).

That would only be the first step towards a really opaque Py_REFCNT() function.

--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

TODO: Add Py_IS_TYPE() macro:

#define Py_IS_TYPE(ob, tp) (Py_TYPE(ob) == (tp)) 

For example, replace:

#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) 

with:

#define PyBool_Check(x) Py_IS_TYPE(x, &PyBool_Type)

IMHO it makes the code more readable.

https://github.com/nascheme/cpython/commit/c156300592dc1eab234b74ed5b7cc90a020ab82b

--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset c86a11221df7e37da389f9c6ce6e47ea22dc44ff by Victor Stinner in 
branch 'master':
bpo-39573: Add Py_SET_REFCNT() function (GH-18389)
https://github.com/python/cpython/commit/c86a11221df7e37da389f9c6ce6e47ea22dc44ff


--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +nascheme

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17764
pull_request: https://github.com/python/cpython/pull/18390

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f95cd199b4bc16775c8c48641bd85416b17742e7 by Victor Stinner in 
branch 'master':
bpo-39571: Fix clang warning on PyTypeObject typedef (GH-18385)
https://github.com/python/cpython/commit/f95cd199b4bc16775c8c48641bd85416b17742e7


--

___
Python tracker 

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



[issue39571] clang warns "warning: redefinition of typedef 'PyTypeObject' is a C11 feature [-Wtypedef-redefinition]"

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks Sam Gross for the hint, it's now fixed.

--
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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 0d76d2bd28ac815dabae8b07240ed002ac8fce2d by Victor Stinner in 
branch 'master':
bpo-39573: Use Py_TYPE() in abstract.c (GH-18390)
https://github.com/python/cpython/commit/0d76d2bd28ac815dabae8b07240ed002ac8fce2d


--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17765
pull_request: https://github.com/python/cpython/pull/18391

___
Python tracker 

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



[issue39574] str.__doc__ is misleading

2020-02-06 Thread Zachary Westrick


Change by Zachary Westrick :


--
assignee: docs@python
components: Documentation
nosy: docs@python, kcirtsew
priority: normal
severity: normal
status: open
title: str.__doc__ is misleading
type: enhancement
versions: Python 3.5

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

Py_TYPE() is commonly used to render the type name in an error message. Example:

PyErr_Format(PyExc_TypeError,
 "cannot convert '%.200s' object to bytearray",
 Py_TYPE(arg)->tp_name);

This code has multiple issues:

* It truncates type name to 200 characters: there is no Python exception, not 
even a marker to indicate that the string has been truncated
* It's only the short name: the qualified name (tp_qualname) would be more 
helpful. The best would be to generate the fully qualified name: module + 
qualname.
* Py_TYPE() returns a borrowed reference which is causing multiple issues: 
https://pythoncapi.readthedocs.io/bad_api.html#borrowed-references

In September 2018, I created bpo-34595: "PyUnicode_FromFormat(): add %T format 
for an object type name". But there was disagreement, so I rejected my change.

I started "bpo-34595: How to format a type name?" thread on python-dev:
* 
https://mail.python.org/archives/list/python-...@python.org/thread/HKYUMTVHNBVB5LJNRMZ7TPUQKGKAERCJ/#3UAMHYG6UF4MPLXBZORHO4JVKUBRUZ53

I didn't continue this work (until now), since it wasn't my priority.

--

___
Python tracker 

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



[issue39574] str.__doc__ is misleading

2020-02-06 Thread Zachary Westrick


New submission from Zachary Westrick :

The docstring for the str() builtin reads

str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

The statement "encoding defaults to sys.getdefaultencoding()." implies that the 
encoding argument defaults to sys.getdefaultencoding(), which would typically 
mean that 

str(X, encoding=sys.getdefaultencoding()) == str(X)

However, this is not the case

str(b'mystring', encoding=sys.getdefaultencoding()) -> 'mystring'
str(b'mystring') -> "b'mystring'"

It seems that the phrase "encoding defaults" is not referring to the argument 
named encoding.

--

___
Python tracker 

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



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-06 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
pull_requests: +17766
pull_request: https://github.com/python/cpython/pull/18379

___
Python tracker 

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



[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-02-06 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 38ac805fa30870e2d093e52a900e3b34 by Jakub Stasiak in 
branch 'master':
bpo-39491: Mention Annotated in get_origin() docstring (GH-18379)
https://github.com/python/cpython/commit/38ac805fa30870e2d093e52a900e3b34


--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a102ed7d2f0e7e05438f14d5fb72ca0358602249 by Victor Stinner in 
branch 'master':
bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)
https://github.com/python/cpython/commit/a102ed7d2f0e7e05438f14d5fb72ca0358602249


--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17767
pull_request: https://github.com/python/cpython/pull/18392

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

Make PyObject an opaque structure is also a first step towards the more 
ambitious project "HPy" project which is fully opaque:
https://github.com/pyhandle/hpy

This API is written from scratch and currently implemented on top on the 
existing C API.

The following article is a nice introduction to the overall idea:
https://morepypy.blogspot.com/2019/12/hpy-kick-off-sprint-report.html

>From my point of view, the long term goal would be to get better performance 
>on PyPy and having a single API for C extension which would be efficient on 
>all Python implementations (not only CPython).

Currently, the C API is not only a performance issue to run C extensions on 
PyPy. It's also an issue in CPython. Because the C API leaks too many 
implementation details, we cannot experiment optimizations.

See also: https://pythoncapi.readthedocs.io/rationale.html

--

___
Python tracker 

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



[issue39575] `coverage` build target should use --coverage instead of -lgcov

2020-02-06 Thread MaskRay


New submission from MaskRay :

This allows clang to get rid of the dependency on libgcov.
When linking, GCC passes -lgcov while clang passes the path to 
libclang_rt.profile-$arch.a

--
components: Build
messages: 361528
nosy: MaskRay
priority: normal
severity: normal
status: open
title: `coverage` build target should use --coverage instead of -lgcov
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



[issue39575] `coverage` build target should use --coverage instead of -lgcov

2020-02-06 Thread MaskRay


Change by MaskRay :


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

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 58ac700fb09497df14d4492b6f820109490b2b88 by Victor Stinner in 
branch 'master':
bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)
https://github.com/python/cpython/commit/58ac700fb09497df14d4492b6f820109490b2b88


--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17769
pull_request: https://github.com/python/cpython/pull/18393

___
Python tracker 

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



[issue37413] Deprecate sys._enablelegacywindowsfsencoding()?

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-29241.

--

___
Python tracker 

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



[issue39318] NamedTemporaryFile could cause double-close on an fd if _TemporaryFileWrapper throws

2020-02-06 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
nosy: +jstasiak

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8 by Victor Stinner in 
branch 'master':
bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)
https://github.com/python/cpython/commit/daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8


--

___
Python tracker 

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



[issue39564] Parsed expression has wrong col_offset when concatenating f-strings

2020-02-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

Can I ask how pegen solved this problem? Did you move parsing of f-strings into 
the grammar?

I found my patch and I'm working on resolving merge conflicts.

--

___
Python tracker 

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



[issue39573] Make PyObject an opaque structure in the limited C API

2020-02-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17770
pull_request: https://github.com/python/cpython/pull/18394

___
Python tracker 

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



[issue39465] Design a subinterpreter friendly alternative to _Py_IDENTIFIER

2020-02-06 Thread hai shi


hai shi  added the comment:

> The GIL avoids any risk of race condition, no?

Looks like the GIL would affect performance more or less?

>_Py_IDENTIFIER() would only be a "key" and _PyUnicode_FromId() would >store 
>the value somewhere in a hash table stored in PyInterpreterState.

+1.

IMHO, for those two cases, the simplest idea is move IDENTIFIER to moduleState 
which would increase more memory usage than InterpreterState.

--

___
Python tracker 

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



[issue37815] 'Make Test' error while trying to install Python 3.7.4 on Linux Mint

2020-02-06 Thread Avery Uslaner


Avery Uslaner  added the comment:

I'm running into the same error while attempting to compile Python 3.8.1 on 
Ubuntu 18.04.

The actual test failure is this:

==
FAIL: test_errors_in_command (test.test_pdb.PdbTestCase)
--
Traceback (most recent call last):
  File "/opt/Python-3.8.1/Lib/test/test_pdb.py", line 1580, in 
test_errors_in_command
self.assertEqual(stdout.splitlines()[1:], [
AssertionError: Lists differ: ['(Pd[283 chars]efined", 'LEAVING RECURSIVE 
DEBUGGER', '(Pdb) ', '\x1b[?1034h'] != ['(Pd[283 chars]efined", 'LEAVING 
RECURSIVE DEBUGGER', '(Pdb) ']

First list contains 1 additional elements.
First extra element 9:
'\x1b[?1034h'

  ['(Pdb) *** SyntaxError: unexpected EOF while parsing',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '*** SyntaxError: unexpected EOF while parsing',
   'LEAVING RECURSIVE DEBUGGER',
   '(Pdb) ENTERING RECURSIVE DEBUGGER',
   '> (1)()',
   "((Pdb)) *** NameError: name 'doesnotexist' is not defined",
   'LEAVING RECURSIVE DEBUGGER',
-  '(Pdb) ',
?  ^

+  '(Pdb) ']
?  ^

-  '\x1b[?1034h']

--

This failure only appeared after I installed additional packages and attempted 
to reconfigure and reinstall. The install command I used was this:

sudo apt-get install libbz2-dev libreadline-gplv2-dev libncursesw5-dev 
libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev

--
nosy: +Avery Uslaner
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue39564] Parsed expression has wrong col_offset when concatenating f-strings

2020-02-06 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

> Can I ask how pegen solved this problem? Did you move parsing of f-strings 
> into the grammar?

No, we actually do a very similar thing to what ast.c does.

I think there is only one major difference between what pegen does and what 
ast.c does. If I understand correctly, fstring_compile_expr calls 
fstring_fix_node_location with parent set to the whole STRING+ node. We OTOH 
only pass as parent the current STRING token (we work with tokens returned by 
the tokenizer) and then walk the AST tree and adjust the line/col_offset based 
on that. I'm not sure that this is bug-free, but after some testing, I could 
find any obvious errors.

If you want, you can take a loot at the code on 
https://github.com/gvanrossum/pegen/pull/183.

--

___
Python tracker 

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



[issue39576] Surprising MemoryError in `decimal` with MAX_PREC

2020-02-06 Thread Tim Peters


New submission from Tim Peters :

Here under Python 3.8.1 on 64-bit Windows:

>>> import decimal
>>> c = decimal.getcontext()
>>> c.prec = decimal.MAX_PREC
>>> i = decimal.Decimal(4)
>>> i / 2
Traceback (most recent call last):
  File "", line 1, in 
MemoryError

Of course the result is exactly 2.  Which I have enough RAM to hold ;-)

The implicit conversion is irrelevant:

>>> i / decimal.Decimal(2)
Traceback (most recent call last):
  File "", line 1, in 
MemoryError

Floor division instead works fine:

>>> i // 2
Decimal('2')

--
components: Library (Lib)
messages: 361536
nosy: tim.peters
priority: normal
severity: normal
status: open
title: Surprising MemoryError in `decimal` with MAX_PREC
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



[issue39576] Surprising MemoryError in `decimal` with MAX_PREC

2020-02-06 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
nosy: +BTaskaya

___
Python tracker 

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



[issue37815] 'Make Test' error while trying to install Python 3.7.4 on Linux Mint

2020-02-06 Thread Avery Uslaner


Avery Uslaner  added the comment:

FYI, the problem seems isolated to the libreadline-gplv2-dev package.

--

___
Python tracker 

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



  1   2   >