You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Todd Lipcon (JIRA)" <ji...@apache.org> on 2009/04/29 23:13:30 UTC
[jira] Created: (THRIFT-471) Generated exceptions in Python should
implement __str__
Generated exceptions in Python should implement __str__
-------------------------------------------------------
Key: THRIFT-471
URL: https://issues.apache.org/jira/browse/THRIFT-471
Project: Thrift
Issue Type: Bug
Components: Compiler (Python)
Reporter: Todd Lipcon
When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
Without __str__:
{code}
File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
raise result.err
ttypes.IOException
{code}
With __str__:
{code}
File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
raise result.err
ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
{code}
Clearly the latter is way more useful.
Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-471) Generated exceptions in Python should
implement __str__
Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Todd Lipcon updated THRIFT-471:
-------------------------------
Attachment: thrift-471.txt
Patch that implements __str__ only for the case of Exception-type structs by calling through to __repr__
> Generated exceptions in Python should implement __str__
> -------------------------------------------------------
>
> Key: THRIFT-471
> URL: https://issues.apache.org/jira/browse/THRIFT-471
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Todd Lipcon
> Attachments: thrift-471.txt
>
>
> When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
> Without __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException
> {code}
> With __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
> {code}
> Clearly the latter is way more useful.
> Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-471) Generated exceptions in Python
should implement __str__
Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704346#action_12704346 ]
Jonathan Ellis commented on THRIFT-471:
---------------------------------------
yeah, the python docs say that __repr__ should be used if there is no __str__ and every other case I have seen follows that rule but the exception printing apparently does not.
+1
> Generated exceptions in Python should implement __str__
> -------------------------------------------------------
>
> Key: THRIFT-471
> URL: https://issues.apache.org/jira/browse/THRIFT-471
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Todd Lipcon
>
> When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
> Without __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException
> {code}
> With __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
> {code}
> Clearly the latter is way more useful.
> Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (THRIFT-471) Generated exceptions in Python should
implement __str__
Posted by "David Reiss (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Reiss resolved THRIFT-471.
--------------------------------
Resolution: Fixed
Assignee: Todd Lipcon
I'll be interested to see how the Python folks respond.
> Generated exceptions in Python should implement __str__
> -------------------------------------------------------
>
> Key: THRIFT-471
> URL: https://issues.apache.org/jira/browse/THRIFT-471
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Todd Lipcon
> Assignee: Todd Lipcon
> Attachments: thrift-471.txt
>
>
> When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
> Without __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException
> {code}
> With __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
> {code}
> Clearly the latter is way more useful.
> Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-471) Generated exceptions in Python should
implement __str__
Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Todd Lipcon updated THRIFT-471:
-------------------------------
Patch Info: [Patch Available]
> Generated exceptions in Python should implement __str__
> -------------------------------------------------------
>
> Key: THRIFT-471
> URL: https://issues.apache.org/jira/browse/THRIFT-471
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Todd Lipcon
> Attachments: thrift-471.txt
>
>
> When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
> Without __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException
> {code}
> With __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
> {code}
> Clearly the latter is way more useful.
> Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-471) Generated exceptions in Python
should implement __str__
Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704353#action_12704353 ]
Jonathan Ellis commented on THRIFT-471:
---------------------------------------
created http://bugs.python.org/issue5882, although that's only of academic interest for existing versions of python :)
> Generated exceptions in Python should implement __str__
> -------------------------------------------------------
>
> Key: THRIFT-471
> URL: https://issues.apache.org/jira/browse/THRIFT-471
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Todd Lipcon
>
> When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
> Without __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException
> {code}
> With __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
> {code}
> Clearly the latter is way more useful.
> Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-471) Generated exceptions in Python
should implement __str__
Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704418#action_12704418 ]
Jonathan Ellis commented on THRIFT-471:
---------------------------------------
They responded, "Exception implements __str__ so this is not a bug."
> Generated exceptions in Python should implement __str__
> -------------------------------------------------------
>
> Key: THRIFT-471
> URL: https://issues.apache.org/jira/browse/THRIFT-471
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Todd Lipcon
> Assignee: Todd Lipcon
> Attachments: thrift-471.txt
>
>
> When the python generator makes an exception class since THRIFT-241, it does not include a __str__ method. This is problematic since raised exceptions don't include any useful information that might be part of the exception struct.
> Without __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException
> {code}
> With __str__:
> {code}
> File "/home/todd/hadoop/src/contrib/thriftfs/gen-py/hadoop/api/Namenode.py", line 780, in recv_stat
> raise result.err
> ttypes.IOException: IOException(msg=None, stack='org.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.fileStatusToStat(NamenodePlugin.java:373)\norg.apache.hadoop.thriftfs.NamenodePlugin$ThriftHandler.stat(NamenodePlugin.java:333)\norg.apache.hadoop.thriftfs.api.Namenode$Processor$stat.process(Namenode.java:1350)\norg.apache.hadoop.thriftfs.api.Namenode$Processor.process(Namenode.java:1054)\norg.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:240)\njava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)\njava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\njava.lang.Thread.run(Thread.java:619)\n')
> {code}
> Clearly the latter is way more useful.
> Patch to follow if no one objects.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.