[issue44792] Improve syntax errors for invalid if expressions

2021-07-31 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue44792] Improve syntax errors for invalid if expressions

2021-07-31 Thread Miguel Brito


New submission from Miguel Brito :

Hi, I was playing around with Python's grammar and noticed that the error 
message for if expression is generic, so not very informative.

I decided to improve it slightly.

*From*:

```
>>> a = 42 if True
  File "", line 1
a = 42 if True
  ^
SyntaxError: invalid syntax
```

*To*:

```
$ ./python
Python 3.10.0b4 (tags/v3.10.0b4-dirty:2ba4b20854, Jul 31 2021, 11:50:15) [GCC 
7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 42 if True
  File "", line 1
a = 42 if True
  ^
SyntaxError: invalid syntax. Conditional expression expected an 'else' here.
```

--
messages: 398633
nosy: miguendes
priority: normal
severity: normal
status: open
title: Improve syntax errors for invalid if expressions

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



[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Miguel Brito


Miguel Brito  added the comment:

Thanks for your comments, folks! I really appreciate it.

I left a comment about this issue in the PR thread: 
https://github.com/python/cpython/pull/26207#issuecomment-843531990

--

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



[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue44166] Make IndexError messages for list more informative

2021-05-18 Thread Miguel Brito

New submission from Miguel Brito :

I've noticed that in people will often ask for help on forums or stackoverflow 
to better understand the causes of
IndexErrors [1][2][3].
> The error message line for an IndexError doesn’t give you great 
> information.[1]

Currently, when we access a out of bounds position we get something along the 
lines:
Traceback (most recent call last):

>>> a = [0, 10, 20, 30, 40]
>>> a[5]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list index out of range
>>> a.pop(6)
Traceback (most recent call last):
  File "", line 1, in 
IndexError: pop index out of range
>>> a[6] = 7
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list assignment index out of range
>>> a = []
>>> a[2]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list index out of range


These error messages are too broad and doesn't inform the current length of the 
list, nor the index that was fed to it.

To improve the debugging experience in both interactive and non-interactive 
code,
I propose to offer a richer and more informative error messages. I think this 
can help users, especially newer and less
experienced folks, debug their code.


>>> a = [0, 10, 20, 30, 40]
>>> a[5]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list index out of range, the len is 5 so index must be in -5..4, 
got 5
>>> a[-6]
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list index out of range, the len is 5 so index must be in -5..4, 
got -6
>>> a.pop(6)
Traceback (most recent call last):
  File "", line 1, in 
IndexError: pop index out of range, the len is 5 so index must be in -5..4, got 
6
>>> a[6] = 7
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list assignment index out of range, the len is 5 so index must be 
in -5..4, got 6
>>> a = []
>>> a[2] = 0
Traceback (most recent call last):
  File "", line 1, in 
IndexError: list assignment index out of range, got index 2 but the list is 
empty


These proposed messages are inspired by other languages, with the difference 
that in Python we can have negative index.
So informing the allowed ranges is a plus.

These improvements are not restricted to list, so it can be applied to strings 
and tuples as well, or any other indexable
object.

I have a branch ready, looking forward to hearing from you!

[1] 
https://stackoverflow.com/questions/1098643/indexerror-list-index-out-of-range-and-python
[2] 
https://stackoverflow.com/questions/16005707/index-error-list-index-out-of-range-python
[3] https://realpython.com/python-traceback/#indexerror

--
components: Interpreter Core
messages: 393858
nosy: miguendes
priority: normal
severity: normal
status: open
title: Make IndexError messages for list more informative
type: enhancement
versions: Python 3.11

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



[issue44137] importlib.resources.path raises RuntimeError when FileNotFoundError is raise in context manager

2021-05-15 Thread Miguel Brito


Miguel Brito  added the comment:

I can reproduce this. From what I can see the issue is that 
`importlib.resources.path` intentionally suppresses `FileNotFoundError` errors.

https://github.com/python/cpython/blob/main/Lib/importlib/resources.py#L138

Based on `importlib.resources.path` docstring I think this is to avoid raising 
an exception if the file is deleted before the context manager exits.

On contextlib.py, since type is not None, it will try to throw the exception 
but since it's supressed nothing will happen and the code will reach the end by 
raising the RuntimeError.

https://github.com/python/cpython/blob/main/Lib/contextlib.py#L151

If I'm not mistaken, this is the test that verifies that behaviour: 
https://github.com/python/cpython/blob/main/Lib/test/test_importlib/test_path.py#L51


I'm not a core dev but it looks like it's an intentional behaviour.

Maybe the docs should be more clear about this. It's not obvious to me when I 
read the docs.

--
nosy: +miguendes

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



[issue32133] documentation: numbers module nitpick

2021-05-15 Thread Miguel Brito


Miguel Brito  added the comment:

@rhettinger added your suggestion.

--

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



[issue32133] documentation: numbers module nitpick

2021-05-15 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue44095] Add suffix property to zipfile.Path

2021-05-14 Thread Miguel Brito


Miguel Brito  added the comment:

I prototyped something by adding `suffix`, `suffixes`, and `stem`. To me these 
are the most obvious ones and would be useful right away.

Regarding the others I'm not so sure. It seems that zipfile.Path is just a 
convenient class to provide basic navigational operations. It's not meant to be 
100% consistent with pathlib.Path. 

In any case, it'd nice to discuss it.


Here it is: https://github.com/python/cpython/pull/26129

--

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



[issue44095] Add suffix property to zipfile.Path

2021-05-14 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue44095] Add suffix property to zipfile.Path

2021-05-14 Thread Miguel Brito


Miguel Brito  added the comment:

+1. 

The docstring says:
```
class Path:
"""
A pathlib-compatible interface for zip files.
```
but only a few methods are supported. It'd be nice to have at least `stem`, 
`parents`, `suffixes`, `parts`, which IMHO would make sense here.

I'd love to work on this if the Core Devs think it makes sense and if OP is not 
doing so also.

--
nosy: +miguendes

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



[issue32133] documentation: numbers module nitpick

2021-05-14 Thread Miguel Brito


Miguel Brito  added the comment:

Seen that nobody is working on this I transformed the suggestion into a PR.

--
nosy: +miguendes

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



[issue44110] Improve string's __getitem__ error message

2021-05-11 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue44110] Improve string's __getitem__ error message

2021-05-11 Thread Miguel Brito


New submission from Miguel Brito :

I noticed that __getitem__ message, although helpful, could be improved a bit 
further. This will also make it consistent with other error messages such as 
the ones raised by `str.count`, `str.split`, `str.endswith` and so many others.

Currently, the error message goes like this: "TypeError: string indices must be 
integers" but we could specify the type of the object passed as argument to 
__getitem__. So, for example:

```
>>> idx = '1'
>>> s = 'abcde'
>>> s[idx]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: string indices must be integers, not 'str'
```

This makes easier to debug and it is also consistent with other methods:

>>> "alala".count(8)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: must be str, not int

>>> "lala|helo".split(1)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: must be str or None, not int

>>> 1 in "lala"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'in ' requires string as left operand, not int

>>> "lala|helo".split(object())
Traceback (most recent call last):
  File "", line 1, in 
TypeError: must be str or None, not object

--
components: Interpreter Core
messages: 393473
nosy: miguendes
priority: normal
severity: normal
status: open
title: Improve string's __getitem__ error message
type: enhancement
versions: Python 3.10, Python 3.11

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



[issue43124] [security] smtplib multiple CRLF injection

2021-05-08 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue43124] [security] smtplib multiple CRLF injection

2021-05-07 Thread Miguel Brito


Miguel Brito  added the comment:

If there's no one working on it I'd be happy to prepare a fix.

--
nosy: +miguendes

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



[issue44061] Regression in pkgutil: iter_modules stopped taking Path argument in python 3.8.10 and 3.9.5

2021-05-07 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue44061] Regression in pkgutil: iter_modules stopped taking Path argument in python 3.8.10 and 3.9.5

2021-05-06 Thread Miguel Brito


Miguel Brito  added the comment:

I can reproduce it on latest master running on Linux.

steve.dower: I wrote some tests and wrapping get_importer argument with 
os.fsdecode() fixes it.

I'm happy to open an PR, just let me know or if OP is not willing to do so 
either.

--
nosy: +miguendes

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



[issue44030] Markup with_traceback code example

2021-05-05 Thread Miguel Brito


Miguel Brito  added the comment:

If we make it a code snippet it works. Just adding a `::` after the paragraph.

Here's a print on Firefox locally: https://imgur.com/a/g2vsqf2

I created a PR for that if you think it's a good solution, feel free to merge :)

--

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



[issue44030] Markup with_traceback code example

2021-05-05 Thread Miguel Brito


Change by Miguel Brito :


--
keywords: +patch
nosy: +miguendes
nosy_count: 2.0 -> 3.0
pull_requests: +24596
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/25929

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



[issue43952] Multiprocessing UNIX socket connection: client freeze if authkey is an empty byte string

2021-05-03 Thread Miguel Brito


Miguel Brito  added the comment:

I had a look at the HMAC RFC and apparently empty bytes sequence can be used as 
secret key.

"The definition of HMAC requires a cryptographic hash function, which
we denote by H, and a secret key K. 

...

The authentication key K can be of any length up to B, the
block length of the hash function."
   
https://tools.ietf.org/html/rfc2104.html#section-2

Assuming that is the case, the fix would be to change the Listener to:

```
if self._authkey is not None:
deliver_challenge(c, self._authkey)
answer_challenge(c, self._authkey)
return c
```


I created a PR for that, if anyone can review it, I appreciate it.
https://github.com/python/cpython/pull/25845

--

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



[issue44018] Bug in random.seed

2021-05-03 Thread Miguel Brito


Miguel Brito  added the comment:

The problem is that random seed will do

```
if isinstance(a, str):
a = a.encode()
a += _sha512(a).digest()
a = int.from_bytes(a, 'big')
```

