[issue43738] Clarify public name of curses.window

2021-04-05 Thread Ryan McCampbell


New submission from Ryan McCampbell :

Until 3.8 the curses window class was not directly available in code, but now 
it is available as `_curses.window`. This is not explicitly stated in the 
documentation (although it is consistent with how the method signatures are 
written). It is useful to have a public name for the type to aid IDE's with 
explicit type annotations, i.e.

@curses.wrapper
def main(stdscr: curses.window):
stdscr.addstr(...)

See https://github.com/python/typeshed/pull/5180, which adds this name to type 
hints in the typeshed project.

This name should be more clearly documented so programmers can annotate the 
type without worrying that it may change (which will cause a runtime error 
unless it is quoted).

--
assignee: docs@python
components: Documentation
messages: 390266
nosy: docs@python, rmccampbell7
priority: normal
severity: normal
status: open
title: Clarify public name of curses.window
type: enhancement
versions: Python 3.10, Python 3.9

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



[issue34305] inspect.getsourcefile and inspect.getcomments do not work with decorated functions

2020-03-05 Thread Ryan McCampbell


Ryan McCampbell  added the comment:

This seems like a pretty straightforward fix. What's holding it up?

--
nosy: +rmccampbell7

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



[issue39587] Mixin repr overrides Enum repr in some cases

2020-02-08 Thread Ryan McCampbell


New submission from Ryan McCampbell :

In Python 3.6 the following works:

class HexInt(int):
def __repr__(self):
return hex(self)

class MyEnum(HexInt, enum.Enum):
A = 1
B = 2
C = 3

>>> MyEnum.A


However in Python 3.7/8 it instead prints
>>> MyEnum.A
0x1

It uses HexInt's repr instead of Enum's. Looking at the enum.py module it seems 
that this occurs for mixin classes that don't define __new__ due to a change in 
the _get_mixins_ method. If I define a __new__ method on the HexInt class then 
the expected behavior occurs.

--
components: Library (Lib)
messages: 361635
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: Mixin repr overrides Enum repr in some cases
type: behavior
versions: Python 3.7, Python 3.8

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



[issue39252] email.contentmanager.raw_data_manager bytes handler breaks on 7bit cte

2020-01-07 Thread Ryan McCampbell


New submission from Ryan McCampbell :

The email.contentmanager.set_bytes_content function which handles bytes content 
for raw_data_manager fails when passed cte="7bit" with an AttributeError: 
'bytes' object has no attribute 'encode'. This is probably not a major use case 
since bytes are generally not for 7-bit data but the failure is clearly not 
intentional.

--
components: Library (Lib)
messages: 359555
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: email.contentmanager.raw_data_manager bytes handler breaks on 7bit cte
type: behavior
versions: Python 3.8

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



[issue37536] ctypes.create_string_buffer fails on windows with non-BMP characters

2019-07-09 Thread Ryan McCampbell


Ryan McCampbell  added the comment:

Oops my bad, didn't realize this was already fixed

--

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



[issue37536] ctypes.create_string_buffer fails on windows with non-BMP characters

2019-07-09 Thread Ryan McCampbell


Change by Ryan McCampbell :


--
versions: +Python 3.6

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



[issue37536] ctypes.create_string_buffer fails on windows with non-BMP characters

2019-07-09 Thread Ryan McCampbell


Change by Ryan McCampbell :


--
components: +ctypes
type:  -> behavior

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



[issue37536] ctypes.create_string_buffer fails on windows with non-BMP characters

2019-07-09 Thread Ryan McCampbell


New submission from Ryan McCampbell :

The ctypes.create_string_buffer function uses the length of the string to 
create the buffer if no size is provided. Since windows wide chars are UTF-16 
the buffer may actually need to be larger to store surrogate pairs. This code 
crashes on windows:

>>> create_unicode_buffer('\U0001\U0001')
ValueError: string too long

--
messages: 347600
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: ctypes.create_string_buffer fails on windows with non-BMP characters

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



[issue35474] mimetypes.guess_all_extensions potentially mutates list

2018-12-12 Thread Ryan McCampbell


New submission from Ryan McCampbell :

The mimetypes.guess_all_extensions function is defined as:

def guess_all_extensions(self, type, strict=True):
type = type.lower()
extensions = self.types_map_inv[True].get(type, [])
if not strict:
for ext in self.types_map_inv[False].get(type, []):
if ext not in extensions:
extensions.append(ext)
return extensions

If any mime type exists in both the strict and non-strict types_map_inv and it 
is called with strict=False, then it will modify the strict list in-place which 
effects future calls even with strict=True. While this doesn't manifest as an 
error for me because the dictionaries are non-overlapping, it is a potential 
error; it is also vulnerable to people accidentally modifying the returned 
list. The list should be copied after the first lookup.

--
components: Library (Lib)
messages: 331715
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: mimetypes.guess_all_extensions potentially mutates list
type: behavior

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



[issue31405] shutil.which doesn't find files without PATHEXT extension on Windows

2018-09-26 Thread Ryan McCampbell


Ryan McCampbell  added the comment:

This is how windows looks up commands, as well as the built in "where" command. 
(Note that windows doesn't actually distinguish between "executable" files and 
just plain old files, so this could be confusing for UNIX users... a text file 
for instance will simply open in the default text editor when "executed" by the 
shell.)

--

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



[issue31405] shutil.which doesn't find files without PATHEXT extension on Windows

2017-09-09 Thread Ryan McCampbell

New submission from Ryan McCampbell:

On windows, shutil.which does not match the semantics of built-in command 
lookup. If you pass the name of a script like foo.py and the PATHEXT variable 
doesn't include .py it will search for foo.py.exe, foo.py.bat, foo.py.cmd, etc. 
but not foo.py, which should be the first name checked.

--
components: Library (Lib)
messages: 301785
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: shutil.which doesn't find files without PATHEXT extension on Windows
type: behavior
versions: Python 3.6

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



[issue22487] ABC register doesn't check abstract methods

2014-09-24 Thread Ryan McCampbell

New submission from Ryan McCampbell:

Is there a reason register() doesn't check for abstract methods, like 
subclassing does? Would it fail for some builtin classes? It seems that this 
would be a better guarantee that, say, something really is iterable when you 
check isinstance(Collections.Iterable, o), since someone could have called 
Collections.Iterable.register(o.__class__) without adding an __iter__ method to 
their class.

--
messages: 227489
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: ABC register doesn't check abstract methods
type: enhancement

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



[issue22487] ABC register doesn't check abstract methods

2014-09-24 Thread Ryan McCampbell

Ryan McCampbell added the comment:

Obviously, I meant isinstance(o, Collections.Iterable).

--

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



[issue21684] inspect.signature bind doesn't include defaults or empty tuple/dicts

2014-06-24 Thread Ryan McCampbell

Ryan McCampbell added the comment:

It's not really a particular use case. I was making a function decorator for 
automatic type checking using annotations (ironically I discovered later there 
is an almost identical example in the PEP for signatures). But I can't think of 
any use case when it would be undesirable to include the extra parameters, 
unless it slows down the code, hence the possibility of a separate method. It 
would not complicate the API to add behavior that would simplify most 
applications. And I just realized this is also the behavior of 
inspect.getcallargs, for which the docs recommend to switch to Signature.bind.

--

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



[issue21684] inspect.signature bind doesn't include defaults or empty tuple/dicts

2014-06-21 Thread Ryan McCampbell

Ryan McCampbell added the comment:

Copying defaults still doesn't give you var positional/keyword arguments, which 
means, you have to explicitly check the parameter type, and then add them in. I 
still think it would more useful to have an official way of getting all 
function parameters from arguments.

--

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



[issue21684] inspect.signature bind doesn't include defaults or empty tuple/dicts

2014-06-14 Thread Ryan McCampbell

Ryan McCampbell added the comment:

If this is decided against, a partial solution would be to set the default 
attribute of VAR_POSITIONAL and VAR_KEYWORD args to an empty tuple/dict, 
respectively. Then you could get a parameter's value no matter what with 
boundargs.get(param.name, param.default).

--

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



[issue21684] inspect.signature bind doesn't include defaults or empty tuple/dicts

2014-06-06 Thread Ryan McCampbell

New submission from Ryan McCampbell:

I'm not sure if this is really a bug, but it is unexpected behavior. When you 
call bind on a Python 3.3 signature object, if you omit an optional argument, 
the default is not provided in the arguments dict. Similarly, if there is a 
var positional or var keyword parameter but there are no extra arguments, 
it will not be included. To emulate the effect on the namespace of an actual 
function, I would expect these to be included, as an empty tuple/dict in the 
case of variable arguments. I realize the current behavior may be useful in 
some cases, but if so, then another method could be added: bind_full, which 
would include all parameters of the signature.

--
messages: 219916
nosy: rmccampbell7
priority: normal
severity: normal
status: open
title: inspect.signature bind doesn't include defaults or empty tuple/dicts
type: behavior
versions: Python 3.3, Python 3.4

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