Skip to content

Commit 83c44e0

Browse files
S-YOUtrotterdylan
authored andcommitted
Chore third party libs (use stdlib whenever possible) (google#145)
* move functools.py to stdlib * move md5.py to stdlib * move re.py re_tests.py sre_*.py to stdlib
1 parent 88e43ac commit 83c44e0

File tree

8 files changed

+28
-37
lines changed

8 files changed

+28
-37
lines changed

third_party/pypy/md5.py

Lines changed: 0 additions & 22 deletions
This file was deleted.
File renamed without changes.

third_party/stdlib/md5.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# $Id$
2+
#
3+
# Copyright (C) 2005 Gregory P. Smith ([email protected])
4+
# Licensed to PSF under a Contributor Agreement.
5+
6+
# import warnings
7+
# warnings.warn("the md5 module is deprecated; use hashlib instead",
8+
# DeprecationWarning, 2)
9+
10+
# from hashlib import md5
11+
import _md5
12+
13+
new = _md5.new
14+
md5 = _md5.new
15+
digest_size = 16

third_party/pypy/re.py renamed to third_party/stdlib/re.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
import sre_compile
105105
import sre_parse
106106

107+
# try:
108+
# import _locale
109+
# except ImportError:
110+
# _locale = None
107111
_locale = None
108112
BRANCH = "branch"
109113
SUBPATTERN = "subpattern"
@@ -194,10 +198,8 @@ def compile(pattern, flags=0):
194198

195199
def purge():
196200
"Clear the regular expression cache"
197-
# _cache.clear()
198-
# _cache_repl.clear()
199-
globals()['_cache'] = {}
200-
globals()['_cache_repl'] = {}
201+
_cache.clear()
202+
_cache_repl.clear()
201203

202204
def template(pattern, flags=0):
203205
"Compile a template pattern, returning a pattern object"
@@ -252,8 +254,7 @@ def _compile(*key):
252254
raise error, v # invalid expression
253255
if not bypass_cache:
254256
if len(_cache) >= _MAXCACHE:
255-
# _cache.clear()
256-
globals()['_cache'] = {}
257+
_cache.clear()
257258
if p.flags & LOCALE:
258259
if not _locale:
259260
return p
@@ -274,8 +275,7 @@ def _compile_repl(*key):
274275
except error, v:
275276
raise error, v # invalid expression
276277
if len(_cache_repl) >= _MAXCACHE:
277-
# _cache_repl.clear()
278-
globals()['_cache_repl'] = {}
278+
_cache_repl.clear()
279279
_cache_repl[key] = p
280280
return p
281281

File renamed without changes.
File renamed without changes.

third_party/pypy/sre_parse.py renamed to third_party/stdlib/sre_parse.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010

1111
"""Internal support module for sre"""
1212

13-
# TODO: Support from foo import * syntax.
14-
import sre_constants
15-
for name in sre_constants.__all__:
16-
globals()[name] = getattr(sre_constants, name)
17-
1813
# XXX: show string offset and offending character for all errors
1914

2015
import sys
2116

22-
newdict = lambda _ : {}
17+
# from sre_constants import *
18+
import sre_constants
19+
for name in sre_constants.__all__:
20+
globals()[name] = getattr(sre_constants, name)
2321

2422
SPECIAL_CHARS = ".\\[{()*+?^$|"
2523
REPEAT_CHARS = "*+?{"
@@ -73,7 +71,7 @@ def __init__(self):
7371
self.flags = 0
7472
self.open = []
7573
self.groups = 1
76-
self.groupdict = newdict("module")
74+
self.groupdict = {}
7775
self.lookbehind = 0
7876

7977
def opengroup(self, name=None):

0 commit comments

Comments
 (0)