and that will modify the bytearray in place.

>>> a = bytearray("1234", "utf-8")
>>> a += b"digest"
>>> a
bytearray(b'1234digest')


IMHO, seed shouldn't modify the input. Since str, and bytes are immutable that 
will only happen when passing a bytearray which is not consistent.

--
nosy: +miguendes

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



[issue43952] Multiprocessing UNIX socket connection: client freeze if authkey is an empty byte string

2021-05-03 Thread Miguel Brito


Change by Miguel Brito :


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

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



[issue43913] unittest module cleanup functions not run unless tearDownModule() is defined

2021-05-03 Thread Miguel Brito


Miguel Brito  added the comment:

Thanks terry.reedy, actually I read it in the mailing list, someones comment 
not a guideline.

Do you mind having a look at the PR?

--

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



[issue43952] Multiprocessing UNIX socket connection: client freeze if authkey is an empty byte string

2021-05-01 Thread Miguel Brito


Miguel Brito  added the comment:

I tried debugging this and from what I can see it's because there's an if that 
checks if the authkey is not None in the Client constructor:

https://github.com/python/cpython/blob/v3.9.4/Lib/multiprocessing/connection.py#L512

```
if authkey is not None:
answer_challenge(c, authkey)
deliver_challenge(c, authkey)
```

Whereas in the Listener, the check is different:

https://github.com/python/cpython/blob/v3.9.4/Lib/multiprocessing/connection.py#L469

```
c = self._listener.accept()
if self._authkey:
deliver_challenge(c, self._authkey)
answer_challenge(c, self._authkey)
return c
```

If I change the Listener to:

```
if self._authkey is not None:
deliver_challenge(c, self._authkey)
answer_challenge(c, self._authkey)
return c
```

it works.


The docs say:

"""
If authkey is given and not None, it should be a byte string and will be used 
as the secret key for an HMAC-based authentication challenge. No authentication 
is done if authkey is None. AuthenticationError is raised if authentication 
fails. See Authentication keys.
"""


Now the question is, if None is OK because no auth will be done what about 
empty bytes? Can it be used as secret key? If empty bytes is not accepted 
shouldn't Listener/Client raise an exception in the constructor?

--
nosy: +miguendes

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



[issue43869] Fix documentation of epoch/time.time

2021-05-01 Thread Miguel Brito


Miguel Brito  added the comment:

Seen that no one is working on this issue I created an PR to clarify the docs.

https://github.com/python/cpython/pull/25777

--

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



[issue43869] Fix documentation of epoch/time.time

2021-05-01 Thread Miguel Brito


Change by Miguel Brito :


--
keywords: +patch
nosy: +miguendes
nosy_count: 4.0 -> 5.0
pull_requests: +24467
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25777

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



[issue43913] unittest module cleanup functions not run unless tearDownModule() is defined

2021-05-01 Thread Miguel Brito


Miguel Brito  added the comment:

I was reading through the dev guide and past issues and I didn't know it's 
advisable to give the author of the issue a chance to submit the PR.

Sorry about that, you can close mine in this case.

--

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



[issue43871] urllib.parse.urlparse doesn't check port

2021-05-01 Thread Miguel Brito


Miguel Brito  added the comment:

I also think the validation logic should be ran as early as possible.

I gave it a shot and implemented it. 

I appreciate any reviews: https://github.com/python/cpython/pull/25774

Got some ideas from https://github.com/python/cpython/pull/16780

--

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



[issue43871] urllib.parse.urlparse doesn't check port

2021-05-01 Thread Miguel Brito


Change by Miguel Brito :


--
keywords: +patch
nosy: +miguendes
nosy_count: 4.0 -> 5.0
pull_requests: +24464
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25774

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



[issue43978] Incorrect "versionadded" info in typing.NoReturn documentation

2021-04-30 Thread Miguel Brito


Miguel Brito  added the comment:

This looks like a leftover from a merge conflict. Or a bad copy and paste 
indeed.

I've checked the file prior to the PR and the was no version 3.5.4 tag.

I've opened a PR to fix this: https://github.com/python/cpython/pull/25760

--

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



[issue43978] Incorrect "versionadded" info in typing.NoReturn documentation

2021-04-30 Thread Miguel Brito


Change by Miguel Brito :


--
keywords: +patch
nosy: +miguendes
nosy_count: 3.0 -> 4.0
pull_requests: +24450
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/25760

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



[issue43913] unittest module cleanup functions not run unless tearDownModule() is defined

2021-04-28 Thread Miguel Brito


Miguel Brito  added the comment:

Hello, first time here. I created an PR for that. Managed to reproduce the 
issue both manually and via unit test.

I hope there's no edge case but all tests pass on my machine.

--
nosy: +miguendes

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



[issue40515] test_ssl.py hangs with SSL 1.1 built with no threads

2020-05-05 Thread Miguel


Miguel  added the comment:

I built with 'no-threads' option.
I understand if you no longer wish to support non-threaded SSL. 
But it just seemed to me that you could if you protected the SSL API calls with 
locking since I can get all your ssl tests to work with this minor change.

