Skip to content

Commit

Permalink
Fixed compatibility with ply 3.6
Browse files Browse the repository at this point in the history
In newly released ply 3.6 function yacc() of the yacc module no longer
accepts 'None' as the 'tabmodule' keyword parameter and expects a valid
string instead.
Meanwhile, the tabmodule file is not created unless write_tables is set
to True.

This patchset provides such a string and ensures that it is unique.
Omitting the 'tabmodule' parameter at all could possibly do the trick as
well, however that would mean that the parameter would get its default
value - 'parsetab' - which could potentially lead to a minor security
vulnerability if the the system somehow had got a malicious 'parsetab'
module (as yacc attempts to load the generated tables from module
specified by 'tabmodule' before proceeding to grammar generation).
Assigning a random value to this parameter prevents such a situation.

This patch also fixes the ply requirement to <=3.6 to prevent future
gate breakages due to unexpected changes in ply.

Closes-Bug: #1448990

Change-Id: I4364729223521864f7cda5a932503d7ce1b6fa36
  • Loading branch information
Alexander Tivelkov committed Apr 28, 2015
1 parent 696c811 commit f59e459
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pbr>=0.6,!=0.7,<1.0
Babel>=0.9.6

ply
six>=1.7.0
ply<=3.6
six>=1.7.0
3 changes: 2 additions & 1 deletion yaql/language/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import collections
import re
import uuid

from ply import lex
from ply import yacc
Expand Down Expand Up @@ -227,6 +228,6 @@ def create(self, options=None):
ply_parser = yacc.yacc(
module=self._create_parser(lexer_rules, operators),
debug=False if not options else options.get("yaql.debug", False),
tabmodule=None, write_tables=False)
tabmodule='m' + uuid.uuid4().hex, write_tables=False)

return YaqlEngine(ply_lexer, ply_parser, options, self)

0 comments on commit f59e459

Please sign in to comment.