bpo-30397: Add re.Pattern and re.Match. by serhiy-storchaka · Pull Request #1646 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation4 Commits6 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

serhiy-storchaka

@serhiy-storchaka

Also add and update docstrings. Change module of the error, Pattern and Match types.

@mention-bot

@serhiy-storchaka

gvanrossum

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. I guess it's too scary to make these classes generic (like their counterparts in typing.py) -- after all we don't do that for other ABCs either.

@@ -690,7 +690,7 @@ PyDoc_STRVAR(_sre_SRE_Match_span__doc__,
"span($self, group=0, /)\n"
"--\n"
"\n"
"For MatchObject m, return the 2-tuple (m.start(group), m.end(group)).");
"For match object m, return the 2-tuple (m.start(group), m.end(group)).");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be "Match object"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. The term "match object" is widely used in the documentation (unlikely to just added name Match).

@ilevkivskyi

Thanks for doing this. I guess it's too scary to make these classes generic (like their counterparts in typing.py) -- after all we don't do that for other ABCs either.

Yes. I was thinking about using these new classes in __extra__ attributes of typing types, like we do for collections ABCs, but there is some special casing for Pattern and Match in typing so that it is better to keep the typing types as is.

This was referenced

Apr 2, 2018

This was referenced

Jul 11, 2018

vmalloc pushed a commit to mongomock/mongomock that referenced this pull request

Jul 22, 2018

@helloqiu @vmalloc

Hi there. Python 3.7 removes re._pattern_type and renames it to re.Pattern. python/cpython#1646 I also remove test for py3.3(point to python3.4, which is redudant) and add test for py3.6 & 3.7. :)