Commit cf371929657dba4d54fd7c801dfe691f23477831
1 parent
ff3908b9
Exists in
master
and in
5 other branches
Melhorando tratamento de excessões na criação do objeto.
Showing
1 changed file
with
12 additions
and
13 deletions
Show diff stats
src/python/init.cc
@@ -41,18 +41,7 @@ | @@ -41,18 +41,7 @@ | ||
41 | 41 | ||
42 | PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { | 42 | PyObject * terminal_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { |
43 | 43 | ||
44 | - pw3270_TerminalObject *self = (pw3270_TerminalObject *) type->tp_alloc(type, 0); | ||
45 | - | ||
46 | - trace("%s: self=%p",__FUNCTION__,self); | ||
47 | - | ||
48 | - self->session = NULL; | ||
49 | - | ||
50 | - return (PyObject *)self; | ||
51 | -} | ||
52 | - | ||
53 | - | ||
54 | -int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { | ||
55 | - | 44 | + PW3270_NAMESPACE::session * session; |
56 | const char *id = ""; | 45 | const char *id = ""; |
57 | 46 | ||
58 | if (!PyArg_ParseTuple(args, "s", &id)) { | 47 | if (!PyArg_ParseTuple(args, "s", &id)) { |
@@ -63,15 +52,25 @@ int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { | @@ -63,15 +52,25 @@ int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { | ||
63 | 52 | ||
64 | try { | 53 | try { |
65 | 54 | ||
66 | - self->session = PW3270_NAMESPACE::session::create(id); | 55 | + session = PW3270_NAMESPACE::session::create(id); |
67 | 56 | ||
68 | } catch(std::exception &e) { | 57 | } catch(std::exception &e) { |
69 | 58 | ||
70 | trace("%s failed: %s",__FUNCTION__,e.what()); | 59 | trace("%s failed: %s",__FUNCTION__,e.what()); |
71 | PyErr_SetString(terminalError, e.what()); | 60 | PyErr_SetString(terminalError, e.what()); |
61 | + return NULL; | ||
72 | 62 | ||
73 | } | 63 | } |
74 | 64 | ||
65 | + pw3270_TerminalObject *self = (pw3270_TerminalObject *) type->tp_alloc(type, 0); | ||
66 | + | ||
67 | + self->session = session; | ||
68 | + | ||
69 | + return (PyObject *)self; | ||
70 | +} | ||
71 | + | ||
72 | + | ||
73 | +int terminal_init(pw3270_TerminalObject *self, PyObject *args, PyObject *kwds) { | ||
75 | 74 | ||
76 | return 0; | 75 | return 0; |
77 | 76 |