Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchObjects not deepcopy()able #34351

Closed
amigalemming mannequin opened this issue Apr 17, 2001 · 12 comments
Closed

MatchObjects not deepcopy()able #34351

amigalemming mannequin opened this issue Apr 17, 2001 · 12 comments
Labels
topic-regex type-feature A feature request or enhancement

Comments

@amigalemming
Copy link
Mannequin

amigalemming mannequin commented Apr 17, 2001

BPO 416670
Nosy @loewis, @terryjreedy, @abalkin

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-09-16.15:17:03.624>
created_at = <Date 2001-04-17.12:31:01.000>
labels = ['expert-regex', 'type-feature']
title = 'MatchObjects not deepcopy()able'
updated_at = <Date 2010-09-16.15:58:08.564>
user = 'https://bugs.python.org/amigalemming'

bugs.python.org fields:

activity = <Date 2010-09-16.15:58:08.564>
actor = 'r.david.murray'
assignee = 'effbot'
closed = True
closed_date = <Date 2010-09-16.15:17:03.624>
closer = 'BreamoreBoy'
components = ['Regular Expressions']
creation = <Date 2001-04-17.12:31:01.000>
creator = 'amigalemming'
dependencies = []
files = []
hgrepos = []
issue_num = 416670
keywords = []
message_count = 12.0
messages = ['53139', '53140', '53141', '53142', '53143', '53144', '63635', '63642', '75488', '77516', '113202', '116560']
nosy_count = 8.0
nosy_names = ['loewis', 'effbot', 'terry.reedy', 'andrewmcnamara', 'belopolsky', 'amigalemming', 'mrabarnett', 'BreamoreBoy']
pr_nums = []
priority = 'low'
resolution = 'out of date'
stage = 'test needed'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue416670'
versions = ['Python 3.2']

@amigalemming
Copy link
Mannequin Author

amigalemming mannequin commented Apr 17, 2001

In the re-Module which come with Python version 2.0
(Nov 28 11:10 re.py) the created MatchObjects cannot be
copied with a deepcopy(). Switching back to the old
"pre.py" as proposed in "re.py" makes everything work
ok.

@amigalemming amigalemming mannequin assigned effbot Apr 17, 2001
@amigalemming amigalemming mannequin added topic-regex type-feature A feature request or enhancement labels Apr 17, 2001
@amigalemming amigalemming mannequin assigned effbot Apr 17, 2001
@amigalemming amigalemming mannequin added topic-regex type-feature A feature request or enhancement labels Apr 17, 2001
@loewis
Copy link
Mannequin

loewis mannequin commented Apr 26, 2001

Logged In: YES
user_id=21627

A patch for that problem is in
http://sourceforge.net/tracker/index.php?func=detail&aid=419070&group_id=5470&atid=305470

@effbot
Copy link
Mannequin

effbot mannequin commented Apr 26, 2001

Logged In: YES
user_id=38376

I'm not sure this is a bug -- imo, you're relying on
an implementation artifact in the original PCRE port.
And making this work under SRE isn't as easy as it may
appear (the proposed patch may work in your specific
case, but it isn't a general solution).

But before I make up my mind here, maybe you could tell
me why you think it's a good idea to use deepcopy on
match objects. Why not just store "m.groups()" or
"m.regs" instead?

Cheers /F

@amigalemming
Copy link
Mannequin Author

amigalemming mannequin commented Apr 27, 2001

Logged In: YES
user_id=197994

You are right, m.groupdict() and m.groups() are surely the
better choice.

@effbot
Copy link
Mannequin

effbot mannequin commented Apr 28, 2001

Logged In: YES
user_id=38376

On the other hand, it looks like we've found a rather
elegant way to solve this. I'll leave this one open
(as a feature request).

@brettcannon
Copy link
Member

Logged In: YES
user_id=357491

The patch by Martin referenced below was closed since, as Fredrik pointed
out in the patch, that re objects have __copy__ and __deepcopy__ methods.
Problem is that they are untested so they are basically no-ops after
compilation by raising exceptions. So if this feature is still desired someone
just needs to work the kinks out of what Fredrik has started.

@abalkin
Copy link
Member

abalkin commented Mar 17, 2008

A related bpo-419070 was closed with no resolution (or resolution did
not survive the trip from SF), but it looks like the patch was rejected.

Some work towards this issue was done in r21437, but 7 years later it is
still marked as work in progress. Is there still interest is this
feature?

@amigalemming
Copy link
Mannequin Author

amigalemming mannequin commented Mar 17, 2008

On Mon, 17 Mar 2008, Alexander Belopolsky wrote:

Alexander Belopolsky <belopolsky@users.sourceforge.net> added the comment:

A related bpo-419070 was closed with no resolution (or resolution did
not survive the trip from SF), but it looks like the patch was rejected.

Some work towards this issue was done in r21437, but 7 years later it is
still marked as work in progress. Is there still interest is this
feature?

Not by me since I moved to Haskell. :-)

@andrewmcnamara
Copy link
Mannequin

andrewmcnamara mannequin commented Nov 4, 2008

One reason why this issue has been having less impact is that a bug in
some versions of the copy.py code meant it was ignoring the
__deepcopy__ stubs and using the pickle logic to copy _sre objects -
so, if you run the right python version, compiled regular expressions
and match objects deepcopy without problems.

On the 2.4 branch (release24-maint), changeset 38430 introduced the bug
that prevents the class __deepcopy__ exception-raising stubs being
found.

As an aside, I don't understand why the _sre objects should be
pickleable, but not deepcopy-able.

@loewis
Copy link
Mannequin

loewis mannequin commented Dec 10, 2008

As far as I can tell, there is no proposed patch. So this is out of
scope for 2.5.3.

@terryjreedy
Copy link
Member

The OP has no interest in this, there is no patch, and re2 is coming. Should we close this?

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Sep 16, 2010

No reply to msg113202.

@BreamoreBoy BreamoreBoy mannequin closed this as completed Sep 16, 2010
@BreamoreBoy BreamoreBoy mannequin closed this as completed Sep 16, 2010
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-regex type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants