You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 31, 2020. It is now read-only.
This is probably abuse of string literals, but the following code works in cPython:
def generate_code():
print('big_string = """\\')
for i in range(65536//64):
s = (str(i)+'_') * 32
print(s[:63])
print('"""')
big_string = """\
0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1
[Trimmed for sanity. Run generate_code() to generate 64Kb string.]
1022_1022_1022_1022_1022_1022_1022_1022_1022_1022_1022_1022_102
1023_1023_1023_1023_1023_1023_1023_1023_1023_1023_1023_1023_102
"""
print('String size:', len(big_string))
# generate_code()
When I run that in cPython, I see the size of the string:
$ python take_test.py
String size: 65536
When I run it in voc, I get an error:
$ voc -v take_test.py && java -classpath ../voc/dist/python-java-support.jar:. python.take_test
Compiling take_test.py ...
Writing ./python/take_test.class ...
Traceback (most recent call last):
File "/home/don/.local/share/virtualenvs/voc-tutorial-YXlPRKgA/bin/voc", line 11, in <module>
load_entry_point('voc', 'console_scripts', 'voc')()
File "/home/don/git/voc-tutorial/voc/voc/__main__.py", line 52, in main
verbosity=args.verbosity
File "/home/don/git/voc-tutorial/voc/voc/transpiler.py", line 33, in transpile
transpiler.write(outdir)
File "/home/don/git/voc-tutorial/voc/voc/transpiler.py", line 62, in write
javaclassfile.write(out)
File "/home/don/git/voc-tutorial/voc/voc/java/klass.py", line 422, in write
constant_pool.write(writer)
File "/home/don/git/voc-tutorial/voc/voc/java/constants.py", line 151, in write
constant.write(writer)
File "/home/don/git/voc-tutorial/voc/voc/java/constants.py", line 211, in write
self.write_info(writer)
File "/home/don/git/voc-tutorial/voc/voc/java/constants.py", line 981, in write_info
writer.write_u2(self.length)
File "/home/don/git/voc-tutorial/voc/voc/java/klass.py", line 73, in write_u2
self._outfile.write(struct.pack('>H', u2))
struct.error: 'H' format requires 0 <= number <= 65535
I can work around it by adding two smaller strings together, like this:
big_string = """\
0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0
1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1
[Trimmed for sanity. Run generate_code() to generate 64Kb string.]
1022_1022_1022_1022_1022_1022_1022_1022_1022_1022_1022_1022_102
1023_1023_1023_1023_1023_1023_1023_1023_1023_1023_1023_1023_10
""" + "2"
print('String size:', len(big_string))
I'm running this with voc 0.1.5, Python 3.5.2, and Ubuntu 16.04.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is probably abuse of string literals, but the following code works in cPython:
When I run that in cPython, I see the size of the string:
When I run it in
voc
, I get an error:I can work around it by adding two smaller strings together, like this:
I'm running this with voc 0.1.5, Python 3.5.2, and Ubuntu 16.04.
The text was updated successfully, but these errors were encountered: