8000 Keep old names of sre_* modules after moving them. · python/cpython@3da0b4c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3da0b4c

Browse files
Keep old names of sre_* modules after moving them.
1 parent cfc39b9 commit 3da0b4c

14 files changed

+52
-52
lines changed

Doc/library/modulefinder.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ Sample output (may vary depending on the architecture)::
9696
Loaded modules:
9797
_types:
9898
copyreg: _inverted_registry,_slotnames,__all__
99-
re._compiler: isstring,_sre,_optimize_unicode
99+
re.sre_compile: isstring,_sre,_optimize_unicode
100100
_sre:
101-
re._constants: REPEAT_ONE,makedict,AT_END_LINE
101+
re.sre_constants: REPEAT_ONE,makedict,AT_END_LINE
102102
sys:
103103
re: __module__,finditer,_expand
104104
itertools:
105105
__main__: re,itertools,baconhameggs
106-
re._parser: _PATTERNENDERS,SRE_FLAG_UNICODE
106+
re.sre_parse: _PATTERNENDERS,SRE_FLAG_UNICODE
107107
array:
108108
types: __module__,IntType,TypeType
109109
---------------------------------------------------

Doc/library/profile.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ the following::
7474
1 0.000 0.000 0.001 0.001 <string>:1(<module>)
7575
1 0.000 0.000 0.001 0.001 re.py:212(compile)
7676
1 0.000 0.000 0.001 0.001 re.py:268(_compile)
77-
1 0.000 0.000 0.000 0.000 _compiler.py:172(_compile_charset)
78-
1 0.000 0.000 0.000 0.000 _compiler.py:201(_optimize_charset)
79-
4 0.000 0.000 0.000 0.000 _compiler.py:25(_identityfunction)
80-
3/1 0.000 0.000 0.000 0.000 _compiler.py:33(_compile)
77+
1 0.000 0.000 0.000 0.000 sre_compile.py:172(_compile_charset)
78+
1 0.000 0.000 0.000 0.000 sre_compile.py:201(_optimize_charset)
79+
4 0.000 0.000 0.000 0.000 sre_compile.py:25(_identityfunction)
80+
3/1 0.000 0.000 0.000 0.000 sre_compile.py:33(_compile)
8181

8282
The first line indicates that 197 calls were monitored. Of those calls, 192
8383
were :dfn:`primitive`, meaning that the call was not induced via recursion. The

Lib/re/__init__.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"""
123123

124124
import enum
125-
from . import _compiler, _parser
125+
from . import sre_compile, sre_parse
126126
import functools
127127
try:
128128
import _locale
@@ -145,21 +145,21 @@
145145
@enum._simple_enum(enum.IntFlag, boundary=enum.KEEP)
146146
class RegexFlag:
147147
NOFLAG = 0
148-
ASCII = A = _compiler.SRE_FLAG_ASCII # assume ascii "locale"
149-
IGNORECASE = I = _compiler.SRE_FLAG_IGNORECASE # ignore case
150-
LOCALE = L = _compiler.SRE_FLAG_LOCALE # assume current 8-bit locale
151-
UNICODE = U = _compiler.SRE_FLAG_UNICODE # assume unicode "locale"
152-
MULTILINE = M = _compiler.SRE_FLAG_MULTILINE # make anchors look for newline
153-
DOTALL = S = _compiler.SRE_FLAG_DOTALL # make dot match newline
154-
VERBOSE = X = _compiler.SRE_FLAG_VERBOSE # ignore whitespace and comments
148+
ASCII = A = sre_compile.SRE_FLAG_ASCII # assume ascii "locale"
149+
IGNORECASE = I = sre_compile.SRE_FLAG_IGNORECASE # ignore case
150+
LOCALE = L = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale
151+
UNICODE = U = sre_compile.SRE_FLAG_UNICODE # assume unicode "locale"
152+
MULTILINE = M = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline
153+
DOTALL = S = sre_compile.SRE_FLAG_DOTALL # make dot match newline
154+
VERBOSE = X = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments
155155
# sre extensions (experimental, don't rely on these)
156-
TEMPLATE = T = _compiler.SRE_FLAG_TEMPLATE # disable backtracking
157-
DEBUG = _compiler.SRE_FLAG_DEBUG # dump pattern after compilation
156+
TEMPLATE = T = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking
157+
DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation
158158
__str__ = object.__str__
159159
_numeric_repr_ = hex
160160

161161
# sre exception
162-
error = _compiler.error
162+
error = sre_compile.error
163163

164164
# --------------------------------------------------------------------
165165
# public interface
@@ -256,8 +256,8 @@ def escape(pattern):
256256
pattern = str(pattern, 'latin1')
257257
return pattern.translate(_special_chars_map).encode('latin1')
258258

259-
Pattern = type(_compiler.compile('', 0))
260-
Match = type(_compiler.compile('', 0).match(''))
259+
Pattern = type(sre_compile.compile('', 0))
260+
Match = type(sre_compile.compile('', 0).match(''))
261261

262262
# --------------------------------------------------------------------
263263
# internals
@@ -278,9 +278,9 @@ def _compile(pattern, flags):
278278
raise ValueError(
279279
"cannot process flags argument with a compiled pattern")
280280
return pattern
281-
if not _compiler.isstring(pattern):
281+
if not sre_compile.isstring(pattern):
282282
raise TypeError("first argument must be string or compiled pattern")
283-
p = _compiler.compile(pattern, flags)
283+
p = sre_compile.compile(pattern, flags)
284284
if not (flags & DEBUG):
285285
if len(_cache) >= _MAXCACHE:
286286
# Drop the oldest item
@@ -294,12 +294,12 @@ def _compile(pattern, flags):
294294
@functools.lru_cache(_MAXCACHE)
295295
def _compile_repl(repl, pattern):
296296
# internal: compile replacement pattern
297-
return _parser.parse_template(repl, pattern)
297+
return sre_parse.parse_template(repl, pattern)
298298

299299
def _expand(pattern, match, template):
300300
# internal: Match.expand implementation hook
301-
template = _parser.parse_template(template, pattern)
302-
return _parser.expand_template(template, match)
301+
template = sre_parse.parse_template(template, pattern)
302+
return sre_parse.expand_template(template, match)
303303

304304
def _subx(pattern, template):
305305
# internal: Pattern.sub/subn implementation helper
@@ -308,7 +308,7 @@ def _subx(pattern, template):
308308
# literal replacement
309309
return template[1][0]
310310
def filter(match, template=template):
311-
return _parser.expand_template(template, match)
311+
return sre_parse.expand_template(template, match)
312312
return filter
313313

314314
# register myself for pickling
@@ -325,22 +325,22 @@ def _pickle(p):
325325

326326
class Scanner:
327327
def __init__(self, lexicon, flags=0):
328-
from ._constants import BRANCH, SUBPATTERN
328+
from .sre_constants import BRANCH, SUBPATTERN
329329
if isinstance(flags, RegexFlag):
330330
flags = flags.value
331331
self.lexicon = lexicon
332332
# combine phrases into a compound pattern
333333
p = []
334-
s = _parser.State()
334+
s = sre_parse.State()
335335
s.flags = flags
336336
for phrase, action in lexicon:
337337
gid = s.opengroup()
338-
p.append(_parser.SubPattern(s, [
339-
(SUBPATTERN, (gid, 0, 0, _parser.parse(phrase, flags))),
338+
p.append(sre_parse.SubPattern(s, [
339+
(SUBPATTERN, (gid, 0, 0, sre_parse.parse(phrase, flags))),
340340
]))
341341
s.closegroup(gid, p[-1])
342-
p = _parser.SubPattern(s, [(BRANCH, (None, p))])
343-
self.scanner = _compiler.compile(p)
342+
p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
343+
self.scanner = sre_compile.compile(p)
344344
def scan(self, string):
345345
result = []
346346
append = result.append

Lib/re/_compiler.py renamed to Lib/re/sre_compile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"""Internal support module for sre"""
1212

1313
import _sre
14-
from . import _parser
15-
from ._constants import *
14+
from . import sre_parse
15+
from .sre_constants import *
1616

1717
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
1818

@@ -68,7 +68,7 @@
6868
for t in _equivalences for i in t}
6969

7070
def _combine_flags(flags, add_flags, del_flags,
71-
TYPE_FLAGS=_parser.TYPE_FLAGS):
71+
TYPE_FLAGS=sre_parse.TYPE_FLAGS):
7272
if add_flags & TYPE_FLAGS:
7373
flags &= ~TYPE_FLAGS
7474
return (flags | add_flags) & ~del_flags
@@ -777,7 +777,7 @@ def compile(p, flags=0):
777777

778778
if isstring(p):
779779
pattern = p
780-
p = _parser.parse(p, flags)
780+
p = sre_parse.parse(p, flags)
781781
else:
782782
pattern = None
783783

Lib/re/_constants.py renamed to Lib/re/sre_constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ def dump(f, d, prefix):
229229
*
230230
* regular expression matching engine
231231
*
232-
* NOTE: This file is generated by Lib/re/_constants.py. If you need
233-
* to change anything in here, edit Lib/re/_constants.py and run it.
232+
* NOTE: This file is generated by Lib/re/sre_constants.py. If you need
233+
* to change anything in here, edit Lib/re/sre_constants.py and run it.
234234
*
235235
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
236236
*

Lib/re/_parser.py renamed to Lib/re/sre_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# XXX: show string offset and offending character for all errors
1414

15-
from ._constants import *
15+
from .sre_constants import *
1616

1717
SPECIAL_CHARS = ".\\[{()*+?^$|"
1818
REPEAT_CHARS = "*+?{"

Lib/sre_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
DeprecationWarning,
44
stacklevel=2)
55

6-
from re._compiler import *
6+
from re.sre_compile import *

Lib/sre_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
DeprecationWarning,
44
stacklevel=2)
55

6-
from re._constants import *
6+
from re.sre_constants import *

Lib/sre_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
DeprecationWarning,
44
stacklevel=2)
55

6-
from re._parser import *
6+
from re.sre_parse import *
Lib/test/test_pyclbr.py
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_others(self):
221221
cm('cgi', ignore=('log',)) # set with = in module
222222
cm('pickle', ignore=('partial', 'PickleBuffer'))
223223
cm('aifc', ignore=('_aifc_params',)) # set with = in module
224-
cm('re._parser', ignore=('dump', 'groups', 'pos')) # from ._constants import *; property
224+
cm('re.sre_parse', ignore=('dump', 'groups', 'pos')) # from .sre_constants import *; property
225225
cm(
226226
'pdb',
227227
# pyclbr does not handle elegantly `typing` or properties

Lib/test/test_re.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def test_re_groupref_exists(self):
569569
'two branches', 10)
570570

571571
def test_re_groupref_overflow(self):
572-
from re._constants import MAXGROUPS
572+
from re.sre_constants import MAXGROUPS
573573
self.checkTemplateError('()', r'\g<%s>' % MAXGROUPS, 'xx',
574574
'invalid group reference %d' % MAXGROUPS, 3)
575575
self.checkPatternError(r'(?P<a>)(?(%d))' % MAXGROUPS,
@@ -2433,7 +2433,7 @@ def test_immutable(self):
24332433
tp.foo = 1
24342434

24352435
def test_overlap_table(self):
2436-
f = re._compiler._generate_overlap_table
2436+
f = re.sre_compile._generate_overlap_table
24372437
self.assertEqual(f(""), [])
24382438
self.assertEqual(f("a"), [0])
24392439
self.assertEqual(f("abcd"), [0, 0, 0, 0])
@@ -2442,8 +2442,8 @@ def test_overlap_table(self):
24422442
self.assertEqual(f("abcabdac"), [0, 0, 0, 1, 2, 0, 1, 0])
24432443

24442444
def test_signedness(self):
2445-
self.assertGreaterEqual(re._compiler.MAXREPEAT, 0)
2446-
self.assertGreaterEqual(re._compiler.MAXGROUPS, 0)
2445+
self.assertGreaterEqual(re.sre_compile.MAXREPEAT, 0)
2446+
self.assertGreaterEqual(re.sre_compile.MAXGROUPS, 0)
24472447

24482448
@cpython_only
24492449
def test_disallow_instantiation(self):

Lib/test/test_site.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def test_startup_imports(self):
523523
self.assertIn('site', modules)
524524

525525
# http://bugs.python.org/issue19205
526-
re_mods = {'re', '_sre', 're._compiler', 're._constants', 're._parser'}
526+
re_mods = {'re', '_sre', 're.sre_compile', 're.sre_constants', 're.sre_parse'}
527527
self.assertFalse(modules.intersection(re_mods), stderr)
528528

529529
# http://bugs.python.org/issue9548
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Convert the :mod:`re` module into a package. Deprecate modules ``sre_compile``,
2-
``sre_constants`` and ``sre_parse``.
1+
Convert the :mod:`re` module into a package. Deprecate undocumented modules
2+
``sre_compile``, ``sre_constants`` and ``sre_parse``.

Modules/sre_constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*
44
* regular expression matching engine
55
*
6-
* NOTE: This file is generated by Lib/re/_constants.py. If you need
7-
* to change anything in here, edit Lib/re/_constants.py and run it.
6+
* NOTE: This file is generated by Lib/re/sre_constants.py. If you need
7+
* to change anything in here, edit Lib/re/sre_constants.py and run it.
88
*
99
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
1010
*

0 commit comments

Comments
 (0)
0