These are chat archives for pybee/general

5th
Mar 2017
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 06:43
@freakboy3742 @eliasdorneles Does any of the python exception take keyword arguments?
Becuase I have triedTypeError, ValueError and Exception and they all are returning error message TypeError: Exception does not take keyword arguments Am I missing something here?
Elias Dorneles
@eliasdorneles
Mar 05 2017 06:47
hm, I can't recall any exception in the standard library that takes keyword arguments
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 06:47

Also one more thing this code

def foo():
    raise ValueError('My Error', foo='bar')


if __name__ == '__main__':
    foo()

When I run above with python I am getting

aceback (most recent call last):
  File "foo7.py", line 7, in <module>
    foo()
  File "foo7.py", line 3, in foo
    raise ValueError('My Error', foo='bar')
TypeError: ValueError does not take keyword arguments

but with VOC I am getting

Exception in thread "main" ValueError: 'My Error'
    at python.foo7.__init__.foo(foo7.py:3)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.python.types.Function.invoke(Function.java:391)
    at org.python.types.Function.invoke(Function.java:350)
    at python.foo7.__init__.module$import(foo7.py:7)
    at python.foo7.__init__.main(foo7.py)
is it means we have implemented keyword argument?
@eliasdorneles
Elias Dorneles
@eliasdorneles
Mar 05 2017 06:48
haha, it seems so :)
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 06:49
lol ;)
Elias Dorneles
@eliasdorneles
Mar 05 2017 06:49
we should follow CPython, and do whatever it does :+1:
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 06:50
Because I am pulling my hairs from last 2 days to get arbitrary number of arguments to work even when we don't provide keyword argument without explicitly creating two constructors
which is impossible without default argument in Java
So @eliasdorneles what should we do now, because I am ready with single *args in Java
Even though the declaration of all the exceptions accept **kwargs but they do not let us use them
Elias Dorneles
@eliasdorneles
Mar 05 2017 06:52
well, we still need to support keyword arguments for subclasses
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 06:53
hm right
Elias Dorneles
@eliasdorneles
Mar 05 2017 06:54
in any case, you can send a PR even if the work isn't complete yet, that might be easier to think on the possibilities
it's kind of late for me, so I can't help you w/ it right now, but you can send a PR with what you've got (I sometimes send a PR with "[WIP]" on the description, as in Work In Progress, to get early feedback ;) )
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 06:56
Hmm that sounds good
fetching latest source code
Hmm one last thing even we are supporting args, and *kwargs, we we are using only args[0].toString()
https://github.com/pybee/voc/blob/master/python/common/org/python/exceptions/BaseException.java#L19
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:02
and even great java.lang.RuntimeException does not take arbitrary number of string args
public class java.lang.RuntimeException extends java.lang.Exception {
  static final long serialVersionUID;
  public java.lang.RuntimeException();
  public java.lang.RuntimeException(java.lang.String);
  public java.lang.RuntimeException(java.lang.String, java.lang.Throwable);
  public java.lang.RuntimeException(java.lang.Throwable);
  protected java.lang.RuntimeException(java.lang.String, java.lang.Throwable, boolean, boolean);
}
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:04
yeah, I think we need to add an args attribute
and make it a Python tuple
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:05
Bingo
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:05
accessible from Python (annotated with @org.python.Attribute)
because this is valid Python 3:
>>> exc = ValueError()
>>> exc.args
()
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:06
and ValueError(1) is a tuple (1,)
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:06
erm, what do you mean?
ValueError(1).args is the actual tuple
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:07
right that's what I mean
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:07
yeah, so, I think that attribute should be added to BaseException
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:08
and then how our org.python.types.Object will interpret this?
Dibya Prakash Das
@dibyadas
Mar 05 2017 07:09
Hi @eliasdorneles @Deepanshu2017 . I need some help to understand the source code of VOC.
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:09
@Deepanshu2017 how do you mean?
@dibyadas feel free to ask any questions :thumbsup:
I'll have to be off in a minute, but others can help too :)
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:10

yeah, I think we need to add an args attribute

We will add a new constructor in BaseException right?

Saurabh--Kumar
@Saurabh--Kumar
Mar 05 2017 07:11
hi pybee folks. I am interested in voc project for GSOC 2017. I am trying to implement max() and min() inbuilt function. The "key" argument in both the functions is a function pointer. Java doesn't have the concept of function pointers. So what would be the type of the "key" argument in the function definition?
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:11
@Saurabh--Kumar there is a type Function
Dibya Prakash Das
@dibyadas
Mar 05 2017 07:11
Sure @eliasdorneles :+1:
I was seeing that iter has not yet been implemented on dict types. I want to work on that issue
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:11
and call super(tuple) from that constructor
Saurabh--Kumar
@Saurabh--Kumar
Mar 05 2017 07:11
ok thanks.
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:11
@Deepanshu2017 hmm no, I don't think the constructor need to change
I mean, the args thing is just an attribute, you don't need to have a constructor for it
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:14
Hmm I lost here. If you have to leave than maybe we can discuss later. But to make things properly set I need some clarification. :)
Dibya Prakash Das
@dibyadas
Mar 05 2017 07:15
Hi @Deepanshu2017 . Can you help me to understand the source code of VOC?
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:15
yes sure :) @dibyadas
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:16
@Saurabh--Kumar check the implementation for List.sort() as an example for handling a keyword argument that is a function: https://github.com/pybee/voc/blob/master/python/common/org/python/types/List.java#L676-L703
@Deepanshu2017 so, why do you think we need a new constructor?
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:17
Okay @eliasdorneles I am explaining from starting. We had a ValueError when passing with String right? pybee/voc#352
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:17
right
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:18
This was due to missing constructor of org.python.Object
Now we can easily solve this issue by adding one more constructors which takes org.python.Object
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:19
erm, doesn't annotating the multiple args constructor would work?
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:19
At line 12 in same file?
Russell Keith-Magee
@freakboy3742
Mar 05 2017 07:20
@mhsmith The 4000 count is if you fully instantiate all the classes involved - i.e., speculatively instantiating everything, rather than doing it on demand.
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:20
@Deepanshu2017 I'm not sure if those signatures work from constructors, but that's what I'd try first
Russell Keith-Magee
@freakboy3742
Mar 05 2017 07:20
And if you’re doing anything dynamic, (like most of Python is) you also need to get JNI references for method
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:25

@Deepanshu2017 I'm not sure if those signatures work from constructors, but that's what I'd try first

But you still need to define their data types right?

Elias Dorneles
@eliasdorneles
Mar 05 2017 07:26
@Deepanshu2017 there is no need to.
ValueError() will still just receive some positional arguments
the only thing is that it will store those arguments in a tuple
so, handling them will probably consist of something like:
this.args = org.python.types.Tuple(Arrays.asList(args))
(the code might not be correct, it's 2:30am here :D )
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:28
here I remember I was doing the same thing 2 days ago at 3:30 AM haha
Maybe indication of some sleep
You can take rest :)
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:30
Subscribed
Elias Dorneles
@eliasdorneles
Mar 05 2017 07:31
haha! I'm not subscribed, but I'm particularly fond of that one strip :)
okay, I'm off! see you later, good luck! :+1:
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:32
Thank you. Enjoy your good sleep :)
Deepanshu Thakur
@Deepanshu2017
Mar 05 2017 07:40
@eliasdorneles Jurassic Fork was fun lol
Satyam Yadav
@satyam1729
Mar 05 2017 10:28
Hello everyone....I'm a sophomore at IIT Roorkee,India and want to contribute to beeware as a part of gsoc this year.For batavia project, i'm having trouble upgrading to npm version 4.x. I ran the following but still get npm version 3.10.10

(venv) satyam@satyam-SVE15111ENB:~/code/opensource/pybee/batavia$ npm install npm@latest -g
/home/satyam/.npm-global/bin/npm -> /home/satyam/.npm-global/lib/node_modules/npm/bin/npm-cli.js
/home/satyam/.npm-global/lib
`-- npm@4.3.0

(venv) satyam@satyam-SVE15111ENB:~/code/opensource/pybee/batavia$ npm --version
3.10.10

Malcolm Smith
@mhsmith
Mar 05 2017 12:05
@freakboy3742 Thanks, thought it might be something like that.
shubham maddhashiya
@sipah00
Mar 05 2017 13:29
Hello everyone..my name is Shubham ,IIT kharagpur,India. It is my first GSoc ,and i want to work for VOC. how should i start? thanks in advance..
Elias Dorneles
@eliasdorneles
Mar 05 2017 15:09
Dibya Prakash Das
@dibyadas
Mar 05 2017 16:49
hi @eliasdorneles .. are u online now?