[issue39720] Signature.bind TypeErrors could be more helpful

2020-02-21 Thread Frazer McLean


New submission from Frazer McLean :

Signature.bind does not tell you if a missing argument is keyword-only for 
example. I created the following snippet to examine the differences:

import inspect

def run(f):
try:
f()
except TypeError as exc:
print(exc.args[0])
else:
raise RuntimeError('Expected to raise!')
sig = inspect.signature(f)
try:
sig.bind()
except TypeError as exc:
print(exc.args[0])
else:
raise RuntimeError('Expected to raise!')
print()

@run
def f1(pos_only, /): ...

@run
def f2(pos_or_kw): ...

@run
def f3(*, kw_only): ...

Output on current 3.9 master:

f1() missing 1 required positional argument: 'pos_only'
missing a required argument: 'pos_only'

f2() missing 1 required positional argument: 'pos_or_kw'
missing a required argument: 'pos_or_kw'

f3() missing 1 required keyword-only argument: 'kw_only'
missing a required argument: 'kw_only'

I am willing to create a PR so that the TypeError for f3 says "missing a 
required keyword-only argument: 'kw_only'", if this would be accepted.

--
components: Library (Lib)
messages: 362439
nosy: RazerM
priority: normal
severity: normal
status: open
title: Signature.bind TypeErrors could be more helpful
type: enhancement

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



[issue30814] Import dotted name as alias breaks with concurrency

2017-06-30 Thread Frazer McLean

Changes by Frazer McLean <fra...@frazermclean.co.uk>:


--
nosy: +RazerM

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



[issue25538] Traceback from __exit__ method is misleading

2017-03-29 Thread Frazer McLean

Changes by Frazer McLean <fra...@frazermclean.co.uk>:


--
nosy: +RazerM

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



[issue29922] error message when __aexit__ is not async

2017-03-29 Thread Frazer McLean

Changes by Frazer McLean <fra...@frazermclean.co.uk>:


--
nosy: +RazerM

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



[issue29392] msvcrt.locking crashes python

2017-01-30 Thread Frazer McLean

Frazer McLean added the comment:

I ran it on AppVeyor to double check, the crash appears from 3.5 onwards as I 
saw on my computer.

https://ci.appveyor.com/project/RazerM/issue29392/build/3

--

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



[issue29392] msvcrt.locking crashes python

2017-01-30 Thread Frazer McLean

New submission from Frazer McLean:

On 3.5.2 and 3.5.3, but not 3.4.3 or 2.7.10 (Windows 64-bit), the third line 
causes Python to crash with exit code 0xC417.

import msvcrt
fp = open('file.txt', 'w')
msvcrt.locking(fp.fileno(), msvcrt.LK_NBLCK, -1)
print('End')

I came across this in the portalocker module. I don't think -1 is a valid third 
argument, but it doesn't raise an exception on Python 3.4 or 2.7.

--
components: Windows
messages: 286495
nosy: RazerM, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: msvcrt.locking crashes python
type: crash
versions: Python 3.5

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



[issue7434] general pprint rewrite

2016-12-13 Thread Frazer McLean

Changes by Frazer McLean <fra...@frazermclean.co.uk>:


--
nosy: +RazerM

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



[issue26423] __len__() returns 32 bit int on windows leading to overflows

2016-02-23 Thread Frazer McLean

Changes by Frazer McLean <fra...@frazermclean.co.uk>:


--
nosy: +RazerM

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



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread Frazer McLean

New submission from Frazer McLean:

In Lib/test/test_contextlib.py, there is a bug in the nested usage part of the 
following function:

def test_cm_is_reentrant(self): 
ignore_exceptions = suppress(Exception) 
with ignore_exceptions: 
pass 
with ignore_exceptions: 
len(5) 
with ignore_exceptions: 
1/0 
with ignore_exceptions: # Check nested usage 
len(5)

Specifically, the final 2 lines aren't reached since the exception raised by 
1/0 exits the context manager.

--
components: Tests
messages: 252382
nosy: RazerM, ncoghlan, yselivanov
priority: normal
severity: normal
status: open
title: contextlib.suppress not tested for nested usage
type: behavior
versions: Python 3.4, Python 3.5

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



[issue25322] contextlib.suppress not tested for nested usage

2015-10-06 Thread Frazer McLean

Frazer McLean added the comment:

I may not have been clear—I understand how context managers work with 
exceptions.

I'm just pointing out that the nested context manager isn't called, so those 
final two lines aren't testing anything, right?

--

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