[issue11021] email MIME-Version headers for each part in multipart message

2011-03-14 Thread David Caro

David Caro  added the comment:

Of course, the RFC that discusses the MIME-Version Header is  RFC-2045
http://www.ietf.org/rfc/rfc2045.txt

Extract of the page 8:
   "Note that the MIME-Version header field is required at the top level
   of a message.  It is not required for each body part of a multipart
   entity."

Strictly all the implementations should support the MIME-Version on each field, 
because the RFC does not explicitly say that it should not be included, but all 
the best practice documents that mention it say that it should not be included 
in all the parts, my main concern is that maybe it raises the spam level of the 
sent e-mails.

Maybe it's not critical enough to be backported, but at least, it should be 
changed for future versions.

Thanks

--

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



[issue10981] options starting with -- match substrings

2011-01-22 Thread David Caro

New submission from David Caro :

When parsing option like --optionname, --option will match it too

example:

>>> import argparse
>>>  parser = argparse.ArgumentParser()
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--superstring')
_StoreAction(option_strings=['--superstring'], dest='superstring', nargs=None, 
const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args(['--super','value'])
Namespace(superstring='value')

I'm using argparse 1.1 with python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39), 
on ubuntu 10.10 32bit

--
messages: 126833
nosy: David.Caro
priority: normal
severity: normal
status: open
title: options starting with -- match substrings

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



[issue10981] options starting with -- match substrings

2011-01-22 Thread David Caro

Changes by David Caro :


--
components: +Extension Modules
versions: +Python 2.6

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



[issue10981] argparse: options starting with -- match substrings

2011-01-22 Thread David Caro

Changes by David Caro :


--
title: options starting with -- match substrings -> argparse: options starting 
with -- match substrings

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



[issue10981] argparse: options starting with -- match substrings

2011-01-22 Thread David Caro

David Caro  added the comment:

It is not an issue, it will try to match all the optional parameters, and if 
only one matches, then it will use it:

2110 elif option_string.startswith(option_prefix):
2111 action = self._option_string_actions[option_string]
2112 tup = action, option_string, explicit_arg
2113 result.append(tup)

and

2057 # if exactly one action matched, this segmentation is good,
2058 # so return the parsed action
2059 elif len(option_tuples) == 1:
2060 option_tuple, = option_tuples
2061 return option_tuple


if you try to add more than one optional parameter that matches the substring, 
it will complain:

>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--superstring')
_StoreAction(option_strings=['--superstring'], dest='superstring', nargs=None, 
const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args(['--super','value'])
Namespace(superstring='value')
>>> parser.add_argument('--superstring2')
_StoreAction(option_strings=['--superstring'], dest='superstring', nargs=None, 
const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args(['--super','value'])
usage: [-h] [--superstring SUPERSTRING] [--superstring2 SUPERSTRING2]
: error: ambiguous option: --super could match --superstring, --superstring2

--
resolution:  -> invalid
status: open -> closed

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



[issue10981] argparse: options starting with -- match substrings

2011-01-26 Thread David Caro

David Caro  added the comment:

Yes it is, here 
http://docs.python.org/dev/library/argparse.html#argument-abbreviations.

--

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



[issue11021] email MIME-Version headers for each part in multipart message

2011-01-26 Thread David Caro

New submission from David Caro :

When attaching a subpart to a multipart message, python should follow the 
recomendations of the rfcs and remove the MIME-Version header of each part, 
leaving only one MIME-Version header at the beggining of the message.


>>> from email.mime.multipart import MIMEMultipart
>>> from email.mime.text import MIMEText
>>> usermail=MIMEMultipart('alternative')
>>> part=MIMEText('text')
>>> print part
>From nobody Thu Jan 27 00:33:50 2011
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

text
>>> usermail.attach(part)
>>> print usermail
>From nobody Thu Jan 27 00:45:26 2011
Content-Type: multipart/alternative; boundary="===1006894803=="
MIME-Version: 1.0

--===1006894803==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

text
--===1006894803==--

--
components: Library (Lib)
messages: 127161
nosy: david.caro
priority: normal
severity: normal
status: open
title: email MIME-Version headers for each part in multipart message
type: behavior
versions: Python 2.6, Python 2.7

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



[issue41231] Type annotations lost when using wraps by default

2020-07-07 Thread David Caro


New submission from David Caro :

In version 3.2, bpo-8814 introduced copying the __annotations__ property from 
the wrapped function to the wrapper by default.

That would be the desired behavior when your wrapper function has the same 
signature than the function it wraps, but in some cases (for example, with the 
contextlib.asynccontextmanager function) the return value is different, and 
then the __annotations__ property will have invalid information:

In [2]: from contextlib import asynccontextmanager  
  

In [3]: @asynccontextmanager 
   ...: async def mytest() -> int: 
   ...: return 1 
   ...: 
  

In [4]: mytest.__annotations__  
  
Out[4]: {'return': int}


I propose changing the behavior of wraps, to only assign the __annotations__ by 
default if there's no __annotations__ already in the wrapper function, that 
would fit most default cases, but would allow to preserve the __annotations__ 
of the wrapper function when the types are explicitly specified, allowing now 
to change the contextlib.asynccontextmanager function with the proper types 
(returning now an AsyncContextManager) and keep the __annotation__ valid.

I'll try to get a POC and attach to the issue, but please comment with your 
ideas too.

--
components: Library (Lib)
messages: 373233
nosy: David Caro
priority: normal
severity: normal
status: open
title: Type annotations lost when using wraps by default
type: behavior
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

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



[issue41231] Type annotations lost when using wraps by default

2020-07-07 Thread David Caro


David Caro  added the comment:

Hi Terry,

That would not work in this case, as I'd want to override all annotations with 
the wrapper function ones if there's any, instead of merging them.

The specific use case, is a type checker (part of TestSlide testing framework), 
to verify that if there's any type annotations, the parameters mocked and 
passed to it are the expected types.

For example, the contextmanager decorator returns an actual ContextManager, 
wrapping whatever the wrapped function returned, so if the wrapped function 
annotations prevail, then there's no way if verifying that the returned type is 
correct.

Thanks for the ChainMap pointer though, I'll use it for sure somewhere else.

--

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



[issue41231] Type annotations lost when using wraps by default

2020-07-08 Thread David Caro


Change by David Caro :


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

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



[issue8814] functools.WRAPPER_ASSIGNMENTS should include __annotations__

2020-07-08 Thread David Caro


Change by David Caro :


--
nosy: +David Caro
nosy_count: 4.0 -> 5.0
pull_requests: +20539
pull_request: https://github.com/python/cpython/pull/21392

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



[issue41231] Type annotations lost when using wraps by default

2020-07-08 Thread David Caro


David Caro  added the comment:

As a note, mypy does not tpyecheck the wrapper functions, probably because it 
would not be possible with the current code (as the typing hints get lost):

https://mypy.readthedocs.io/en/latest/generics.html?highlight=wrapper#declaring-decorators

--

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



[issue41231] Type annotations lost when using wraps by default

2020-07-08 Thread David Caro


David Caro  added the comment:

Elaborating on the last message, given the following code:
```
  1 #!/usr/bin/env python3
  2 
  3 from functools import wraps
  4 
  5 
  6 def return_string(wrapped):
  7 @wraps(wrapped)
  8 def wrapper(an_int: int) -> str:
  9 return str(wrapped(an_int))
 10 
 11 return wrapper
 12 
 13 
 14 @return_string
 15 def identity(an_int: int) -> int:
 16 return an_int
 17 
 18 def print_bool(a_bool: bool) -> None:
 19 print(a_bool)
 20 
 21 def identity_nonwrapped(an_int: int) -> int:
 22 return an_int
 23 
 24 
 25 print_bool(a_bool=identity(7))
 26 print_bool(a_bool=identity_nonwrapped(7))
```

mypy will complain only on the last line, being unable to check properly the 
line 25.

I'll investigate a bit more on why mypy skips that.

--

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



[issue39960] Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is broken (hackcheck too eager?)

2020-07-14 Thread David Caro


Change by David Caro :


--
nosy: +David Caro
nosy_count: 5.0 -> 6.0
pull_requests: +20618
pull_request: https://github.com/python/cpython/pull/21473

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-14 Thread David Caro


Change by David Caro :


--
keywords: +patch
nosy: +David Caro
nosy_count: 5.0 -> 6.0
pull_requests: +20617
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21473

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-14 Thread David Caro


David Caro  added the comment:

Just sent a PR that fixes the issue (a first approach), let me know if it's 
addressing the issue correctly or if there's a better way.


Thanks!

--

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



[issue41295] CPython 3.8.4 regression on __setattr__ in multiinheritance with metaclasses

2020-07-17 Thread David Caro


David Caro  added the comment:

> David, which issue number is this?

It's issue41295, pr #21473

--

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