Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c994f83

Browse filesBrowse files
committed
some changes for py3 compat
1 parent 2d5e911 commit c994f83
Copy full SHA for c994f83

File tree

Expand file treeCollapse file tree

3 files changed

+13
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+13
-7
lines changed
Open diff view settings
Collapse file

‎java2python/config/default.py‎

Copy file name to clipboardExpand all lines: java2python/config/default.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
modulePrologueHandlers = [
2525
basic.shebangLine,
2626
basic.simpleDocString,
27+
'from __future__ import print_function',
2728
basic.maybeBsr,
2829
basic.maybeSyncHelpers,
2930
]
@@ -193,8 +194,8 @@
193194

194195
# module output subs.
195196
moduleOutputSubs = [
196-
(r'System\.out\.println\((.*)\)', r'print \1'),
197-
(r'System\.out\.print_\((.*?)\)', r'print \1,'),
197+
(r'System\.out\.println\((.*)\)', r'print(\1)'),
198+
(r'System\.out\.print_\((.*?)\)', r'print(\1, end="")'),
198199
(r'(.*?)\.equals\((.*?)\)', r'\1 == \2'),
199200
(r'(.*?)\.equalsIgnoreCase\((.*?)\)', r'\1.lower() == \2.lower()'),
200201
(r'([\w.]+)\.size\(\)', r'len(\1)'),
Collapse file

‎java2python/mod/include/overloading.py‎

Copy file name to clipboardExpand all lines: java2python/mod/include/overloading.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
3737
"""
3838

39-
import new
39+
from types import MethodType as instancemethod
4040

41-
# Make the environment more like Python 3.0
42-
__metaclass__ = type
43-
from itertools import izip as zip
41+
import sys
42+
if sys.version_info[0] < 3:
43+
# Make the environment more like Python 3.0
44+
__metaclass__ = type
45+
from itertools import izip as zip
4446

4547

4648
class overloaded:
@@ -55,7 +57,7 @@ def __init__(self, default_func):
5557
def __get__(self, obj, type=None):
5658
if obj is None:
5759
return self
58-
return new.instancemethod(self, obj)
60+
return instancemethod(self, obj)
5961

6062
def register(self, *types):
6163
"""Decorator to register an implementation for a specific set of types.
Collapse file

‎test/Self0.java‎

Copy file name to clipboardExpand all lines: test/Self0.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public static void main(String[] args) {
1717
System.out.println("True");
1818
else
1919
System.out.println("False");
20+
System.out.print("test");
21+
System.out.print("ing");
22+
System.out.println();
2023
}
2124

2225
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.