[issue45546] Unable to pickle enum with nested frozen dataclass?

2021-10-21 Thread Eric Cousineau
Eric Cousineau added the comment: > I get an error with 3.8.10, but not on the main branch (3.11) [...] Confirmed, using 3.11.0a1 (using Docker). Seems like at least the pickling is fixed? > I'm confused -- your initial report talks about pickling fields, but your > tests are

[issue45546] Unable to pickle enum with nested frozen dataclass?

2021-10-20 Thread Eric Cousineau
Eric Cousineau added the comment: Thinking on it some more, I the current `Enum` metaclass doesn't distinguish between nested class and normal field, so it wraps it, thus why `pickle` gets confused. Perhaps it's possible to recognize this case - the class w/ `__qualname__` can be checked

[issue45546] Unable to pickle enum with nested frozen dataclass?

2021-10-20 Thread Eric Cousineau
Eric Cousineau added the comment: Ah, forgot to include error message: ``` E ... _pickle.PicklingError: Can't pickle : it's not the same object as __main__.DoesNotWork.NestedValue2 ``` -- ___ Python tracker <https://bugs.python.org/issue45

[issue45546] Unable to pickle enum with nested frozen dataclass?

2021-10-20 Thread Eric Cousineau
New submission from Eric Cousineau : I seem cannot pickle enum values from an enum class w/ a nested frozen dataclass. I can pickle a field from a normal class w/ a nested frozen dataclass, and I can pickle a field from an enum with a top-level frozen dataclass - perhaps it's some interplay

[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2020-04-09 Thread Eric Cousineau
Eric Cousineau added the comment: Aye. Using a workaround for now ("leak" the object by incrementing the refcount on first resurrection): https://github.com/RobotLocomotion/pybind11/pull/39 I may try Antoine's suggestion later on, but will definitely reformulate this to use the

[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2020-04-09 Thread Eric Cousineau
Eric Cousineau added the comment: Er, to clarify: "PEP 442 had that effect" => "PEP 442 had the effect of making it resurrectable only once, but not more than that." -- ___ Python tracker <https://

[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2020-04-09 Thread Eric Cousineau
Eric Cousineau added the comment: > [...] but I am not sure it makes sense to allow to mark an object as > finalized because that could mess with the GC algorithm. Actually, I would like the opposite, to mark it unfinalized to resurrect the object more than once. PEP 442 from a way

[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2020-04-09 Thread Eric Cousineau
Eric Cousineau added the comment: C functions sound great! I am certainly not wed to the macros (nor do I love them), as I do not have intense performance requirements where inlining (and spilling implementation guts) is necessary. -- ___ Python

[issue32377] Difference in ressurrection behavior with __del__ in py2 vs. py3

2020-04-09 Thread Eric Cousineau
Eric Cousineau added the comment: See also bpo-40240: "Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?" -- ___ Python tracker <https://bugs.python.o

[issue40240] Expose public spelling of _PyGC_FINALIZED and _PyGC_SET_FINALIZED?

2020-04-09 Thread Eric Cousineau
New submission from Eric Cousineau : Motivated by this downstream project issue that I am working on: https://github.com/RobotLocomotion/drake/issues/13026 In https://bugs.python.org/issue32377, I encountered PEP 442's updated resurrection behavior when moving from supporting Python 2

[issue32377] Difference in ressurrection behavior with __del__ in py2 vs. py3

2020-04-09 Thread Eric Cousineau
Eric Cousineau added the comment: Super late response, but for this part: > Well... perhaps you could create another PyObject (it's just a wrapper, > right?) since the old one doesn't have any outside references to it > remaining. In certain cases, yes, that would be the case.

[issue32845] Mac: Local modules can shadow builtins (e.g. a local `math.py` can shadow `math`)

2018-02-15 Thread Eric Cousineau
Eric Cousineau <eric.cousineau@tri.global> added the comment: > P.S. This issue points out once again why it is generally a bad idea to > shadow or mix-and-match standard library module names. Duly noted! And thank y'all for the explanations! Can I ask if it's bad practice to us

[issue32845] Mac: Local modules can shadow builtins (e.g. a local `math.py` can shadow `math`)

2018-02-14 Thread Eric Cousineau
New submission from Eric Cousineau <eric.cousineau@tri.global>: We ran into an issue with our library; we build a submodule named `math.so`, and have a test `math_test` which is ran in the same directory as this module (since this is how we've written it with Bazel's generated Python bi

[issue32377] Difference in ressurrection behavior with __del__ in py2 vs. py3

2017-12-19 Thread Eric Cousineau
Eric Cousineau <eric.cousineau@tri.global> added the comment: You're welcome, and thank you for the prompt response! I will say that it feels a tad odd to only have `tp_finalize` be called once for the entire lifetime of the object, while still having the option of it being resur

[issue32377] Difference in ressurrection behavior with __del__ in py2 vs. py3

2017-12-19 Thread Eric Cousineau
New submission from Eric Cousineau <eric.cousineau@tri.global>: Due to how `PyObject_CallFinalizer` is written in python3, `__del__` will only *ever* be called once. In my use case, I am experimenting with a feature in `pybind11` to prevent slicing with Python class instances that i

[issue15768] re.sub() with re.MULTILINE not replacing all occurrences

2012-08-22 Thread Eric Cousineau
New submission from Eric Cousineau: [Copying post I made here: http://stackoverflow.com/questions/12082886/bug-in-python-regex-re-sub-with-re-multiline] I'm noticing some odd behavior in Python's Regex library, and I'm not sure if I'm doing something wrong. If I run a regex on it using

[issue15768] re.sub() with re.MULTILINE not replacing all occurrences

2012-08-22 Thread Eric Cousineau
Eric Cousineau added the comment: Looks like I was just writing my code incorrectly - I should have been using re.sub(..., flags = re.MULTILINE). That explains it. -- resolution: - invalid status: open - closed ___ Python tracker rep