-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python3 build problem #8
Comments
The problem you're seeing is because of the:
statememnt in phplexpy. In python3, this returns an iterator object rather than the tuple/list returned in python 2. A simple fix is to change
in phpparse.py to
|
ok thanks! changing that makes the build fail just after
they seems all related to the same error |
I fixed the other problems in this patch (I guess) Description: This patch makes the package python3 ready
Author: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
Neil Muller
Forwarded: https://github.com/ramen/phply/issues/8
Last-Update: 2015-02-19
Index: python-phply/phply/phpparse.py
===================================================================
--- python-phply.orig/phply/phpparse.py 2015-02-21 16:44:56.306062304 +0100
+++ python-phply/phply/phpparse.py 2015-02-21 16:44:56.302062296 +0100
@@ -6,12 +6,12 @@
import os
import sys
-import phplex
-import phpast as ast
+from phply import phplex
+from phply import phpast as ast
import ply.yacc as yacc
# Get the token map
-tokens = phplex.tokens
+tokens = tuple(phplex.tokens)
precedence = (
('left', 'INCLUDE', 'INCLUDE_ONCE', 'EVAL', 'REQUIRE', 'REQUIRE_ONCE'),
@@ -1189,7 +1189,10 @@
elif len(p) == 3:
p[0] = ''
else:
- p[0] = p[2].decode('string_escape')
+ if (sys.version_info > (3, 0)):
+ p[0] = bytes(p[2], "utf-8").decode('unicode_escape')
+ else:
+ p[0] = p[2].decode('string_escape')
def p_static_scalar_namespace_name(p):
'''static_scalar : namespace_name
@@ -1257,10 +1260,17 @@
def p_encaps_list_string(p):
'encaps_list : encaps_list ENCAPSED_AND_WHITESPACE'
if p[1] == '':
- p[0] = p[2].decode('string_escape')
+ if (sys.version_info > (3, 0)):
+ p[0] = bytes(p[2], "utf-8").decode('unicode_escape')
+ else:
+ p[0] = p[2].decode('string_escape')
else:
- p[0] = ast.BinaryOp('.', p[1], p[2].decode('string_escape'),
- lineno=p.lineno(2))
+ if (sys.version_info > (3, 0)):
+ p[0] = ast.BinaryOp('.', p[1], bytes(p[2], "utf-8").decode('unicode_escape'),
+ lineno=p.lineno(2))
+ else:
+ p[0] = ast.BinaryOp('.', p[1], p[2].decode('string_escape'),
+ lineno=p.lineno(2))
def p_encaps_var(p):
'encaps_var : VARIABLE'
@@ -1336,9 +1346,9 @@
try:
lexer.lineno = 1
result = parser.parse(s, lexer=lexer)
- except SyntaxError, e:
+ except SyntaxError as e:
if e.lineno is not None:
- print e, 'near', repr(e.text)
+ print (e, 'near', repr(e.text))
s = ''
continue
if result:
Index: python-phply/tests/test_lexer.py
===================================================================
--- python-phply.orig/tests/test_lexer.py 2015-02-21 16:44:56.306062304 +0100
+++ python-phply/tests/test_lexer.py 2015-02-21 16:44:56.302062296 +0100
@@ -14,13 +14,13 @@
if tok.type in ignore: continue
output.append((tok.type, tok.value))
- print 'Lexer output:'
+ print ('Lexer output:')
pprint.pprint(output)
print
- print 'Token by token:'
+ print ('Token by token:')
for out, exp in zip(output, expected):
- print '\tgot:', out, '\texpected:', exp
+ print ('\tgot:', out, '\texpected:', exp)
nose.tools.eq_(out, exp)
assert len(output) == len(expected), \
Index: python-phply/tests/test_parser.py
===================================================================
--- python-phply.orig/tests/test_parser.py 2015-02-21 16:44:56.306062304 +0100
+++ python-phply/tests/test_parser.py 2015-02-21 16:44:56.302062296 +0100
@@ -11,13 +11,13 @@
output = parser.parse(input, lexer=lexer)
resolve_magic_constants(output)
- print 'Parser output:'
+ print ('Parser output:')
pprint.pprint(output)
print
- print 'Node by node:'
+ print ('Node by node:')
for out, exp in zip(output, expected):
- print '\tgot:', out, '\texpected:', exp
+ print ('\tgot:', out, '\texpected:', exp)
nose.tools.eq_(out, exp)
assert len(output) == len(expected), \
Index: python-phply/tools/phpshell.py
===================================================================
--- python-phply.orig/tools/phpshell.py 2015-02-21 16:44:56.306062304 +0100
+++ python-phply/tools/phpshell.py 2015-02-21 16:44:56.302062296 +0100
@@ -21,11 +21,11 @@
sys.stdout.write(obj)
def XXX(obj):
- print 'Not implemented:\n ', obj
+ print ('Not implemented:\n ', obj)
def ast_dump(code):
- print 'AST dump:'
- print ' ', ast.dump(code, include_attributes=True)
+ print ('AST dump:')
+ print (' ', ast.dump(code, include_attributes=True))
def php_eval(nodes):
body = []
@@ -63,7 +63,7 @@
lexer.lineno = 1
result = parser.parse(s, lexer=lexer)
php_eval(result)
- except SyntaxError, e:
+ except SyntaxError as e:
# Parsing failed. See if it can be parsed as an expression.
try:
lexer.lineno = 1
@@ -81,7 +81,7 @@
if e.lineno is None:
continue
else:
- print e, 'near', repr(e.text)
+ print (e, 'near', repr(e.text))
s = ''
except:
traceback.print_exc()
Index: python-phply/tools/unparse.py
===================================================================
--- python-phply.orig/tools/unparse.py 2015-02-21 16:44:56.306062304 +0100
+++ python-phply/tools/unparse.py 2015-02-21 16:44:56.302062296 +0100
@@ -28,7 +28,7 @@
self.f = file
self._indent = 0
self.dispatch(tree)
- print >>self.f,""
+ self.f.write("")
self.f.flush()
def fill(self, text = ""):
@@ -492,17 +492,17 @@
try:
names = [n for n in os.listdir(a) if n.endswith('.py')]
except OSError:
- print >> sys.stderr, "Directory not readable: %s" % a
+ print ("Directory not readable: %s" % a, file=sys.stderr)
else:
for n in names:
fullname = os.path.join(a, n)
if os.path.isfile(fullname):
output = cStringIO.StringIO()
- print 'Testing %s' % fullname
+ print ('Testing %s' % fullname)
try:
roundtrip(fullname, output)
- except Exception, e:
- print ' Failed to compile, exception is %s' % repr(e)
+ except Exception as e:
+ print (' Failed to compile, exception is %s' % repr(e))
elif os.path.isdir(fullname):
testdir(fullname)
|
Thank you for raising this @LocutusOfBorg ! Another series of patches has been merged for py3 support and it should be pretty much equivalent. If you see other py3 issues, please raise them :) |
Hi, just release a new version and I'll notify/report them :) |
Hi, in my effort to make the package going into debian I did some tweaks to make it work on python-3.4
this is the patch
note: I'm not a python developer.
However I'm stuck with a problem I don't know how to figure out
The text was updated successfully, but these errors were encountered: