Unexpected behaviour of exit method · Issue #113 · oracle/python-cx_Oracle (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Description:
I believe the __exit__()
method does not behave as expected. PEP-343 states
Many context managers (such as files and generator-based contexts) will be single-use objects. Once the
__exit__()
method has been called, the context manager will no longer be in a usable state (e.g. the file has been closed, or the underlying generator has finished execution).
The current implementation commits or rolls-back any transaction but leaves the connection open.
More information
- What is your version of Python? Is it 32-bit or 64-bit?
Python 3.6, 64 bits - What is your version of cx_Oracle?
'6.0b2' - What is your OS and version?
Mac OSX 10.12.6 - What compiler version did you use? For example, with GCC, run
gcc --version
.
Apple LLVM version 9.0.0 (clang-900.0.38) - What exact command caused the problem (e.g. what command did you try to
install with)? Who were you logged in as?conn= cx_Oracle.connect(user=username,password=password,dsn=dsn) conn.__exit__()
- What error(s) you are seeing?
The__exit__()
method returns False without closing the connection. This is unexpected behaviour as users usually expect a with-block to always close the open connection. As an example,
f = open(filename, "r") f.exit() f.closed
returns True