Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Fix proto import bug
Browse files Browse the repository at this point in the history
In addition to doing `import mod` we also do the previous
`from mod import *`. The former keeps the package support that was
recently added, and the latter fixes the regression that broke plain
proto imports.
  • Loading branch information
dowski committed Aug 9, 2013
1 parent 42910be commit 8b8e225
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion palm/palmc/codegen.py
Expand Up @@ -67,7 +67,9 @@ def gen_module(messages, imports, tlenums, with_slots, packages, curr_package):

out('from palm.palm import ProtoBase, is_string, RepeatedSequence, ProtoValueError\n\n_PB_type = type\n_PB_finalizers = []\n\n')
for i in imports:
out('import %s\n' % convert_proto_name(i))
converted_name = convert_proto_name(i)
out('import %s\n' % converted_name)
out('from %s import *\n' % converted_name)

for ename, espec in tlenums:
write_enum(ename, espec)
Expand Down
7 changes: 7 additions & 0 deletions test/test.py
Expand Up @@ -528,6 +528,13 @@ def test_fast_append_on_rendered_repeated_fails(self):
pass
else:
assert 0, "SHOULD HAVE RAISED"

def test_field_from_imported_proto(self):
pb1 = test_palm.Test(req_a=1, req_b=2, req_c=3)
pb1.ext = test_palm.Bar(message="hi")
pb2 = test_palm.Test(pb1.dumps())
assert pb2.ext.message == "hi"

class TestNesting(object):
def test_nested_messages(self):
"""See https://github.com/bumptech/palm/issues/24"""
Expand Down

0 comments on commit 8b8e225

Please sign in to comment.