These are chat archives for pybee/general

12th
Mar 2017
Deepankar Agrawal
@deep110
Mar 12 2017 00:01

@freakboy3742 @eliasdorneles I was trying to solve this bug pybee/voc#361. I have isolated the problem but need some help :sweat_smile:
Main problem is that if it is not finding python module then, it thinks it is a native module instead of throwing error. here
So basically when it can't import it as python module, it again calls importNativeModule as fallback, and in that it tries to load it as native class (here). There the loader always throws ClassNotFoundException, even when loading native class (didn't understood clearly, but I think the thread doesn't have any class loaded). Then, in catch whatever module we have, it considers it as a native class, hence the error afterwards. (here)

So is there someway to check if that class exists or not, or something which can confirm it is a native module, so that ImportErrorcould be thrown. :confused:

Chiang Fong Lee
@cflee
Mar 12 2017 03:22
@Saurabh--Kumar could you check if print(some_list) works fine, and it’s only print(enumerate(some_list)) that’s throwing that exception?
that said, I was poking around in the python interpreter as well, and I noticed this:
>>> ls = ['a', 'b', 'c']
>>> print(enumerate(ls))
<enumerate object at 0x108c803f0>
>>> print(list(enumerate(ls)))
[(0, 'a'), (1, 'b'), (2, 'c’)]
so I guess print(enumerate(some_list)) shouldn’t crash, but it shouldn’t be printing out the list either. but you can also see if pint(list(enumerate(some_list))) works or crashes too
another idea might be that if you look at the other builtin functions, their parameters are always of type org.python.Object, then they do the type checks inside and cast it if it’s correct
Shivendra Kumar
@bitdumper1
Mar 12 2017 04:05
Hi! I am Shivendra Kumar.
how can i convert String[] to org.python.types.List
String[] result = someArray;
java.util.List result_list = Arrays.asList(result);
return new org.python.types.List(result_list);
this gives me RuntimeError: java.lang.String cannot be cast to org.python.Object
Arpit Nandwani
@arpitn30
Mar 12 2017 07:58

Hello, I'm a computer science undergraduate student in the pre final year of my college. I work on Python on a regular basis along with javascript and MySQL/PostgreSQL. I'm well versed with java and linux environment. Some of my opensource projects can be seen on my github profile https://github.com/arpitn30.

I am really excited to work with BeeWare project due to its focus on promoting cross platform development. I looked into the projects mentioned on your page and found VOC and Ouroboros really interesting. It would really be helpful if someone could guide me on how to proceed further so I can begin working on it early on.

Saurabh--Kumar
@Saurabh--Kumar
Mar 12 2017 12:15
@cflee the standard enumerate() function returns a lazy iterator. I discussed this issue with @eliasdorneles , he told me to implement a version which returns a org.python.types.List for the time being. so print(enumerate(some_list)) should work fine with my implementation. Regardless, I tried with print(list(enumerate(some_list)))and I get the same runtime error. Exception in thread "main" RuntimeError: java.lang.NullPointerException at org.python.types.Function.invoke(Function.java:412) at org.python.types.Function.invoke(Function.java:347) at python.example.__init__.module$import(example.py:4) at python.example.__init__.main(example.py) .The surprising thing is that I don't get any error for running enumerate(some_list).
I have used try and catch block to catch if iterator is returned by the object and to check for StopIteration exception.
Any idea about what could be going wrong?
Shivendra Kumar
@bitdumper1
Mar 12 2017 13:17
I solved my problem using iteration and made the pull request #407
Elias Dorneles
@eliasdorneles
Mar 12 2017 13:17
@Saurabh--Kumar let me have a look...
btw, you should still use print(list(enumerate(some_list))) on the tests for your code, because even though it will return a list, it should be an implementation detail and not something someone a VOC user should rely on
Elias Dorneles
@eliasdorneles
Mar 12 2017 13:39
@Saurabh--Kumar about the code you've pasted, I've noticed a few things:
  • the tuple inside the Python list should be org.python.types.Tuple, not a Java ArrayList (namly, you have to do enumList.add(new org.python.types.Tuple(tuple));)
  • the return type should still be org.python.Iterable -- you can return return org.Python.iter(new org.python.types.List(enumList));to make the compiler happy
  • are you providing the default value for start? It's not enough just to put default_args = {"start"} in the signature, this just means that callers can call without providing a value, you should still check for null and set the default value
Saurabh--Kumar
@Saurabh--Kumar
Mar 12 2017 14:28
Thanks @eliasdorneles . I had corrected the issue with Tuple later on but 'start' argument was causing the problem. Do I need to write tests before submitting a PR? Is there any documentation regarding test writing conventions?
Chiang Fong Lee
@cflee
Mar 12 2017 14:38
@Saurabh--Kumar yes, generally any change that adds/fixes functionality needs to be tested – so that could be a previously-failing test that is now passing, or newly added tests that exercise all the normal, error and edge cases
I’m not sure if that’s written anywhere… we probably should have that somewhere in the contributing guide!
Saurabh--Kumar
@Saurabh--Kumar
Mar 12 2017 14:39
@cflee it is not written in the guide. Regardless, does voc use pytest?
Chiang Fong Lee
@cflee
Mar 12 2017 14:41
yep – you can run the tests with python setup.py test or py.test
gilmouta
@gilmouta
Mar 12 2017 15:12
I also think you should add the flake8 and ant checkstyle commands to the contributing guide, since they are needed to pass on the CI. Speaking of which, how can I run ant checkstyle on my local machine? I get this error when I try it: voc\build-java.xml:63: Unable to process files: <Every File>
Chiang Fong Lee
@cflee
Mar 12 2017 15:16
@gilmouta that’s a good idea! we always welcome improvements to the docs, especially since fresh eyes will know what’s missing better :)
as for ant: are you running this on windows?
if so, could you edit that line in build-java.xml:63 to replace config with configURL and see if it works? it seems like an issue in checkstyle (checkstyle/checkstyle#3119), we might need to make that change
gilmouta
@gilmouta
Mar 12 2017 15:30
That seems to be the problem, yes. However replacing config with configURL resulted in another error, voc\build-java.xml:63: java.net.MalformedURLException: no protocol: checkstyle.xml. It looks like it's expecting an URL and not a file.
Chiang Fong Lee
@cflee
Mar 12 2017 15:35
hmm. perhaps configURL="${project.projectDir}/checkstyle.xml”?
ok maybe not. I better check the ant docs first
gilmouta
@gilmouta
Mar 12 2017 15:37
Ok, thanks :)
Chiang Fong Lee
@cflee
Mar 12 2017 15:45
@gilmouta okay, that was gradle instead of ant syntax. this url works on mac os, hopefully it works on windows too: configURL="file:///${basedir}/checkstyle.xml”
gilmouta
@gilmouta
Mar 12 2017 15:55
@cflee Same error as the first one. However this time I noticed this also shows up: Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST. It showed up before but I didn't notice it, not sure if it's relevant.
Chiang Fong Lee
@cflee
Mar 12 2017 16:02
@gilmouta what is your environment like - OS, java version, ant version
gilmouta
@gilmouta
Mar 12 2017 16:03
@cflee Windows 10, Java 1.8, Ant 1.10.1
Chiang Fong Lee
@cflee
Mar 12 2017 16:06
@gilmouta hmm, I’m not too sure. everything that google pulls up for that error is about having the antlr-2.7.7 jars somewhere on your/ant classpath, but I’m not sure if you could accidentally get that installed on Windows
(or some other version of antlr on the ant classpath – somehow there are 10+ year old mailing list messages/blog posts about this. e.g. http://lists.alioth.debian.org/pipermail/pkg-java-maintainers/2005-April/003174.html)
gilmouta
@gilmouta
Mar 12 2017 16:22
@cflee Well, the magic of reinstalling ant worked. I went back to config="checkstyle.xml" and it also worked. Can't say I understand what happened but thanks for your help!
Chiang Fong Lee
@cflee
Mar 12 2017 16:23
@gilmouta :thumbsup: great to hear that it’s working now!
Saurabh--Kumar
@Saurabh--Kumar
Mar 12 2017 16:59
hi everyone. I have submitted a PR pybee/voc#408 for voc project(inbuilt enumerate function). please review it. Thanks.
Nimish Singhal
@ASP1234
Mar 12 2017 18:31
I'm working on len() builtin fn, I fixed bytearray thing, working on other types
Nimish Singhal
@ASP1234
Mar 12 2017 19:35
I'm trying to implement FrozenSet constructors but keep getting this ' No Python-compatible constructor for type class org.python.types.FrozenSet' , even though the constructor def matches it.
AD Mohanraj
@ad1269
Mar 12 2017 20:01
Hey guys! I implemented support for adding floats to complex numbers, and tested it personally by running the test cases that the actual tester uses. I'm getting the same output from both Python and from VOC, however, when running the tests, it still says expected failure. Any ideas on how I could troubleshoot this?
Nimish Singhal
@ASP1234
Mar 12 2017 20:02
Remove it from not implemented list in the test class
AD Mohanraj
@ad1269
Mar 12 2017 20:10
Thanks! That worked!
Nimish Singhal
@ASP1234
Mar 12 2017 20:15
:)