These are chat archives for pybee/general

14th
Mar 2017
Guillermo Ramos-Macias
@memo330179
Mar 14 2017 00:40

Hi guys, My name is Guillermo. I am a third year student studying computer science.

I absolutely love the idea of running python in the browser. I remember hearing about the project on the Talk Python to Me podcast and thinking how cool it was that a project like this existed.

I would like to contribute to the project as a part of the Google Summer of Code. I love the kind of challenges that the project would present. Last summer I contributed to another Open Source Project PHETsims (not through summer of code) and I really enjoyed the experience.

I would love to talk about what the project needs from me. I have some ideas and would like to narrow them down to something that is both useful and feasible over the summer.

Russell Keith-Magee
@freakboy3742
Mar 14 2017 01:09
@memo330179 Hi! Our guide to getting started withthe GSoC is here: https://github.com/pybee/pybee.github.io/wiki/So-you-want-to-be-a-BeeWare-GSoC-student%3F - if you’ve got any questions, just ask!
@Ocupe Unfortunately, I don’t - I usually end up spending some quality time with the macOS API docs. I’m guessing you’ll need to work out how to get a handle to the App menu, and put it in there.
leasunhy
@leasunhy
Mar 14 2017 03:13

Hi, when I am writing inline selection logic for __add__ and __radd__, I have run into this issue:

Traceback (most recent call last):
  File "/home/leasunhy/voc/voc-github/voc/python/ast.py", line 160, in visit
    super().visit(node)
  File "/usr/lib64/python3.4/ast.py", line 245, in visit
    return visitor(node)
  File "/home/leasunhy/voc/voc-github/voc/python/ast.py", line 49, in dec
    fn(self, node)
  File "/home/leasunhy/voc/voc-github/voc/python/ast.py", line 1011, in visit_BinOp
    JavaOpcodes.ICONST_0,
  File "/home/leasunhy/voc/voc-github/voc/python/blocks.py", line 38, in add_opcodes
    if opcode.process(self):
TypeError: process() missing 1 required positional argument: 'context'

It all seems caused by the IF()'s and ELSE()'s ... Does anyone know why? Thanks!

The code can be found at: gist
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 03:32
Where is the Grammer of Interpreter written?
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:06
@gEt-rIgHt-jR It’s not clear what question you’re asking - or why you’re asking it. VOC and Batavia both use CPython’s parser, so there’s no “grammar” involved.
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 04:07
Oh ok
I wanted to define my own Data type
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:08
@gEt-rIgHt-jR Can we start with what project are you working on?
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 04:09
@freakboy3742 I'm not working on any project, just trying to learn the core concepts
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:10
Yes, but the core concepts of what?
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 04:10
How VOC works
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:10
Ok - so what are you trying to do?
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 04:11
I want know how the Python code runs in VOC
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:12
So- that’s where the problem starts. Python code doesn’t run in VOC. VOC is a transpiler. It takes Python code, and turns it into Java bytecode. It’s then the responsibility of the Java virtual machine to run the code.
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 04:13
Yeah I know that, but where does it get converted and how, that's what I'm trying to learn
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:15
The key part of the process is contained in voc/python/ast.py; beyond that, it’s difficult to answer without doing a complete walkthrough of the code.
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 04:15
Ohk, thanks for the help
After updating my pull request https://github.com/pybee/voc/pull/399/files, it shows a lot of changes in Python.java, is that incorrect?
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:20
I’m not sure why you’d be getting those changes - they certainly don’t appear to be necessary for the patch you’ve proposed.
icyflames23
@icyflames23
Mar 14 2017 04:43
Hello people, I would like to connect with this organisation, through GSoc.
I'm a first yearite, learning Python Programming. Can I be of some use in GSoc and after it, to the organisation's resources?
Russell Keith-Magee
@freakboy3742
Mar 14 2017 04:46
@icyflames23 Absolutely! We’ve had people with very little programming experience make a valuable contribution to BeeWare
The guide to getting started with GSoC can be found here: https://github.com/pybee/pybee.github.io/wiki/So-you-want-to-be-a-BeeWare-GSoC-student%3F
icyflames23
@icyflames23
Mar 14 2017 04:46
Thanks Russell Keith Magree
This really motivated me. I shall try my best to contribute to this organisation, with whatsoever knowledge I have.
icyflames23
@icyflames23
Mar 14 2017 05:04
@freakboy3742 I just want to ask if there's something I can do with C programming.
Russell Keith-Magee
@freakboy3742
Mar 14 2017 05:06
@icyflames23 Not really. There is Java in VOC; Javascript in Batavia; and there’s some Objective-C related stuff in Rubicon and Toga; but I can’t think of anything likely projects in BeeWare that call for raw C
icyflames23
@icyflames23
Mar 14 2017 05:06
okay ty :)
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 07:19
@freakboy3742 What should I do then? I just rebased, I don't know how they came. Where I went wrong?
Russell Keith-Magee
@freakboy3742
Mar 14 2017 07:22
@gEt-rIgHt-jR The changes will have come due to a conflict between what is in the main repository and what is in your own repository. I’m guessing that when you’ve rebased, you’ve somehow selected the version of Python.java in your own branch, rather than merging the changes in Python.java with your own changes.
Abhidnya Andraskar
@gEt-rIgHt-jR
Mar 14 2017 07:23
What should I do now?
Russell Keith-Magee
@freakboy3742
Mar 14 2017 07:25
Resolve the discrepancies. Your patch should only contain the changes that are needed to make your feature work. It shouldn’t undo (or redo) the work of other patches.
rahul kumar
@kevin2jordan
Mar 14 2017 10:38
hello everyone, i am new to GSOC and i want to contribute to open source.i have an idea of making a python app that will wok on Software as a Service concept.suppose i have a smart phone that lacks certain apps and there is server that have apps that i need then i will use their app without even installing that app in my phone.
udaspriest
@udaspriest
Mar 14 2017 10:59
What kind of projects could I submit
Russell Keith-Magee
@freakboy3742
Mar 14 2017 11:02
@kevin2jordan @udaspriest Please see out page for prospective GSoC applicants for the types of projects that we’re looking for. https://github.com/pybee/pybee.github.io/wiki/So-you-want-to-be-a-BeeWare-GSoC-student%3F
Jonatas CD
@joncasdam
Mar 14 2017 13:17
@freakboy3742 hello :smile: I've updated pull request pybee/pybee.github.io#107
Alexander Konyaev
@ioo11
Mar 14 2017 13:30
hi everyone. this is my first trying to make a pull request and contribute. please check and comment pybee/batavia#463
Chiang Fong Lee
@cflee
Mar 14 2017 13:39

