[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Fri Mar 23 11:01:04 UTC 2018


The branch, master has been updated
       via  da72c40 autobuild: Move "none" environment to samba-none-env
       via  e29a75e Add tests for dckeytab python module
       via  4f03649 python3 port for dckeytab module
       via  6a7cdad Add python tests for samba.gpo module
       via  a032ea5 libgpo: port samba.gpo to python3
       via  bb88292 tests/dcerpc/misc.GUID: improve tests
       via  f6db12e tests/dcerpc/misc.GUID: test that long-form py3 bytes works
       via  cd5a451 samba python tests: Ensure GUIDTests cover all input formats
       via  18a5afa s4/librpc: GUID should accept string or bytes in python3
       via  aea433e python: Add compatability helpers to determine if type is really bytes
       via  0d65c1e s4/dsdb: python3 api should take 'bytes'
       via  4c02d5c s4/selftest: enable netbios python test for python3 too
       via  330bbf7 python3 port for netbios module
       via  0fa93f5 s4/selftest: Add simple python netbios test python2 only for the moment
       via  0448719 libcli/nbt: Fix illegal tuple index access.
       via  8ca43ec README.Coding: remove reference to non-existent prog_guide4.txt
       via  cd1136f README.Coding: mention compatible Python versions
       via  0844c5a lib/tdb: convert print func to be py2/py3 compatible
       via  7b897d6 auth/credentials/test: convert print func to be py2/py3 compatible
       via  2a64f77 script: convert print func to be py2/py3 compatible
       via  220f19f s3/script/tests: convert print func to be py2/py3 compatible
       via  40e7d57 selftest: convert print func to be py2/py3 compatible
       via  bebdefe s4/selftest: convert print func to be py2/py3 compatible
       via  66ea491 s4/torture/drs: convert print func to be py2/py3 compatible
       via  dd5c347 s4/scripting: convert print func to be py2/py3 compatible
       via  66a9b4d s4/script: convert print func to be py2/py3 compatible
       via  a8aab19 s3/dsdb: convert print func to be py2/py3 compatible
       via  9c25174 samba python libs: convert print func to be py2/py3 compatible
       via  aacbe1b samba-tool: convert print func to be py2/py3 compatible
       via  708abbf samba python tests: convert print func to be py2/py3 compatible
      from  b9f0c7f Fix invocation of gnutls_aead_cipher_encrypt()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit da72c4018ed92feab28025f8c6c29894f4c8691c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Mar 3 19:51:29 2018 +1300

    autobuild: Move "none" environment to samba-none-env
    
    This takes this part of the test out of the main, slow samba task
    but also keeps it away from samba-o3 which is up against the 50min
    budget on travis-ci.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Fri Mar 23 12:00:40 CET 2018 on sn-devel-144

commit e29a75e74a089c6d786cf7ae8a26d4f778ddccb6
Author: David Mulder <dmulder at suse.com>
Date:   Fri Feb 16 10:00:19 2018 -0700

    Add tests for dckeytab python module
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 4f036497f1e8825d5ebe3a14c528ddf6cb1a4b22
Author: Noel Power <noel.power at suse.com>
Date:   Fri Feb 2 16:08:48 2018 +0000

    python3 port for dckeytab module
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 6a7cdad3e77ee78a9db20ae48dfe5e5c65597414
Author: David Mulder <dmulder at suse.com>
Date:   Mon Feb 12 12:21:42 2018 -0700

    Add python tests for samba.gpo module
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit a032ea5bf842da35099930008e308f35668d7caf
Author: David Mulder <dmulder at suse.com>
Date:   Tue Jan 30 12:31:42 2018 -0700

    libgpo: port samba.gpo to python3
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit bb88292cee5289742b72ff0249f01d527920301f
Author: Joe Guo <joeg at catalyst.net.nz>
Date:   Wed Mar 21 12:13:56 2018 +1300

    tests/dcerpc/misc.GUID: improve tests
    
    1. Merge tests for different formats into a for loop, make it easy to
    read and extend.
    2. Add test for invalid formats.
    
    Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit f6db12e236d3774b14e0af14889b0709cab3af0b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 16 16:33:44 2018 +1300

    tests/dcerpc/misc.GUID: test that long-form py3 bytes works
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit cd5a4519b111993f8aef41c564de8ec359602507
Author: Noel Power <noel.power at suse.com>
Date:   Wed Feb 28 14:40:26 2018 +0000

    samba python tests: Ensure GUIDTests cover all input formats
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 18a5afa6fb3ac016db23be072a69b0b1378209b3
Author: Noel Power <noel.power at suse.com>
Date:   Wed Feb 28 16:25:55 2018 +1300

    s4/librpc: GUID should accept string or bytes in python3
    
    In python3 you can't store a binary blob GUID in a string class, you
    need to use 'bytes'. This change ensures python2 code continues to use
    a string and in python3 both 'bytes' and 'string' are supported.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit aea433ee0c87d42f670aa8b9e068b80cf2d9ef09
Author: Noel Power <noel.power at suse.com>
Date:   Wed Mar 7 14:39:54 2018 +0000

    python: Add compatability helpers to determine if type is really bytes
    
    py3compat has PyBytes_Check macro which evalates to PyString_Check in
    python2. To help switch behaviour based on whether you are dealing
    with the bytes type the following macros have been added.
    
    IsPy3Bytes
    IsPy3BytesOrString
    
    IsPy3Bytes will evaluate to false in python2 and will return the
    expected result in python3. IsPy3BytesOrString will test for string
    type alone in python2 or bytes and string in python3.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 0d65c1ef65b1485ae772ac87a52bb58611d45c72
Author: Noel Power <noel.power at suse.com>
Date:   Thu Feb 22 12:49:36 2018 +0000

    s4/dsdb: python3 api should take 'bytes'
    
    Attributes are properly represented by 'bytes' and *maybe* can be
    converted into strings (if they are text).
    py_dsdb_normalise_attributes currently expects strings, this is fine
    in python2 however in python3 we need to actually pass a 'bytes'
    class.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4c02d5cafe2e0a8dc97bd161bcb5b9af5b151dd4
Author: Noel Power <noel.power at suse.com>
Date:   Thu Feb 15 20:46:53 2018 +0000

    s4/selftest: enable netbios python test for python3 too
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 330bbf7c3cfadd7f07fb5a83c5a7473c93e127dc
Author: Noel Power <noel.power at suse.com>
Date:   Fri Feb 2 17:08:00 2018 +0000

    python3 port for netbios module
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 0fa93f5fe99bd31c3f13241960c4ac600197c837
Author: Noel Power <noel.power at suse.com>
Date:   Thu Feb 15 20:43:53 2018 +0000

    s4/selftest: Add simple python netbios test python2 only for the moment
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 04487198a77708544f6bdefd21c660160e6ec236
Author: Noel Power <noel.power at suse.com>
Date:   Thu Feb 15 15:02:58 2018 +0000

    libcli/nbt: Fix illegal tuple index access.
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 8ca43ec8e27bd4fabf9630b3f10cc0e4fcc04894
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 23 15:12:06 2018 +1300

    README.Coding: remove reference to non-existent prog_guide4.txt
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit cd1136f39bba306419ef19c2c0884e694a59f2d0
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 23 15:09:57 2018 +1300

    README.Coding: mention compatible Python versions
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 0844c5aa22c60404044b4e6dfa51ec301194cb2a
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:07:31 2018 +0000

    lib/tdb: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 7b897d6d1c58df0d0914cfcb063d0f60943b1332
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:06:55 2018 +0000

    auth/credentials/test: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 2a64f77d4f72e1c92562f7fa262cc2a4db413536
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:06:21 2018 +0000

    script: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 220f19fce045a80d8c031b684b1edf8c2e33a445
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:04:29 2018 +0000

    s3/script/tests: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 40e7d5799936cdfc079a0c7c21d277ad61696984
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:03:29 2018 +0000

    selftest: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit bebdefeba912be4ff5bd93438151101671ecceda
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:02:52 2018 +0000

    s4/selftest: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 66ea49130dd486e86aaa6df37d41dc3f27fdf772
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:02:18 2018 +0000

    s4/torture/drs: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit dd5c347da5847980406978a5d199c36299d2cdf4
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 14:01:17 2018 +0000

    s4/scripting: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 66a9b4dc66022a0059d37dae0c0e713d7588051f
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 13:59:50 2018 +0000

    s4/script: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit a8aab19b90324a02f11cd09c79b8b38522f451ca
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 13:57:01 2018 +0000

    s3/dsdb: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 9c251740b42b04eb0c277bc7975170e0fa784ebf
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 13:53:45 2018 +0000

    samba python libs: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit aacbe1b65ccf6f75d26bcae517632e09552f23ca
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 13:49:09 2018 +0000

    samba-tool: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 708abbf3065120ffa2b3a9bf4b62912951d8bf0e
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 9 13:38:42 2018 +0000

    samba python tests: convert print func to be py2/py3 compatible
    
    Signed-off-by: Noel Power <noel.power at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 .gitlab-ci.yml                                     |   8 ++
 .travis.yml                                        |   1 +
 README.Coding                                      |  14 +--
 auth/credentials/tests/bind.py                     |  11 +-
 lib/tdb/python/tdbdump.py                          |   5 +-
 libcli/nbt/pynbt.c                                 |  57 ++++++----
 libcli/nbt/wscript_build                           |   3 +-
 libgpo/pygpo.c                                     |  30 ++++--
 libgpo/wscript_build                               |   9 +-
 python/py3compat.h                                 |  24 +++++
 python/samba/dbchecker.py                          |   3 +-
 python/samba/emulate/traffic.py                    | 116 ++++++++++++---------
 python/samba/join.py                               |  53 +++++-----
 python/samba/kcc/graph_utils.py                    |   7 +-
 python/samba/ms_display_specifiers.py              |   7 +-
 python/samba/ms_forest_updates_markdown.py         |   3 +-
 python/samba/ms_schema.py                          |   7 +-
 python/samba/ms_schema_markdown.py                 |   3 +-
 python/samba/netcmd/domain.py                      |   5 +-
 python/samba/netcmd/sites.py                       |   5 +-
 python/samba/ntacls.py                             |   5 +-
 python/samba/tests/auth_log.py                     |   4 +-
 python/samba/tests/auth_log_base.py                |   3 +-
 python/samba/tests/auth_log_pass_change.py         |  13 +--
 python/samba/tests/blackbox/ndrdump.py             |   3 +-
 python/samba/tests/dcerpc/dnsserver.py             |   5 +-
 python/samba/tests/dcerpc/misc.py                  |  35 +++++++
 python/samba/tests/dcerpc/testrpc.py               |  33 +++---
 python/samba/tests/dckeytab.py                     |  56 ++++++++++
 python/samba/tests/dns.py                          |  19 ++--
 python/samba/tests/dns_base.py                     |   9 +-
 python/samba/tests/dns_forwarder.py                |  15 +--
 python/samba/tests/dns_forwarder_helpers/server.py |   3 +-
 python/samba/tests/gpo.py                          |  70 +++++++++++++
 python/samba/tests/netbios.py                      |  52 +++++++++
 python/samba/tests/samba3sam.py                    |   3 +-
 python/samba/upgradehelpers.py                     |  15 +--
 python/samba/web_server/__init__.py                |   6 +-
 script/autobuild.py                                |  28 +++--
 script/compare_cc_results.py                       |   3 +-
 selftest/selftesthelpers.py                        |  21 ++--
 selftest/subunithelper.py                          |  19 ++--
 source3/script/tests/test_wbinfo_sids2xids_int.py  |   7 +-
 source4/dsdb/pydsdb.c                              |  12 ++-
 .../samdb/ldb_modules/tests/possibleinferiors.py   |  19 ++--
 source4/dsdb/tests/python/acl.py                   |  25 ++---
 .../dsdb/tests/python/ad_dc_medley_performance.py  |  21 ++--
 source4/dsdb/tests/python/ad_dc_performance.py     |  10 +-
 .../dsdb/tests/python/ad_dc_search_performance.py  |  19 ++--
 source4/dsdb/tests/python/deletetest.py            |  17 +--
 source4/dsdb/tests/python/dirsync.py               |  17 +--
 source4/dsdb/tests/python/ldap.py                  |   5 +-
 source4/dsdb/tests/python/ldap_schema.py           |   3 +-
 source4/dsdb/tests/python/linked_attributes.py     |  15 +--
 source4/dsdb/tests/python/notification.py          |   5 +-
 source4/dsdb/tests/python/password_lockout.py      |  11 +-
 source4/dsdb/tests/python/password_lockout_base.py |  25 ++---
 source4/dsdb/tests/python/passwords.py             |   7 +-
 source4/dsdb/tests/python/rodc.py                  |   7 +-
 source4/dsdb/tests/python/rodc_rwdc.py             |  39 +++----
 source4/dsdb/tests/python/sam.py                   |  35 ++++---
 source4/dsdb/tests/python/sec_descriptor.py        |  15 +--
 source4/dsdb/tests/python/sites.py                 |  18 ++--
 source4/dsdb/tests/python/sort.py                  |  55 +++++-----
 source4/dsdb/tests/python/token_group.py           |   9 +-
 source4/dsdb/tests/python/tombstone_reanimation.py |  25 ++---
 source4/dsdb/tests/python/urgent_replication.py    |   5 +-
 source4/dsdb/tests/python/user_account_control.py  |   3 +-
 source4/dsdb/tests/python/vlv.py                   |  27 ++---
 source4/libnet/py_net_dckeytab.c                   |  26 +++--
 source4/libnet/wscript_build                       |  12 +--
 source4/librpc/ndr/py_misc.c                       |  14 ++-
 source4/script/depfilter.py                        |   9 +-
 source4/scripting/bin/gen_hresult.py               |   7 +-
 source4/scripting/bin/w32err_code.py               |  13 +--
 source4/scripting/devel/demodirsync.py             |  59 +++++------
 source4/scripting/devel/pfm_verify.py              |  15 +--
 source4/scripting/devel/repl_cleartext_pwd.py      |   7 +-
 source4/scripting/devel/speedtest.py               |  25 ++---
 source4/selftest/tests.py                          |   8 +-
 source4/torture/drs/python/delete_object.py        |   5 +-
 source4/torture/drs/python/drs_base.py             |  13 +--
 source4/torture/drs/python/fsmo.py                 |   7 +-
 source4/torture/drs/python/getncchanges.py         |   1 +
 source4/torture/drs/python/repl_move.py            |  35 ++++---
 source4/torture/drs/python/replica_sync.py         |  57 +++++-----
 86 files changed, 982 insertions(+), 578 deletions(-)
 create mode 100644 python/samba/tests/dckeytab.py
 create mode 100644 python/samba/tests/gpo.py
 create mode 100644 python/samba/tests/netbios.py


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2ae9eb4..60accd4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,6 +11,14 @@ build_samba:
     # this one takes about 4 hours to finish
     - python script/autobuild.py samba            --verbose --tail --testbase /tmp/samba-testbase
 
+build_samba_none_env:
+  stage: build
+  tags:
+    - autobuild
+  script:
+    # this one takes about 1 hours to finish
+    - python script/autobuild.py samba-none-env    --verbose --tail --testbase /tmp/samba-testbase
+
 build_samba_others:
   stage: build
   tags:
diff --git a/.travis.yml b/.travis.yml
index 5ad750d..19d5b4c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,7 @@ env:
   - TASK=samba-libs
   - TASK=samba-static
   - TASK=samba-o3
+  - TASK=samba-none-env
   - TASK=samba-nopython
   - TASK=samba-systemkrb5
   - TASK=ldb
diff --git a/README.Coding b/README.Coding
index 054cf3f..3d4c5a5 100644
--- a/README.Coding
+++ b/README.Coding
@@ -16,15 +16,15 @@ style should never outweigh coding itself and so the guidelines
 described here are hopefully easy enough to follow as they are very
 common and supported by tools and editors.
 
-The basic style for C code, also mentioned in prog_guide4.txt, is the Linux kernel
-coding style (See Documentation/CodingStyle in the kernel source tree). This
-closely matches what most Samba developers use already anyways, with a few
-exceptions as mentioned below.
+The basic style for C code is the Linux kernel coding style (See
+Documentation/CodingStyle in the kernel source tree). This closely matches
+what most Samba developers use already anyways, with a few exceptions as
+mentioned below.
 
 The coding style for Python code is documented in PEP8,
-http://www.python.org/pep/pep8 (with spaces). 
-If you have ever worked on another free software Python project, you are
-probably already familiar with it.
+http://www.python.org/pep/pep8. New Python code should be compatible with
+Python 2.6, 2.7, and Python 3.4 onwards. This means using Python 3 syntax
+with the appropriate 'from __future__' imports.
 
 But to save you the trouble of reading the Linux kernel style guide, here
 are the highlights.
diff --git a/auth/credentials/tests/bind.py b/auth/credentials/tests/bind.py
index 4aa4498..8b08b4a 100755
--- a/auth/credentials/tests/bind.py
+++ b/auth/credentials/tests/bind.py
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 # This is unit with tests for LDAP access checks
 
+from __future__ import print_function
 import optparse
 import sys
 import base64
@@ -101,7 +102,7 @@ unicodePwd:: """ + base64.b64encode("\"P at ssw0rd\"".encode('utf-16-le')) + """
         # do a simple bind and search with the machine account
         creds_machine.set_bind_dn(self.computer_dn)
         creds_machine.set_password(self.password)
-        print "BindTest with: " + creds_machine.get_bind_dn()
+        print("BindTest with: " + creds_machine.get_bind_dn())
         ldb_machine = samba.tests.connect_samdb(host, credentials=creds_machine,
                                                 lp=lp, ldap_only=True)
         res = ldb_machine.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
@@ -119,7 +120,7 @@ unicodePwd:: """ + base64.b64encode("\"P at ssw0rd\"".encode('utf-16-le')) + """
         # do a simple bind and search with the user account in format user at realm
         creds_user1.set_bind_dn(self.username + "@" + creds.get_realm())
         creds_user1.set_password(self.password)
-        print "BindTest with: " + creds_user1.get_bind_dn()
+        print("BindTest with: " + creds_user1.get_bind_dn())
         ldb_user1 = samba.tests.connect_samdb(host, credentials=creds_user1,
                                               lp=lp, ldap_only=True)
         res = ldb_user1.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
@@ -127,7 +128,7 @@ unicodePwd:: """ + base64.b64encode("\"P at ssw0rd\"".encode('utf-16-le')) + """
         # do a simple bind and search with the user account in format domain\user
         creds_user2.set_bind_dn(creds.get_domain() + "\\" + self.username)
         creds_user2.set_password(self.password)
-        print "BindTest with: " + creds_user2.get_bind_dn()
+        print("BindTest with: " + creds_user2.get_bind_dn())
         ldb_user2 = samba.tests.connect_samdb(host, credentials=creds_user2,
                                               lp=lp, ldap_only=True)
         res = ldb_user2.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
@@ -135,7 +136,7 @@ unicodePwd:: """ + base64.b64encode("\"P at ssw0rd\"".encode('utf-16-le')) + """
         # do a simple bind and search with the user account DN
         creds_user3.set_bind_dn(str(user_dn))
         creds_user3.set_password(self.password)
-        print "BindTest with: " + creds_user3.get_bind_dn()
+        print("BindTest with: " + creds_user3.get_bind_dn())
         ldb_user3 = samba.tests.connect_samdb(host, credentials=creds_user3,
                                               lp=lp, ldap_only=True)
         res = ldb_user3.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
@@ -154,7 +155,7 @@ unicodePwd:: """ + base64.b64encode("\"P at ssw0rd\"".encode('utf-16-le')) + """
         creds_user4.set_password(self.password)
         creds_user4.set_domain('')
         creds_user4.set_workstation('')
-        print "BindTest (no domain) with: " + self.username
+        print("BindTest (no domain) with: " + self.username)
         try:
             ldb_user4 = samba.tests.connect_samdb(host, credentials=creds_user4,
                                               lp=lp, ldap_only=True)
diff --git a/lib/tdb/python/tdbdump.py b/lib/tdb/python/tdbdump.py
index 01859eb..a16d26e 100644
--- a/lib/tdb/python/tdbdump.py
+++ b/lib/tdb/python/tdbdump.py
@@ -1,12 +1,13 @@
 #!/usr/bin/env python
 # Trivial reimplementation of tdbdump in Python
 
+from __future__ import print_function
 import tdb, sys
 
 if len(sys.argv) < 2:
-    print "Usage: tdbdump.py <tdb-file>"
+    print("Usage: tdbdump.py <tdb-file>")
     sys.exit(1)
 
 db = tdb.Tdb(sys.argv[1])
 for (k, v) in db.iteritems():
-    print "{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v)
+    print("{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v))
diff --git a/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c
index 7162880..6337092 100644
--- a/libcli/nbt/pynbt.c
+++ b/libcli/nbt/pynbt.c
@@ -19,6 +19,7 @@
 
 #include <Python.h>
 #include "includes.h"
+#include "python/py3compat.h"
 #include "libcli/util/pyerrors.h"
 #include "python/modules.h"
 #include "../libcli/nbt/libnbt.h"
@@ -37,7 +38,7 @@ typedef struct {
 static void py_nbt_node_dealloc(nbt_node_Object *self)
 {
 	talloc_free(self->mem_ctx);
-	self->ob_type->tp_free(self);
+	Py_TYPE(self)->tp_free(self);
 }
 
 static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *kwargs)
@@ -56,8 +57,8 @@ static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *
 
 static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, uint16_t *dest_port)
 {
-	if (PyString_Check(obj)) {
-		*dest_addr = PyString_AsString(obj);
+	if (PyStr_Check(obj)) {
+		*dest_addr = PyStr_AsString(obj);
 		*dest_port = NBT_NAME_SERVICE_PORT;
 		return true;
 	}
@@ -68,12 +69,12 @@ static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, u
 			return false;
 		}
 
-		if (!PyString_Check(PyTuple_GetItem(obj, 0))) {
+		if (!PyStr_Check(PyTuple_GetItem(obj, 0))) {
 			PyErr_SetString(PyExc_TypeError, "Destination tuple first element not string");
 			return false;
 		}
 
-		*dest_addr = PyString_AsString(obj);
+		*dest_addr = PyStr_AsString(obj);
 
 		if (PyTuple_Size(obj) == 1) {
 			*dest_port = NBT_NAME_SERVICE_PORT;
@@ -95,13 +96,13 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
 {
 	if (PyTuple_Check(obj)) {
 		if (PyTuple_Size(obj) == 2) {
-			name->name = PyString_AsString(PyTuple_GetItem(obj, 0));
+			name->name = PyStr_AsString(PyTuple_GetItem(obj, 0));
 			name->type = PyInt_AsLong(PyTuple_GetItem(obj, 1));
 			name->scope = NULL;
 			return true;
 		} else if (PyTuple_Size(obj) == 3) {
-			name->name = PyString_AsString(PyTuple_GetItem(obj, 0));
-			name->scope = PyString_AsString(PyTuple_GetItem(obj, 1));
+			name->name = PyStr_AsString(PyTuple_GetItem(obj, 0));
+			name->scope = PyStr_AsString(PyTuple_GetItem(obj, 1));
 			name->type = PyInt_AsLong(PyTuple_GetItem(obj, 2));
 			return true;
 		} else {
@@ -110,9 +111,9 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
 		}
 	}
 
-	if (PyString_Check(obj)) {
+	if (PyStr_Check(obj)) {
 		/* FIXME: Parse string to be able to interpret things like RHONWYN<02> ? */
-		name->name = PyString_AsString(obj);
+		name->name = PyStr_AsString(obj);
 		name->scope = NULL;
 		name->type = 0;
 		return true;
@@ -171,7 +172,7 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa
 	ret = PyTuple_New(3);
 	if (ret == NULL)
 		return NULL;
-	PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
+	PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
 
 	py_name = PyObject_FromNBTName(node->socket, &io.out.name);
 	if (py_name == NULL)
@@ -186,7 +187,7 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa
 	}
 
 	for (i = 0; i < io.out.num_addrs; i++) {
-		PyList_SetItem(reply_addrs, i, PyString_FromString(io.out.reply_addrs[i]));
+		PyList_SetItem(reply_addrs, i, PyStr_FromString(io.out.reply_addrs[i]));
 	}
 
 	PyTuple_SetItem(ret, 2, reply_addrs);
@@ -229,7 +230,7 @@ static PyObject *py_nbt_name_status(PyObject *self, PyObject *args, PyObject *kw
 	ret = PyTuple_New(3);
 	if (ret == NULL)
 		return NULL;
-	PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
+	PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
 
 	py_name = PyObject_FromNBTName(node->socket, &io.out.name);
 	if (py_name == NULL)
@@ -289,10 +290,10 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject *
 		return NULL;
 	}
 
-	ret = PyTuple_New(3);
+	ret = PyTuple_New(4);
 	if (ret == NULL)
 		return NULL;
-	PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
+	PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
 
 	py_name = PyObject_FromNBTName(node->socket, &io.out.name);
 	if (py_name == NULL)
@@ -300,7 +301,7 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject *
 
 	PyTuple_SetItem(ret, 1, py_name);
 
-	PyTuple_SetItem(ret, 2, PyString_FromString(io.out.reply_addr));
+	PyTuple_SetItem(ret, 2, PyStr_FromString(io.out.reply_addr));
 
 	PyTuple_SetItem(ret, 3, PyInt_FromLong(io.out.rcode));
 
@@ -347,7 +348,7 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k
 	ret = PyTuple_New(3);
 	if (ret == NULL)
 		return NULL;
-	PyTuple_SetItem(ret, 0, PyString_FromString(io.out.reply_from));
+	PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
 
 	py_name = PyObject_FromNBTName(node->socket, &io.out.name);
 	if (py_name == NULL)
@@ -355,7 +356,7 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k
 
 	PyTuple_SetItem(ret, 1, py_name);
 
-	PyTuple_SetItem(ret, 2, PyString_FromString(io.out.reply_addr));
+	PyTuple_SetItem(ret, 2, PyStr_FromString(io.out.reply_addr));
 
 	PyTuple_SetItem(ret, 3, PyInt_FromLong(io.out.rcode));
 
@@ -386,7 +387,7 @@ static PyMethodDef py_nbt_methods[] = {
 };
 
 PyTypeObject nbt_node_Type = {
-	PyObject_HEAD_INIT(NULL) 0,
+	PyVarObject_HEAD_INIT(NULL, 0)
 	.tp_name = "netbios.Node",
 	.tp_basicsize = sizeof(nbt_node_Object),
 	.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
@@ -397,14 +398,24 @@ PyTypeObject nbt_node_Type = {
 		  "Create a new NetBIOS node\n"
 };
 
-void initnetbios(void)
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    .m_name = "netbios",
+    .m_doc = "NetBIOS over TCP/IP support",
+    .m_size = -1,
+    .m_methods = NULL,
+};
+
+MODULE_INIT_FUNC(netbios)
 {
-	PyObject *mod;
+	PyObject *mod = NULL;
 	if (PyType_Ready(&nbt_node_Type) < 0)
-		return;
+		return mod;
+
+	mod = PyModule_Create(&moduledef);
 
-	mod = Py_InitModule3("netbios", NULL, "NetBIOS over TCP/IP support");
 
 	Py_INCREF((PyObject *)&nbt_node_Type);
 	PyModule_AddObject(mod, "Node", (PyObject *)&nbt_node_Type);
+	return mod;
 }
diff --git a/libcli/nbt/wscript_build b/libcli/nbt/wscript_build
index 090789c..e965a34 100644
--- a/libcli/nbt/wscript_build
+++ b/libcli/nbt/wscript_build
@@ -24,7 +24,8 @@ bld.SAMBA_BINARY('nmblookup' + bld.env.suffix4,
                  install=False
                  )
 
-bld.SAMBA_PYTHON('python_netbios',
+for env in bld.gen_python_environments():
+        bld.SAMBA_PYTHON('python_netbios',
                  source='pynbt.c',
                  public_deps='cli-nbt DYNCONFIG samba-hostconfig',
                  realname='samba/netbios.so'
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c
index b6b53b7..ac6e323 100644
--- a/libgpo/pygpo.c
+++ b/libgpo/pygpo.c
@@ -27,6 +27,7 @@
 #include "librpc/rpc/pyrpc_util.h"
 #include "auth/credentials/pycredentials.h"
 #include "libcli/util/pyerrors.h"
+#include "python/py3compat.h"
 
 /* A Python C API module to use LIBGPO */
 
@@ -37,7 +38,7 @@ static PyObject* GPO_get_##ATTR(PyObject *self, void *closure) \
 		= pytalloc_get_ptr(self); \
 	\
 	if (gpo_ptr->ATTR) \
-		return PyString_FromString(gpo_ptr->ATTR); \
+		return PyStr_FromString(gpo_ptr->ATTR); \
 	else \
 		return Py_None; \
 }
@@ -110,7 +111,7 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
 		goto out;
 	}
 
-	ret = PyString_FromString(unix_path);
+	ret = PyStr_FromString(unix_path);
 
 out:
 	return ret;
@@ -475,7 +476,7 @@ static PyMethodDef ADS_methods[] = {
 	{ "connect", (PyCFunction)py_ads_connect, METH_NOARGS,
 		"Connect to the LDAP server" },
 #ifdef HAVE_ADS
-	{ "get_gpo_list", (PyCFunction)py_ads_get_gpo_list, METH_KEYWORDS,
+	{ "get_gpo_list", (PyCFunction)py_ads_get_gpo_list, METH_VARARGS | METH_KEYWORDS,
 		NULL },
 #endif
 	{ NULL }
@@ -499,34 +500,45 @@ static PyMethodDef py_gpo_methods[] = {
 	{NULL}
 };
 
+static struct PyModuleDef moduledef = {
+	PyModuleDef_HEAD_INIT,
+	.m_name = "gpo",
+	.m_doc = "libgpo python bindings",
+	.m_size = -1,
+	.m_methods = py_gpo_methods,
+};
+
 /* Will be called by python when loading this module */
-void initgpo(void)
+void initgpo(void);
+
+MODULE_INIT_FUNC(gpo)
 {
 	PyObject *m;
 
 	debug_setup_talloc_log();
 
 	/* Instantiate the types */
-	m = Py_InitModule3("gpo", py_gpo_methods, "libgpo python bindings");
+	m = PyModule_Create(&moduledef);
 	if (m == NULL) {
-		return;
+		return m;
 	}
 
 	PyModule_AddObject(m, "version",
-			   PyString_FromString(SAMBA_VERSION_STRING));
+			   PyStr_FromString(SAMBA_VERSION_STRING));
 
 	if (PyType_Ready(&ads_ADSType) < 0) {
-		return;
+		return m;
 	}
 
 	PyModule_AddObject(m, "ADS_STRUCT", (PyObject *)&ads_ADSType);
 
 	if (pytalloc_BaseObject_PyType_Ready(&GPOType) < 0) {
-		return;
+		return m;
 	}
 
 	Py_INCREF((PyObject *)(void *)&GPOType);
 	PyModule_AddObject(m, "GROUP_POLICY_OBJECT",
 			   (PyObject *)&GPOType);
+	return m;
 
 }
diff --git a/libgpo/wscript_build b/libgpo/wscript_build
index 2ef66f7..f456d41 100644
--- a/libgpo/wscript_build
+++ b/libgpo/wscript_build
@@ -7,7 +7,8 @@ bld.SAMBA3_LIBRARY('gpext',
                    deps='talloc ads TOKEN_UTIL auth',
                    private_library=True)
 
-bld.SAMBA3_PYTHON('python_samba_libgpo', 'pygpo.c',
-                 deps='''pyparam_util gpext talloc ads TOKEN_UTIL
-                 auth pyrpc_util''',
-                 realname='samba/gpo.so')
+for env in bld.gen_python_environments():
+    bld.SAMBA3_PYTHON('python_samba_libgpo', 'pygpo.c',
+                     deps='''pyparam_util gpext talloc ads TOKEN_UTIL
+                     auth pyrpc_util''',
+                     realname='samba/gpo.so')
diff --git a/python/py3compat.h b/python/py3compat.h
index ce317c6..5fa57f3 100644
--- a/python/py3compat.h
+++ b/python/py3compat.h
@@ -82,6 +82,19 @@
 #define PY_DESC_PY3_BYTES "bytes"
 #define PY_DESC_PY3_STRING "string"
 
+/* Determine if object is really bytes, for code that runs
+ * in python2 & python3 (note: PyBytes_Check is replaced by
+ * PyString_Check in python2) so care needs to be taken when
+ * writing code that will check if incoming type is bytes that
+ * will work as expected in python2 & python3
+ */
+
+#define IsPy3Bytes PyBytes_Check
+
+#define IsPy3BytesOrString(pystr) \
+    (PyStr_Check(pystr) || PyBytes_Check(pystr))
+
+
 /* Ints */
 
 #define PyInt_Type PyLong_Type
@@ -152,6 +165,17 @@
 #define PY_DESC_PY3_BYTES "string"
 #define PY_DESC_PY3_STRING "unicode"
 
+/* Determine if object is really bytes, for code that runs
+ * in python2 & python3 (note: PyBytes_Check is replaced by
+ * PyString_Check in python2) so care needs to be taken when
+ * writing code that will check if incoming type is bytes that
+ * will work as expected in python2 & python3
+ */
+
+#define IsPy3Bytes(pystr) false
+
+#define IsPy3BytesOrString PyStr_Check
+
 /* PyArg_ParseTuple/Py_BuildValue argument */
 
 #define PYARG_BYTES_LEN "s#"
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index d4d7e4e..fb968a5 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import ldb
 import samba
 import time
@@ -1759,7 +1760,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
         # the correct values are above 0x80000000) values first and
         # remove the 'second' value we see.
         for o in reversed(ctr.array):
-            print "%s: 0x%08x" % (dn, o.attid)
+            print("%s: 0x%08x" % (dn, o.attid))
             att = self.samdb_schema.get_lDAPDisplayName_by_attid(o.attid)
             if att.lower() in set_att:


-- 
Samba Shared Repository



More information about the samba-cvs mailing list