Commits

Georg Brandl committed 5b45626

Closes #749: get rid of deepcopy usage to restore 2.4 compatibility

Comments (0)

Files changed (1)

pygments/lexers/sql.py

 """
 
 import re
-from copy import deepcopy
 
 from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups
 from pygments.token import Punctuation, \
     """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])
     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`.
     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']):
     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'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.