@leasunhy

 [snip]
  File "/home/leasunhy/voc/voc-github/voc/python/ast.py", line 1011, in visit_BinOp
    JavaOpcodes.ICONST_0,
  File "/home/leasunhy/voc/voc-github/voc/python/blocks.py", line 38, in add_opcodes
    if opcode.process(self):
TypeError: process() missing 1 required positional argument: 'context'

it needs to be JavaOpcodes.ICONST_0(), with the parentheses

leasunhy
@leasunhy
Mar 14 2017 13:40
Oh, thank you!!!
Dima Tisnek
@dimaqq
Mar 14 2017 15:03
now the hard rubicon-objc question -- how do I ensure that objc-land stuff that I created in Python does not get garbage-collected?
I could create e.g. NSMutableArray, but that too could get garbage-collected right?
In my case, most of the code is executed in callbacks, so... where can I put stuff "permanently"?
Dima Tisnek
@dimaqq
Mar 14 2017 15:15
or could I perhaps manually bump up reference count?
dgelessus
@dgelessus
Mar 14 2017 15:24
You need to call retain and release on the objects by hand, as you would in "old" Objective-C (without GC or ARC). Keep in mind that objects from a new call (or alloc().init()) are already retained, so you only need to release them when you are done using them.
Dima Tisnek
@dimaqq
Mar 14 2017 15:24
on this case, I'm asking runtime to generate a new view instance from a nib
I guess it's made for "autorelease" semantics, I'll try retaining it and see how far I get
dgelessus
@dgelessus
Mar 14 2017 15:29
Yep, most methods return objects autoreleased, which means that you need to retain them if you want to keep using them. Otherwise, if nobody else has the object retained, it is deallocated after a while (if you're in a run loop, it happens when the next run loop iteration begins, I think).
Shyam Sunder
@shyamsunder007
Mar 14 2017 16:48
This message was deleted
what does
BUILD FAILED
Target "checkstyle" does not exist in the project "python". this mean when i run flake8 and checkstyle
Vignesh
@Vignesh-sopho
Mar 14 2017 17:11
hi everyone. I am new to GSOC and I want to contribute to open source projects. I have no experience in open source projects. Can I help in the VOC project?
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 17:11
Hi. Why don't we use HashMap for implementing dict() for python? Won't it make it much simpler? @eliasdorneles @cflee
Deepankar Agrawal
@deep110
Mar 14 2017 17:28
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 17:33
Deepankar Agrawal
@deep110
Mar 14 2017 17:35
@ashutoshsaboo I think you are confused somehow, Map is just a abstract class, and HashMap is implementation
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 17:37
Ohh. oops. Just got confused with something else actually. My bad! :+1:
Dima Tisnek
@dimaqq
Mar 14 2017 17:48
@kevin2jordan is this wrong channel perhaps? web apps have a concept of server-side rendering (redux, vue, etc support that); reusing client-side code requires careful engineering. What you are proposing is similar to VNC. It would be a cool hack, for sure, for example, to get user interaction right, for example what widgets respond to scroll or pinch, without roundtrip lag, would require introspection into view tree...
Anyhow, Google recently started public trials of "instant apps" -- similar concept, implemented differently, have a look at that.
Nimish Singhal
@ASP1234
Mar 14 2017 17:54
where to run codestyle check via terminal?
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 17:55
In the git repo, run this-:
flake8 && ant checkstyle
First install flake8 by pip install flake8
in your virtual environment
Nimish Singhal
@ASP1234
Mar 14 2017 17:55
ok
Thanks
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 17:56
No worries! :smile:
Nimish Singhal
@ASP1234
Mar 14 2017 18:07
@ashutoshsaboo any idea how to generate report for checkstyle errors
I want to run over a particular file
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 18:08
Just run the command, you'll get the report yourself. It'll run it on all the files. Also it's pretty quick. So don't worry about it.
@ASP1234 ^
Nimish Singhal
@ASP1234
Mar 14 2017 18:11
C:\Users\NMSH\Desktop\voc-dev\voc\build.xml:26: The following error occurred while executing this line:
C:\Users\NMSH\Desktop\voc-dev\voc\build-java.xml:63: Unable to process files: [C:\Users\NMSH\Desktop\voc-dev\voc\python\android\python\platform\AndroidPlatform.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\android\python\platform\LogStream.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\Python.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Attribute.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Callable.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Class.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\ImportLib.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Iterable.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Method.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Module.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\Object.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ArithmeticError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\AssertionError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\AttributeError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\BaseException.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\BlockingIOError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\BrokenPipeError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\BufferError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\BytesWarning.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ChildProcessError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ConnectionAbortedError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ConnectionError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ConnectionRefusedError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ConnectionResetError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\DeprecationWarning.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\EOFError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\Exception.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\FileExistsError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\FileNotFoundError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\FloatingPointError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\FutureWarning.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\GeneratorExit.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ImportError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\ImportWarning.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\IndentationError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\IndexError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\InterruptedError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\IsADirectoryError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\KeyError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\KeyboardInterrupt.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\LookupError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\MemoryError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\NameError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\NotADirectoryError.java, C:\Users\NMSH\Desktop\voc-dev\voc\python\common\org\python\exceptions\Not
getting this :(
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 18:12
Did you do ant java before running the style checks?
Nimish Singhal
@ASP1234
Mar 14 2017 18:12
no
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 18:12
Try doing it after issuing that command.
Nimish Singhal
@ASP1234
Mar 14 2017 18:13
still same
is there any formatter we use for java here?
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 18:15
Where are you running all these commands - in the voc directory right?
Nimish Singhal
@ASP1234
Mar 14 2017 18:16
yeah
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 18:17
Does the build ant java happen successfully, without any errors?
Nimish Singhal
@ASP1234
Mar 14 2017 18:17
yeah
Ashutosh Saboo
@ashutoshsaboo
Mar 14 2017 18:18
Ahh then seems to be some issue. Not sure. Never ran into such a problem. Maybe @eliasdorneles could help you out. :smile:
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 19:27
how do i typecast org.python.Object to org.python.types.Int? I tried var1=(org.python.types.Int) var2;but it doesn't work. how else should i do it?
Elias Dorneles
@eliasdorneles
Mar 14 2017 19:30
what error do you get?
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 19:32
when I pass var2 as True. I get "org.python.types.Bool cannot be cast to org.python.types.Int"
Elias Dorneles
@eliasdorneles
Mar 14 2017 19:33
hm, I see, just checked now and in VOC, Bool doesn't inherit from Int... thinking....
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 19:35
you asked me to make this change in PR. Do i just leave the bool test case for ennumerate() function?
*enumerate()
Elias Dorneles
@eliasdorneles
Mar 14 2017 19:37
yeah, they still evaluate as the same, and it should work
Nimish Singhal
@ASP1234
Mar 14 2017 19:39
class FrozensetTests(TranspileTestCase):
    def test_creation(self):
        # Empty dict
        self.assertCodeExecution("""
            x = frozenset()
            print(x)
            """)

        # Set constant
        self.assertCodeExecution("""
            x = {'a'}
            print(x)
            """)

        self.assertCodeExecution("""
            x = frozenset(['a'])
            print(x)
            """)
@eliasdorneles trying to complete tests for frozenset constructors
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 19:40
one more doubt. in TypeError exception, I write something like throw new org.python.exceptions.TypeError(start.typeName() +" object cannot be interpreted as an integer " ); but the message that i see on runnign code is different.
Nimish Singhal
@ASP1234
Mar 14 2017 19:40
but here its comparing returned obj with frozenset()
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 19:41
for example in case of float, I see a message "org.python.types.Float cannot be cast to org.python.types.Int" instead of "org.python.types.Float object cannot be interpreted as an integer".
Yudit Sharabi
@yuliaSharabi
Mar 14 2017 19:44
hi guys or if I can be specific @eliasdorneles , I am trying to understand how yo fix - https://github.com/pybee/voc/blob/master/tests/builtins/test_map.py#L25-L27 by implementing the iter method and I kind of lost there..
Elias Dorneles
@eliasdorneles
Mar 14 2017 19:45
@Saurabh--Kumar so, about the boolean as int thing, let's leave that for a separate issue, you can disregard it for now
Yudit Sharabi
@yuliaSharabi
Mar 14 2017 19:46
I see that there is voc/python/common/org/python/types/Iterator.java
class should I inherit it?
I dont really understand how do I implement this iter method in java :(
Elias Dorneles
@eliasdorneles
Mar 14 2017 19:50
@Saurabh--Kumar about the class name, I think you can use start.__class__.PYTHON_TYPE_NAME
(this should be __name__, we probably have to change it at some point)
@yuliaSharabi yeah, it's a bit confusing the way it is right now, because Python has the distinction between Iterable and Iterator, and VOC is using the same interface for both (I think this will change at some point)
but the iterable types should implement Iterable
Elias Dorneles
@eliasdorneles
Mar 14 2017 19:56
and the __iter__ method should return an iterator (which is the thing that should have a __next__ method)
There is a org.python.types.Iteratorclass that wraps around Java's java.util.Iterator
you can probably handle it in a similar way that List and Tuple does, for now (adding a constructor to Iterator for the type you're modifying)
Nimish Singhal
@ASP1234
Mar 14 2017 19:59
@eliasdorneles regarding frozenset constructors test?

```
class FrozensetTests(TranspileTestCase):
def test_creation(self):

    # Empty dict
    self.assertCodeExecution("""
        x = frozenset()
        print(x)
        """)
    # Set constant
    self.assertCodeExecution("""
        x = {'a'}
        print(x)
        """)

    self.assertCodeExecution("""
        x = frozenset(['a'])
        print(x)
        """)

```

Elias Dorneles
@eliasdorneles
Mar 14 2017 19:59
getting there :)
@ASP1234 so, what's the problem with those again?
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 20:02
@eliasdorneles which exception is thrown when typecast fails? I have tried TypeError and Exception in the catch blck but they are not working.
Nimish Singhal
@ASP1234
Mar 14 2017 20:02
well in assertion i get 'x' as an object which I think is right as its a set, but fails beacuse o/p should be frozenset() rather than a frozenset obj
Elias Dorneles
@eliasdorneles
Mar 14 2017 20:03
@Saurabh--Kumar if you mean in Java, I believe it's ClassCastException. But the best way to check is writing a test and see what happens. ;-)
@ASP1234 sorry, I'm not following
Nimish Singhal
@ASP1234
Mar 14 2017 20:05
Traceback (most recent call last):
  File "c:\users\nmsh\desktop\voc-dev\voc\tests\datatypes\test_frozenset.py", line 10, in test_creation
    """)
  File "c:\users\nmsh\desktop\voc-dev\voc\tests\utils.py", line 398, in assertCodeExecution
    self.assertEqual(java_out, py_out, context)
AssertionError: '<frozenset object at 0xXXXXXXXX>\n===end of test===\n' != 'frozenset()\n===end of test===\n'
- <frozenset object at 0xXXXXXXXX>
+ frozenset()
  ===end of test===
 : Global context

----------------------------------------------------------------------
Ran 1 test in 10.266s

FAILED (failures=1)
Test failed: <unittest.runner.TextTestResult run=1 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=1 errors=0 failures=1>
Hope this helps
Saurabh--Kumar
@Saurabh--Kumar
Mar 14 2017 20:12
@eliasdorneles thanks
Nimish Singhal
@ASP1234
Mar 14 2017 20:14
@eliasdorneles Got it! Need to implement repr
Elias Dorneles
@eliasdorneles
Mar 14 2017 21:01
yup!
Nimish Singhal
@ASP1234
Mar 14 2017 21:02
Also, for non iterable cases, I need to throw typeerror right
eg. frozenset(1)
EGJ1996
@EGJ1996
Mar 14 2017 21:52
Hello, I was taking a look at issue 46 for the batavia project and it seems that most of the operations are already implemented. Does anybody know any operation that is not implemented yet?
Elias Dorneles
@eliasdorneles
Mar 14 2017 22:00
@ASP1234 yes, you should do the same as CPython does
>>> frozenset(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable