summaryrefslogtreecommitdiff
path: root/pygments/lexers/sql.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-05-08 13:20:12 +0200
committerGeorg Brandl <georg@python.org>2012-05-08 13:20:12 +0200
commitfe70ea7412b05ca7361fb9e96aaaff02e6b56107 (patch)
tree1f66851a02290c5108550938f96168da7234bbd5 /pygments/lexers/sql.py
parent2203614c8548f8b36042d7d1e9e0208fa8422dfd (diff)
downloadpygments-fe70ea7412b05ca7361fb9e96aaaff02e6b56107.tar.gz
Closes #749: get rid of deepcopy usage to restore 2.4 compatibility
Diffstat (limited to 'pygments/lexers/sql.py')
-rw-r--r--pygments/lexers/sql.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/pygments/lexers/sql.py b/pygments/lexers/sql.py
index 656d29a7..e7e02fce 100644
--- a/pygments/lexers/sql.py
+++ b/pygments/lexers/sql.py
@@ -39,7 +39,6 @@
"""
import re
-from copy import deepcopy
from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups
from pygments.token import Punctuation, \
@@ -61,9 +60,6 @@ def language_callback(lexer, match):
"""Parse the content of a $-string using a lexer
The lexer is chosen looking for a nearby LANGUAGE.
-
- Note: this function should have been a `PostgresBase` method, but the
- rules deepcopy fails in this case.
"""
l = None
m = language_re.match(lexer.text[match.end():match.end()+100])
@@ -93,8 +89,6 @@ class PostgresBase(object):
had, _tokens could be created on this ancestor and not updated for the
other classes, resulting e.g. in PL/pgSQL parsed as SQL. This shortcoming
seem to suggest that regexp lexers are not really subclassable.
-
- `language_callback` should really be our method, but this breaks deepcopy.
"""
def get_tokens_unprocessed(self, text, *args):
# Have a copy of the entire text to be used by `language_callback`.
@@ -182,7 +176,7 @@ class PlPgsqlLexer(PostgresBase, RegexLexer):
mimetypes = ['text/x-plpgsql']
flags = re.IGNORECASE
- tokens = deepcopy(PostgresLexer.tokens)
+ tokens = dict((k, l[:]) for (k, l) in PostgresLexer.tokens.iteritems())
# extend the keywords list
for i, pattern in enumerate(tokens['root']):
@@ -216,7 +210,7 @@ class PsqlRegexLexer(PostgresBase, RegexLexer):
aliases = [] # not public
flags = re.IGNORECASE
- tokens = deepcopy(PostgresLexer.tokens)
+ tokens = dict((k, l[:]) for (k, l) in PostgresLexer.tokens.iteritems())
tokens['root'].append(
(r'\\[^\s]+', Keyword.Pseudo, 'psql-command'))