--

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



[issue40515] test_ssl.py hangs with SSL 1.1 built with no threads

2020-05-05 Thread Miguel


New submission from Miguel :

Hello, this is my first python bug report!

I've been running builds of Python 3.7.x on CentOS Linux release 7.7 
(64bit/Intel Core
2 Duo) 
and I ran into hangs with test_ssl.py when using latest SSL 1.1.1d sources.

I've done a full compilation from source for Python 3.7.7 and SSL 1.1 in my
workspaces.

>From what I can tell the problem is when SSL 1.1 is built with no threading
there is no locking enabled by python.

This one line change will make the hangs in test_ssl.py  go away:

Index: Modules/_ssl.c

--- Modules/_ssl.c  (revision 70)
+++ Modules/_ssl.c  (working copy)
@@ -5875,7 +5875,7 @@
 if (!_setup_ssl_threads()) {
 return NULL;
 }
-#elif OPENSSL_VERSION_1_1 && defined(OPENSSL_THREADS)
+#elif OPENSSL_VERSION_1_1
 / OpenSSL 1.1.0 builtin thread support is enabled /
 _ssl_locks_count++;

# endif

There appears to be an assumption in _ssl.c and test_ssl.y that SSL 1.1 will be
threaded
but this may not be true (as in my case).

Appreciate any feedback. Thanks!

--
assignee: christian.heimes
components: SSL
messages: 368143
nosy: christian.heimes, mig28suarez
priority: normal
severity: normal
status: open
title: test_ssl.py hangs with SSL 1.1 built with no threads
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2020-04-03 Thread Miguel Amaral


Miguel Amaral  added the comment:

A related issue(which I believe has no topic in this forum yet) is substituting 
an expression that results in a multiline string into a multiline f-string 
while matching its indentation.
If a new type of string prefix is made to auto-dedent, maybe the substitutions 
should match the local indentation.
Some related stackoverflow posts:

https://stackoverflow.com/questions/36739667/python-templates-for-generating-python-code-with-proper-multiline-indentation

https://stackoverflow.com/a/57189263/2976410

I.e. ideally we would have:
```python
def make_g_code():
  nl='\n'
  return d"""\
def g():
  {nl.join(something(i) for i in range(n))}
  return something_else
"""
```
This still has issues. Newline needs to be put into a variable, for instance. 
In the case of using this template for languages, great many use braces for 
delimiting blocks and those need to be escaped inside f-strings.

An implementation that works with spaces only (does not suit my case where 
mixed indentation is possible) is here:

http://code.activestate.com/recipes/578835-string-templates-with-adaptive-indenting/

Please let me know if this is the wrong place to comment on this issue.

--
nosy: +Miguel Amaral

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



[issue36085] Enable better DLL resolution

2020-03-27 Thread David Miguel Susano Pinto


David Miguel Susano Pinto  added the comment:

I have just found out that commit 2438cdf0e93 which added the winmode argument 
and the documentation for it disagree. Documentation states that default is 
zero while the real default in code is None.

I have opened PR 19167 on github to address it

--
message_count: 60.0 -> 61.0
nosy: +carandraug
nosy_count: 14.0 -> 15.0
pull_requests: +18563
pull_request: https://github.com/python/cpython/pull/19167

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



[issue39829] __len__ called twice in the list() constructor

2020-03-02 Thread Kim-Adeline Miguel


New submission from Kim-Adeline Miguel :

