Skip to content

Commit 8aeb6d1

Browse files
author
James William Pye
committed
Update.
1 parent 81a3bbc commit 8aeb6d1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

postgresql/resolved/pythoncommand.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ class to attempt to fill in the attribute using 'args' and other
419419
"""
420420
self.args = args
421421
self.context = context and list(context) or ()
422-
self.reset_module__main__()
423422

424423
if main is not None:
425424
self.main = main
@@ -454,12 +453,16 @@ class to attempt to fill in the attribute using 'args' and other
454453
else:
455454
# console
456455
self.main = (None, None)
456+
self.reset_module__main__()
457457

458458
def reset_module__main__(self):
459459
mod = types.ModuleType('__main__')
460-
mod.__package__ = None
461460
mod.__builtins__ = __builtins__
461+
mod.__package__ = None
462462
self.module__main__ = mod
463+
path = getattr(self.main[1], 'fullname', None)
464+
if path is not None:
465+
mod.__package__ = '.'.join(path.split('.')[:-1])
463466

464467
def _call(self,
465468
console = ExtendedConsole,

0 commit comments

Comments
 (0)