[issue28557] error message for bad raw readinto

2018-06-07 Thread David Szotten


Change by David Szotten :


--
pull_requests: +7121
stage:  -> patch review

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2014-06-11 Thread David Szotten

New submission from David Szotten:

```
>>> __import__('fabric.', fromlist=[u'api'])
Traceback (most recent call last):
  File "", line 1, in 
```

accidentally ended up with something like this via some module that was using 
`unicode_literals`. stumped me for a second until i realised that my variable 
was a string, but not `str`. would be nice with a custom error message if this 
is a unicode string, explicitly mentioning that these must not be unicode or 
similar

--
messages: 220267
nosy: davidszotten
priority: normal
severity: normal
status: open
title: "TypeError: Item in ``from list'' not a string"  message
type: enhancement
versions: Python 2.7

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2014-08-28 Thread David Szotten

David Szotten added the comment:

after some trial and error it only appears to break for 3rd party packages (all 
20 or so i happened to have installed), whereas everything i tried importing 
from the standard library worked fine

```
>>> __import__('requests.', fromlist=[u'get'])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Item in ``from list'' not a string

>>> __import__('os.', fromlist=[u'path'])
/lib/python2.7/os.pyc'>
```

--

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2014-08-28 Thread David Szotten

David Szotten added the comment:

first ever patch to python, so advice on the patch would be appreciated

found an example in the stdlib that triggers bug (used in test):

`__import__('encodings', fromlist=[u'aliases'])`

--
keywords: +patch
Added file: http://bugs.python.org/file36500/fromlist.patch

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2014-08-29 Thread David Szotten

David Szotten added the comment:

not sure i follow. we need a different message if e.g. an integer is passed in

updated the patch to only run the unicode check for non-strings

or do you have a suggestion for an error message that works nicely in both 
cases?

--
Added file: http://bugs.python.org/file36501/fromlist2.patch

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



[issue26232] Mock(spec=spec) has no effect

2016-01-28 Thread David Szotten

New submission from David Szotten:

Unless i misunderstand the docs, i would expect `Mock(foo)` to have the same 
effect as `create_autospec(foo)`, but that doesn't appear to be the case:

>>> m1 = mock.Mock(spec=lambda: None)
>>> m2 = mock.create_autospec(spec=lambda: None)
>>> m1(1)

>>> m2(1)
# snip
TypeError: too many positional arguments

--
components: Library (Lib)
messages: 259130
nosy: davidszotten
priority: normal
severity: normal
status: open
title: Mock(spec=spec) has no effect
type: behavior
versions: Python 3.5

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



[issue26232] Mock(spec=spec) has no effect

2016-01-28 Thread David Szotten

David Szotten added the comment:

thanks, and apologies for the noise

--

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



[issue28557] error message for bad raw readinto

2016-10-29 Thread David Szotten

New submission from David Szotten:

Was just tracking down a bug in eventlet, which manifested as "OSError: raw 
readinto() returned invalid length -1 (should have been between 0 and 8192)"

I was misled for a while by the fact that readinto was in fact returning b'', 
not -1. This improves the error message in that case by including the TypeError 
from the failed conversion of b'' to an int.

Would prefer to still return an OSError with the TypeError as a cause, but 
couldn't figure out how to do that. Hints/help would be appreciated.

--
components: IO
files: readinto_error.patch
keywords: patch
messages: 279685
nosy: davidszotten
priority: normal
severity: normal
status: open
title: error message for bad raw readinto
versions: Python 3.7
Added file: http://bugs.python.org/file45265/readinto_error.patch

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