(See #33234)

Recently we added Python 3.8 to our CI test matrix, and we noticed a possible 
backward incompatibility with the list() constructor.

We found that __len__ is getting called twice, while before 3.8 it was only 
called once.

Here's an example:

class Foo:
 def __iter__(self):
  print("iter")
  return iter([3, 5, 42, 69])

 def __len__(self):
  print("len")
  return 4

Calling list(Foo()) using Python 3.7 prints:

iter
len

But calling list(Foo()) using Python 3.8 prints:

len
iter
len

It looks like this behaviour was introduced for #33234 with PR GH-9846. 

We realize that this was merged a while back, but at least we wanted to make 
the team aware of this change in behaviour.

--
components: Interpreter Core
messages: 363186
nosy: brett.cannon, eric.snow, kimiguel, pablogsal, rhettinger
priority: normal
severity: normal
status: open
title: __len__ called twice in the list() constructor
type: behavior
versions: Python 3.8, Python 3.9

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



[issue35338] set union/intersection/difference could accept zero arguments

2018-11-28 Thread David Miguel Susano Pinto


New submission from David Miguel Susano Pinto :

set union, intersection, difference methods accept any non-zero number of sets 
and return a new set instance, like so:

>>> a = set([1, 2])
>>> b = set([1, 3])
>>> c = set([3, 5])
>>> set.union(a, b, c)
{1, 2, 3, 5}

even if it's only one argument:

>>> set.union(a)
{1, 2}

I think it would be nice if zero arguments were not an error:

>>> set.union()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: descriptor 'union' of 'set' object needs an argument

This would allow to handle any sequence of sets which otherwise requires this:

if len(sequence):
return set.union(*sequence)
else:
return set()

--
messages: 330601
nosy: carandraug
priority: normal
severity: normal
status: open
title: set union/intersection/difference could accept zero arguments
type: enhancement
versions: Python 3.7

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



[issue33649] asyncio docs overhaul

2018-09-18 Thread Miguel Ángel

Change by Miguel Ángel :


--
pull_requests: +8811

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



[issue33649] asyncio docs overhaul

2018-09-17 Thread Miguel Ángel

Change by Miguel Ángel :


--
pull_requests: +8808

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



[issue34718] Syntax error on factorial example

2018-09-17 Thread Miguel Ángel

Miguel Ángel  added the comment:

Too trivial to require an issue. Sorry, I'm newbie here :)

--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

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



[issue34718] Syntax error on factorial example

2018-09-17 Thread Miguel Ángel

New submission from Miguel Ángel :

In the example on 
https://docs.python.org/3/library/asyncio-task.html#running-tasks-concurrently, 
there is a double closing parenthesis, but just one is needed for the `gather` 
method. This makes the example to fail.

--
assignee: docs@python
components: Documentation
messages: 325614
nosy: docs@python, magmax
priority: normal
severity: normal
status: open
title: Syntax error on factorial example
type: enhancement
versions: Python 3.7, Python 3.8

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



[issue30508] "Task exception was never retrieved" reported for a canceled task

2017-05-29 Thread Miguel Grinberg

New submission from Miguel Grinberg:

I am seeing a strange issue that occurs when a task that is awaiting an 
asyncio.wait_for() is cancelled. I created a simple example that I think 
demonstrates the issue, even though it isn't exactly how it manifests on my 
application.

When I run the attached script never-retrieved.py I get the following error:

Task exception was never retrieved
future:  
exception=ZeroDivisionError('division by zero',)>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
  File "never-retrieved.py", line 5, in crash
a = 1/0
ZeroDivisionError: division by zero

You can see in the script that the future was cancelled, but the cancel() call 
was made after the task finished in a zero division error. I think the cancel() 
call should update the internal state of the future so that the "exception was 
never retrieved" error does not appear.

My application has a more complex setup that I have been unable to reproduce 
with a simple example. I have a task that is waiting on asyncio.wait_for(fut, 
timeout), with fut subsequently waiting on a websocket server's receive 
function. When the websocket client closes the connection, a bunch of 
cancellations happen, but this future inside the wait_for call crashes before 
wait_for gets to call cancel() on it. Even though I need to investigate this 
crash, the fact is that wait_for did cancel this future, but because it already 
ended in an error the "never retried" error is reported anyway.

--
components: asyncio
files: never-retrieved.py
messages: 294732
nosy: Miguel Grinberg, yselivanov
priority: normal
severity: normal
status: open
title: "Task exception was never retrieved" reported for a canceled task
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file46911/never-retrieved.py

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



[issue29108] Python 3.6.0 multiprocessing map_async callback

2016-12-29 Thread Jose Miguel Colella

Jose Miguel Colella added the comment:

Hello David,
Thanks for your response. Improvements to the documentation could clear this 
misunderstanding. I had initially believed that after transforming with the 
function passed to the map, it would use the callback on each of the result 
arguments. 
Just to understand the use case of the callback. So basically it should not 
return anything and be a simple print?

--

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



[issue29108] Python 3.6.0 multiprocessing map_async callback

2016-12-29 Thread Jose Miguel Colella

Jose Miguel Colella added the comment:

The result is:
Here: [1, 4, 9]
[1, 4, 9]

--

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



[issue29108] Python 3.6.0 multiprocessing map_async callback

2016-12-29 Thread Jose Miguel Colella

New submission from Jose Miguel Colella:

Hello I am trying to use the callback for the map_async method for Pool, but 
have found a bug. In the below code, only the print statement is carried out, 
the return is completely ignored. Is this working as designed or is this a bug?

from multiprocessing import Pool


def f(x):
return x * x


def s(x):
print(f'Here: {x}')
return type(x)


if __name__ == '__main__':
with Pool(5) as p:
result = p.map_async(f, [1, 2, 3], callback=s)
q = result.get()
print(q)

--
components: Library (Lib)
files: main2.py
messages: 284295
nosy: Jose Miguel Colella
priority: normal
severity: normal
status: open
title: Python 3.6.0 multiprocessing map_async callback
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file46084/main2.py

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



[issue28498] tk busy command

2016-10-29 Thread Miguel

Miguel added the comment:

Why dont we do the job well from the beginning and refactor _configure() and 
adapt other dependent code? It's not so complicated to change the dependent 
code. Many people around the world use Tkinter.

--

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



[issue28498] tk busy command

2016-10-26 Thread Miguel

Miguel added the comment:

Using the same reasoning applied to tk_busy_hold(), we have to change also 
these methods:
selection_set(self, first, last=None) -> selection_set(self, **kw)
coords(self, value=None) -> coords(self, **kw)
identify(self, x, y) -> identity(self, **kw)
delete(self, index1, index2=None) -> delete(self, **kw)
mark_set(self, markName, index) -> ...
mark_unset(self, *markNames) -> ...


and many other to adapt to future changes.

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

In the C source code that I am reading of tkinter: _tkinter.c. It seems that 
these parameters are not used:
- wantobjects
- useTk
- syn 
- use

It seems that it's dead code. I hope that somebody can tell me whether I am 
right. I suppose that now Python returns always Python objects instead of 
strings. For this reason, wantobjects is not any more necessary. This is the C 
code of Tkinter_Create that I am reading:

static PyObject *
Tkinter_Create (self, args)
 PyObject *self;
 PyObject *args;
{
  char *screenName = NULL;
  char *baseName = NULL;
  char *className = NULL;
  int interactive = 0;

  baseName = strrchr (Py_GetProgramName (), '/');
  if (baseName != NULL)
baseName++;
  else
baseName = Py_GetProgramName ();
  className = "Tk";
  
  if (!PyArg_ParseTuple (args, "|zssi",
 , , , ))
return NULL;

  return (PyObject *) Tkapp_New (screenName, baseName, className, 
 interactive);
}

And this is the call to Tkinter_Create in Tkinter.py:
   self.tk = _tkinter.create(screenName, baseName, className, interactive, 
wantobjects, useTk, sync, use)

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

It's not defined the semantics for things different than strings.

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Hi,
I think that it's behaving well. Where is the bug here?
root.tk.getboolean(root.tk_strictMotif())

getboolean() converts Tcl strings to Boolean Python values according to the 
definition of True and False in Tcl.

getboolean is only used for converting strings to boolean Python values. It's 
undefined the behaviour for other things different than strings.

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Yes, its true. The semantics of configure() is affected then if I ommit _flaten.

I like elegancy and to dont repeat myself for this reason I made that 
suggestion. But the drawback is that maybe other external code that shouldn't 
rely on internal methods like _configure, would be affected.

I think that you agree with me about the fact there is no bug with getboolean 
and it has the expected behaviour.

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Hi Serhiy,
I totally disagree of this change on your patch:

+def tk_busy_status(self):
+'''Returns the busy status of this window.
+If the window presently can not receive user interactions,
+True is returned, otherwise False.'''
+return((self.tk.getboolean(self.tk.call(
+'tk', 'busy', 'status', self._w)) and True) or False)

tk_busy_status should return the returned value of self.tk.getboolean directly 
like other methods in Tkinter using self.tk.getboolean.

There is no test that shows that self.tk.getboolean is buggy.

This is the right implementation:
def tk_busy_status(self):
 '''Returns the busy status of this window.
If the window presently can not receive user interactions,
True is returned, otherwise False.'''
return self.tk.getboolean(self.tk.call('tk', 'busy', 'status', self._w))

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

This is my point of view:
These functions are easy to change: 
itemconfigure(), entryconfigure(), image_configure(), tag_configure() and 
window_configure()

It's only to add self._w in the proper place. Only one line per method

Other third party extensions should not rely on _configure() because it's an 
internal method (it starts with underscore). We have rights to change the 
semantics of this internal method in any moment without notification.

--
components: +Installation -Library (Lib), Tkinter

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Your proposal also makes an extra computation: an item (not) belongs to a list

   if not self._w in cmd:
  cmd = _flatten((self._w, cmd))

Also it's more efficient to use this than the function _flaten() in that 
situation:
   
   if not self._w in cmd:
  cmd = (self._w,) + cmd

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

It's also necessary in the same way to adapt these functions:
itemconfigure(), entryconfigure(), image_configure(), tag_configure() and 
window_configure().

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Yes, sure. It will break code. Maybe it's better to be explicit than implicit 
(another Python motto). It's also necessary to change configure(). This is the 
code for my version of _configure() and configure():
def _configure(self, cmd, cnf, kw):
"""Internal function."""
if kw:
cnf = _cnfmerge((cnf, kw))
elif cnf:
cnf = _cnfmerge(cnf)
if cnf is None:
return self._getconfigure(cmd)
if isinstance(cnf, str):
return self._getconfigure1(cmd + ('-'+cnf,))
self.tk.call(cmd + self._options(cnf))


# These used to be defined in Widget:
def configure(self, cnf=None, **kw):
"""Configure resources of a widget.

The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method keys.
"""
return self._configure((self._w, 'configure'), cnf, kw)

The semantics of getboolean is clear for me: Transform a true and false value 
in *Tcl* to an integer value: 1 or 0:

def getboolean(s):
"""Convert true and false to integer values 1 and 0."""
return _default_root.tk.getboolean(s)

I think that the C implementation of getboolean is right. 
The true values for Tcl are: 1, true, yes. 
And the false values are: 0, false, no

>>> tk.getboolean("true")
True
>>> tk.getboolean("false")
False
>>> tk.getboolean("0")
False
>>> tk.getboolean("1")
True
>>> tk.getboolean("yes")
True
>>> tk.getboolean("no")
False

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Ok. Maybe the bug is here:

   Misc.getboolean()

This is the required change:
def getboolean(self, s):
"""Return a boolean value for Tcl boolean values true and false given 
as parameter."""
return bool(self.tk.getboolean(s))

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Tcl_GetBoolean() converts a boolean string to an integer 0 or 1:
https://www.tcl.tk/man/tcl8.6/TclLib/GetInt.htm

and then Py_BuildValue() converts the integer to a Python object:
https://docs.python.org/2/c-api/arg.html

--

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



[issue28498] tk busy command

2016-10-23 Thread Miguel

Miguel added the comment:

Hi klappnase,
you are right with the function tk_busy_configure(). Maybe there is a little 
bit of code duplicated. I think that it's better to directly change the Tkinter 
function _configure() to make it more general:
def _configure(self, cmd, cnf, kw):
"""Internal function."""
if kw:
cnf = _cnfmerge((cnf, kw))
elif cnf:
cnf = _cnfmerge(cnf)
if cnf is None:
return self._getconfigure(cmd)
if isinstance(cnf, str):
return self._getconfigure1(cmd + ('-'+cnf,))
self.tk.call(cmd + self._options(cnf))

I think that it's interesting to do this change because the function is more 
general and maybe can be used again in the future for new features in Tcl Tk. 
This way, we avoid code duplication (Dont Repeat Yourself is one of the 
philosophes of Python). This is the new version of tk_busy_configure using the 
mentioned change:
def tk_busy_configure(self, cnf=None, **kw):
return self._configure(('tk', 'busy', 'configure', self._w), cnf, kw)

It's more concise.
I disagree with tk_busy_status(). It's better to be more predictable an return 
the same than the other methods that uses getboolean(). If there is a bug, it's 
better to solve that bug.  Could you please guive me an code example that 
replicates the bug?

The _getboolean function is implemented in _tkinter.c. This is the 
implementation:
static PyObject *
Tkapp_GetBoolean (self, args)
 PyObject *self;
 PyObject *args;
{
  char *s;
  int v;

  if (!PyArg_Parse (args, "s", ))
return NULL;
  if (Tcl_GetBoolean (Tkapp_Interp (self), s, ) == TCL_ERROR)
return Tkinter_Error (self);
  return Py_BuildValue ("i", v);
}

A priori , I can't appreciate any bug in this function. If there is some bug, 
it's in another place of the C code.

--

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



[issue28498] tk busy command

2016-10-22 Thread Miguel

Miguel added the comment:

Misc._configure is only used when the first Tcl command is the name of the 
widget.

Very probably my proposal for tk_busy_configure is a better candidate because 
it follows the conventions used in tkinter (it's similar to pack_configure and 
place_configure):
 def tk_busy_configure(self, cnf=None, **kw):
self.tk.call(('tk', 'busy', 'configure', self._w) + self._options(cnf, 
kw))

--

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



[issue28498] tk busy command

2016-10-22 Thread Miguel

Miguel added the comment:

Thanks klappnase for your collaboration.

I dont understand this function:
def busy_status(self):
'''Returns the busy status of this window.
If the window presently can not receive user interactions,
True is returned, otherwise False.'''
return((self.tk.getboolean(self.tk.call(
'tk', 'busy', 'status', self._w)) and True) or False)

This pattern is not used in other functions that make use of 
self.tk.getboolean. These functions simply returns the value of 
self.tk.getboolean directly.

The code of your function busy_configure() is very similar to 
Misc._configure(). I think that you are duplicating code. Other functions 
related to configuration like pack_configure() and place_configure() simply use 
self._options(). For example:
def pack_configure(self, cnf={}, **kw):
self.tk.call(
  ('pack', 'configure', self._w)
  + self._options(cnf, kw))

def place_configure(self, cnf={}, **kw):
self.tk.call(
  ('place', 'configure', self._w)
  + self._options(cnf, kw))

I think that my proposal can do the job well. It follows the same pattern than 
the other functions:
def tk_busy_configure(self, cnf=None, **kw):
self.tk.call(('tk', 'busy', 'configure', self._w) + self._options(cnf, 
kw))

But I am not totally sure whether it's better to call directly Misc._configure 
or Misc._options in this situation.

Also if we follow the naming convention used in tkinter, it seems that we have 
to define first tk_busy_configure and then make this assignation:
 busy_configure = tk_busy_configure

--

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



[issue28498] tk busy command

2016-10-22 Thread Miguel

Miguel added the comment:

Maybe it's better to add also these methods:
busy = tk_busy
busy_cget = tk_busy_cget
busy_configure = tk_busy_configure
busy_current = tk_busy_current
busy_forget = tk_busy_forget
busy_hold = tk_busy_hold
busy_status = tk_busy_status

Many other methods in tkinter module follow the same pattern. For example:

iconbitmap = wm_iconbitmap
iconify = wm_iconify
group = wm_group
geometry = wm_geometry
focusmodel = wm_focusmodel
frame = wm_frame

--

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



[issue28498] tk busy command

2016-10-21 Thread Miguel

New submission from Miguel:

tcl tk 8.6.6 has a new busy command. The new tkinter library doesn't provide an 
interface for this command.

https://www.tcl.tk/man/tcl/TkCmd/busy.htm

The solution is to add to the class Misc of tkinter these methods:

def tk_busy(self, *args, **kw):
self.tk_busy_hold(*args, **kw)

def tk_buy_hold(self, cnf=None, **kw)
self.tk.call(('tk', 'busy', 'hold', self._w) + self._options(cnf, kw))

def tk_buy_configure(self, cnf=None, **kw):
self.tk.call(('tk', 'busy', 'configure', self._w) + self._options(cnf, kw))

def tk_cget(self, option):
return self.tk.call('tk', 'busy', 'cget', self._w, option)

def tk_busy_forget(self):
self.tk_call('tk', 'busy', 'forget', self._w)

def tk_busy_current(self, pattern=None):
if pattern is None:
self.tk.call('tk', 'busy', 'current')
else:
self.tk.call('tk', 'busy', 'current', pattern)

def tk_busy_status(self):
return self.tk.call('tk', 'busy', 'status', self._w)

--
components: Tkinter
messages: 279140
nosy: tkinter
priority: normal
severity: normal
status: open
title: tk busy command
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

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



[issue28497] future in tkinter

2016-10-21 Thread Miguel

New submission from Miguel:

I load the future package.
In the new package installed here:
python2.7/dist-packages/tkinter/__init__.py

it's not possible to import _default_root.

One possible solution is to create a method in tkinter module that returns the 
_default_root object.
```
def default_root():
  return _default_root
```

--
components: Tkinter
messages: 279139
nosy: tkinter
priority: normal
severity: normal
status: open
title: future in tkinter
versions: Python 2.7

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



[issue11632] difflib.unified_diff loses context

2013-04-29 Thread Miguel Latorre

Miguel Latorre added the comment:

This bug is still present in python 2.7.4 and python 3.3.1.
I attach another example, the result differs depending on number of lines to 
process (see test.py).

--
nosy: +mal
versions: +Python 2.7, Python 3.3
Added file: http://bugs.python.org/file30057/test.zip

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



[issue12268] file readline, readlines readall methods can lose data on EINTR

2012-12-03 Thread Gary Miguel

Changes by Gary Miguel gar...@google.com:


--
nosy: +Gary.Miguel

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



[issue13896] Make shelf instances work with 'with' as context managers

2012-09-05 Thread Miguel Angel García

Changes by Miguel Angel García miguelangel.gar...@gmail.com:


--
nosy: +Miguel.Angel.García

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



[issue13818] argparse: -h listening required options under optional arguments

2012-01-18 Thread Miguel Godinho

New submission from Miguel Godinho m...@miguelgodinho.com:

Adding a 'required optional argument' as with:
```
app.add_argument('--dbsnp', required=True)
```

will still result on having that argument listed under the optional when the 
app is called with the help option (-h)

Please note that the usage line is rendered ok (no square brackets around the 
'required optional argument').

--
components: Library (Lib)
messages: 151562
nosy: mgodinho
priority: normal
severity: normal
status: open
title: argparse: -h listening required options under optional arguments
type: behavior
versions: Python 2.7

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



[issue6434] buffer overflow in Zipfile when wrinting more than 2gig file

2011-11-03 Thread Miguel Hernández Martos

Miguel Hernández Martos enla...@gmail.com added the comment:

I think it's a dup of http://bugs.python.org/issue9720 

That issue has a patch that allows the generation of zip files with 2GB files.

--
nosy: +enlavin

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



[issue12772] fractional day attribute in datetime class

2011-08-20 Thread Miguel de Val Borro

Miguel de Val Borro miguel.de...@gmail.com added the comment:

Thanks, I need the fractional day added to the ordinal day of the month. Using 
the timedelta division it would be:

 from __future__ import division
 dt = datetime.datetime(2008, 5, 8, 13, 35, 41, 56)
 dt.day + (dt-datetime.datetime(dt.year, dt.month, 
 dt.day))/datetime.timedelta(1)
8.566453330752315

Then it simply becomes a one line function so I'm closing this ticket.

--
status: pending - closed

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



[issue12772] fractional day attribute in datetime class

2011-08-17 Thread Miguel de Val Borro

New submission from Miguel de Val Borro miguel.de...@gmail.com:

It would be useful to have a fractional day method in datetime.datetime
that returns a float object calculated from the day, hour, minute, second, and 
microseconds. Fractional days in UTC are often used in science, in particular 
to record astronomical observations.

--
messages: 142286
nosy: Miguel.de.Val.Borro
priority: normal
severity: normal
status: open
title: fractional day attribute in datetime class
type: feature request
versions: Python 2.7

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



[issue10141] SocketCan support

2011-07-19 Thread Miguel Luis

Changes by Miguel Luis mkx...@gmail.com:


--
nosy: +mluis

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