[issue45110] argparse repeats itself when formatting help metavars

2021-09-11 Thread Lewis Gaul


Lewis Gaul  added the comment:

Big +1 from me for at least supporting a way to get the more concise output. 
I've never understood the verbosity of python's argparse where the metavar is 
repeated.

--
nosy: +LewisGaul

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



[issue43080] pprint for dataclass instances

2021-03-16 Thread Lewis Gaul


Lewis Gaul  added the comment:

> FWIW, we've not had a feature request for this ever, nor has there been a 
> request for pprint to support attrs, nor any other hand-rolled class that 
> implements methods similar to those generated by dataclasses.

I wouldn't expect core Python to support a 3rd party lib like attrs, but I fail 
to see what's so different between dataclasses, SimpleNamespace and namedtuple 
- all of these may be used for storing/modelling [nested] data, which then may 
be printed.

> AFAICT, this tracker issue wasn't motivated by a known use case; rather, it 
> was "my PR was accepted for SimpleNamespace and thought dataclasses could be 
> the next."

This issue is entirely motivated by a real-world example - I'm currently 
maintaining a private fork of the pprint module with support for dataclasses 
added. I'm assuming the reason this hasn't come up before is that dataclasses 
are relatively new (and plenty of users will still be on older versions of 
Python).

I was not the author of the issue that added support for SimpleNamespace, I 
just saw it and used it as an example of precedent.

> At some point, we need a modern redesign alternative to pprint.

I'm on board with this, but as Eric said there aren't currently any signs of 
this being worked on. In absence of a redesign, dataclass support seems like a 
natural extension to me.

--

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



[issue19073] Inability to specific __qualname__ as a property on a class instance.

2021-02-20 Thread Lewis Gaul


Lewis Gaul  added the comment:

This would also be useful for me - I just hit this same problem. If someone 
could give some guidance on how to make this change I'd be happy to put up a PR.

--
nosy: +LewisGaul

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



[issue43080] pprint for dataclass instances

2021-01-31 Thread Lewis Gaul


Lewis Gaul  added the comment:

@Serhiy - Yes, I noted that problem in the PR. Thanks for pointing me to that 
issue, I agree it would be good to make pprint properly extensible (my current 
solution is to maintain a fork of the pprint module with dataclass support 
added).

Eric's suggestion would work, I wasn't sure if it would be considered an 'ok' 
thing to do, but if so then could be an easy enough way to support dataclasses 
(and namedtuples potentially)?

--

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



[issue43080] pprint for dataclass instances

2021-01-31 Thread Lewis Gaul


Lewis Gaul  added the comment:

> a dataclass can do anything a regular class can do

Agreed, but isn't that also true of any subclasses of currently supported 
types? In particular 'UserDict', 'UserList' and 'UserString', which all have 
explicit support in pprint and are intended for "easier subclassing" according 
to the docs.

I'm also not sure why it would be a reason for not giving it pprint handling 
(in the case where there's no user-defined __repr__). Is there any harm in 
doing so? 

I'd consider dataclasses one of the primary choices for storing data in modern 
Python (e.g. for converting to/from JSON/YAML), and may well be used for 
storing nested data, which can be very hard to read without some mechanism for 
pretty-printing.

Indeed, the dataclasses.asdict() function recurses into dataclass fields. This 
gives the option of pprint(dataclasses.asdict(my_dataclass)), but at the cost 
of losing the class names and any custom reprs.

--

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



[issue43080] pprint for dataclass instances

2021-01-30 Thread Lewis Gaul


Change by Lewis Gaul :


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

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



[issue43080] pprint for dataclass instances

2021-01-30 Thread Lewis Gaul


New submission from Lewis Gaul :

Currently the pprint module does not have support for dataclasses. I have 
implemented support for this and will link the PR once I have the issue number!

See also issue37376 for SimpleNamespace support.

--
components: Library (Lib)
messages: 386002
nosy: LewisGaul, eric.snow, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: pprint for dataclass instances
type: enhancement
versions: Python 3.10

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



[issue38865] [subinterpreters] Can Py_Finalize() be called if the current interpreter is not the main interpreter?

2020-10-25 Thread Lewis Gaul


Change by Lewis Gaul :


--
pull_requests: +21889
pull_request: https://github.com/python/cpython/pull/17575

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



[issue37776] [subinterpreters] Test Py_Finalize() from a subinterpreter

2020-10-25 Thread Lewis Gaul


Change by Lewis Gaul :


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

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



[issue38865] [subinterpreters] Can Py_Finalize() be called if the current interpreter is not the main interpreter?

2020-10-22 Thread Lewis Gaul


Change by Lewis Gaul :


--
pull_requests:  -21778

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



[issue38865] [subinterpreters] Can Py_Finalize() be called if the current interpreter is not the main interpreter?

2020-10-20 Thread Lewis Gaul


Change by Lewis Gaul :


--
nosy: +LewisGaul
nosy_count: 4.0 -> 5.0
pull_requests: +21778
pull_request: https://github.com/python/cpython/pull/17575

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



[issue38379] finalizer resurrection in gc

2020-08-16 Thread Lewis Gaul


Lewis Gaul  added the comment:

You're right that's how I had interpreted it, thanks for clarifying.

I was wondering if this could be related to an issue I've hit with gc.collect() 
getting slower and slower in a test suite, but that now seems unlikely, so I 
won't go into that here.

--

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



[issue38379] finalizer resurrection in gc

2020-08-16 Thread Lewis Gaul


Lewis Gaul  added the comment:

I noticed this bug is mentioned in the 3.9 release notes with a note similar to 
the title of the 4th PR: "garbage collection does not block on resurrected 
objects".

I can't see any mention of a blocking issue here on the issue:

> The bug:  the stats keep claiming gc is collecting an enormous number of 
> objects, but in fact it's not collecting any.  Objects in the unreachable set 
> shouldn't add to the "collected" count unless they _are_ collected.

Would someone be able to elaborate on the blocking issue that was fixed as part 
of this BPO?

--
nosy: +LewisGaul

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



[issue37776] Test Py_Finalize() from a subinterpreter

2019-12-13 Thread Lewis Gaul


Lewis Gaul  added the comment:

It seems that test_audit_subinterpreter() in _testembed.c was 
(unintentionally?) doing this already.

After fixing #36225 I found this testcase causes a segfault, but works fine 
when switching back to the main threadstate before calling Py_Finalize().

So it looks like adding a specific testcase for this is likely to weed out an 
actual issue here!

--
nosy: +LewisGaul

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



[issue39030] Ctypes unions with bitfield members that do not share memory

2019-12-12 Thread Lewis Gaul


Change by Lewis Gaul :


--
nosy: +LewisGaul, belopolsky

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



[issue36225] Lingering subinterpreters should be implicitly cleared on shutdown

2019-12-11 Thread Lewis Gaul


Change by Lewis Gaul :


--
pull_requests: +17048
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/17575

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



[issue38860] GenericPyCData_new does not invoke new or init

2019-12-11 Thread Lewis Gaul


Change by Lewis Gaul :


--
nosy: +LewisGaul, aeros

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



[issue37292] _xxsubinterpreters: Can't unpickle objects defined in __main__

2019-11-24 Thread Lewis Gaul


Lewis Gaul  added the comment:

The relevant code for the multiprocessing example seems to be in 
Lib/multiprocessing/spawn.py. I think I get what it's doing, but I'm not sure 
whether we actually need something similar for subinterpreters. Any thoughts 
@eric.snow?

--

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



[issue37292] _xxsubinterpreters: Can't unpickle objects defined in __main__

2019-11-24 Thread Lewis Gaul


Lewis Gaul  added the comment:

Just to move the conversation from the subinterpreters project repo to here...

I'm going to take a look at how this is done by subprocess using the example 
provided by Guido:

import os
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import get_context

class C:
def __getstate__(self):
print("pickled in %d" % os.getpid())
return {}

def __setstate__(self, state):
print("unpickled in %d" % os.getpid())

def hello(self):
print("Hello world")


if __name__ == "__main__":
with ProcessPoolExecutor(mp_context=get_context("spawn")) as ex:
ex.submit(C().hello).result()

Output:

pickled in 23480
unpickled in 23485
Hello world

--
nosy: +LewisGaul

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



[issue36225] Lingering subinterpreters should be implicitly cleared on shutdown

2019-11-21 Thread Lewis Gaul


Lewis Gaul  added the comment:

I've put together a test along the lines of what Nick suggested, see the 
attached patch. Running this hits the Fatal 'remaining subinterpreters' error 
as expected:

```
   > ./Programs/_testembed test_bpo36225
--- Pass 0 ---
interp 0 <0x1A561A0>, thread state <0x1A56DD0>: id(modules) = 139707107673104
interp 1 <0x1A9D050>, thread state <0x1A87620>: id(modules) = 139707106987472
interp 2 <0x1B02210>, thread state <0x1AEC320>: id(modules) = 139706981531088
interp 0 <0x1A561A0>, thread state <0x1A56DD0>: id(modules) = 139707107673104
interp 3 <0x1B53740>, thread state <0x1AFD980>: id(modules) = 139706980408304
interp 4 <0x1BA3390>, thread state <0x1B3C7A0>: id(modules) = 139706979780944
interp 0 <0x1A561A0>, thread state <0x1A56DD0>: id(modules) = 139707107673104
Fatal Python error: PyInterpreterState_Delete: remaining subinterpreters
Python runtime state: finalizing (tstate=0x1a56dd0)

Aborted
```

I'm happy to look a bit further into the fix for this - Eric's pointers in this 
thread look useful to get started. @nanjekyejoannah did you get anywhere with 
this?

--
keywords: +patch
nosy: +LewisGaul
Added file: https://bugs.python.org/file48733/finalise-subinterps-test.diff

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



[issue38880] Subinterpreters: List interpreters associated with a channel end

2019-11-21 Thread Lewis Gaul


Change by Lewis Gaul :


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

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



[issue38880] Subinterpreters: List interpreters associated with a channel end

2019-11-21 Thread Lewis Gaul


New submission from Lewis Gaul :

The public interpreters API being implemented for PEP 554 requires the ability 
to list interpreters associated with channel ends. This functionality needs 
adding in the internal subinterpreters module.

See https://github.com/ericsnowcurrently/multi-core-python/issues/52 and 
https://www.python.org/dev/peps/pep-0554/#api-for-sharing-data.

--
messages: 357181
nosy: Lewis Gaul, eric.snow, nanjekyejoannah
priority: normal
severity: normal
status: open
title: Subinterpreters: List interpreters associated with a channel end
type: enhancement
versions: Python 3.9

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



[issue16142] ArgumentParser inconsistent with parse_known_args

2019-11-12 Thread Lewis Gaul


Change by Lewis Gaul :


--
nosy: +aeros

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



[issue27994] In the argparse help(argparse) prints weird comments instead of good docstrings

2019-11-04 Thread Lewis Gaul


Change by Lewis Gaul :


--
nosy: +aeros

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



[issue27994] In the argparse help(argparse) prints weird comments instead of good docstrings

2019-11-04 Thread Lewis Gaul


Lewis Gaul  added the comment:

This doesn't seem to be the case [anymore] to me, should this be closed?

--
nosy: +Lewis Gaul

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



[issue38475] Break Statement

2019-11-04 Thread Lewis Gaul


Lewis Gaul  added the comment:

Should this issue be closed?

--
nosy: +Lewis Gaul

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



[issue23692] Undocumented feature prevents re module from finding certain matches

2019-10-29 Thread Lewis Gaul


Lewis Gaul  added the comment:

Thanks for the explanation Matthew, I'll take a further look at some point in 
the coming weeks.

--

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



[issue22491] Support Unicode line boundaries in regular expression

2019-10-27 Thread Lewis Gaul


Lewis Gaul  added the comment:

Hi there, I'm running 'EnHackathon' in a couple of weeks, and was wondering if 
this could be a good issue for a small team of first-time contributors with 
experience in C to work on.

Would anyone be able to offer any guidance for where to start in Modules/_sre.c?

--
nosy: +Lewis Gaul

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



[issue23692] Undocumented feature prevents re module from finding certain matches

2019-10-27 Thread Lewis Gaul


Lewis Gaul  added the comment:

Hi there, if anyone's able to provide any guidance on this issue I'd be happy 
to take a look into it.

Is this a behaviour that is feasible to fix, or should this just be documented 
in some way as suggested by Evgeny?

--
nosy: +Lewis Gaul

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



[issue21002] _sre.SRE_Scanner object should have a fullmatch() method

2019-10-27 Thread Lewis Gaul


Lewis Gaul  added the comment:

Scanner is not documented in CPython's own re documentation: 
https://docs.python.org/3/library/re.html#regular-expression-objects, so I'd 
say there's no obligation to maintain consistency with public APIs.

Is anyone able to make a call on whether this issue should be closed, or 
alternatively give some guidance on what work this issue should encompass?

--
nosy: +Lewis Gaul

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



[issue38351] Modernize email example from %-formatting to f-string

2019-10-27 Thread Lewis Gaul


Lewis Gaul  added the comment:

Hi all, I'm a newcomer interested in making this small fix, but it looks like 
this has become a bit of a contentious issue. Are there any advances on whether 
this is a desirable fix?

--
nosy: +Lewis Gaul

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