#855836 decopy attempts to parse Python 2 sources with Python 3 and fails

#855836#5
Date:
2017-02-22 10:19:16 UTC
From:
To:
Dear Maintainer,

I'm trying to use decopy on a Python 2 package, and it fails, as it seems it attempts
to parse its Python code with Python 3 parser:

$ decopy
Traceback (most recent call last):
  File "/usr/bin/decopy", line 11, in <module>
    load_entry_point('Decopy==0.1', 'console_scripts', 'decopy')()
  File "/usr/lib/python3/dist-packages/decopy/decopy.py", line 62, in main
    filetree.process(options)
  File "/usr/lib/python3/dist-packages/decopy/tree.py", line 369, in process
    item.process_licenses(self.root, options)
  File "/usr/lib/python3/dist-packages/decopy/tree.py", line 175, in process_licenses
    copyrights, licenses = parse_file(fullpath, options)
  File "/usr/lib/python3/dist-packages/decopy/parsers.py", line 155, in parse_file
    copyrights, licenses = parser(fullname)
  File "/usr/lib/python3/dist-packages/decopy/parsers.py", line 62, in python_parser
    for token in tokenize.tokenize(f.readline):
  File "/usr/lib/python3.5/tokenize.py", line 580, in _tokenize
    ("<tokenize>", lnum, pos, line))
  File "<tokenize>", line 176
    print "SSRC spammer started"
    ^
IndentationError: Missing parentheses in call to 'print'

#855836#10
Date:
2017-03-30 09:23:55 UTC
From:
To:
¡Hola Andrew!

El 2017-02-22 a las 11:19 +0100, Andrew Shadura escribió:

I was cutting some corners by using the tokenize module, I should have written
a small tokenizer that only handles comments and doc strings, this is still
pending.

I was trying to write a test case about this and it seems that the py2 code
needs to be invalid to get this error, but it's only yield when trying to run
it.

Apparently, when running python 2 code in python 3 a:
 python "Foo"
yields a SyntaxError exception with the Missing parentheses in call to 'print'
message, and:
 for a in []:
 print "Bar"
yields the reported IndentationError exception.

But I could not get these exceptions when using the tokenize module.

If you can still reproduce this issue, I would like to write a test with the
file that's failling, so, if possible, please let me know how can I access the
src tree that's producing this issue in decopy.

Happy hacking,

#855836#15
Date:
2022-10-27 09:26:32 UTC
From:
To:
Hi,

* Maximiliano Curia <maxy@debian.org> [2017-03-30 11:23]:

Based on the string I guess it is this file:

https://mau.dev/maunium/synapse/-/blob/v0.5.4/contrib/jitsimeetbridge/jitsimeetbridge.py#L176

But I can't reproduce the bug with a recent decopy either.

I guess this could be closed but will leave the decision to you.

Cheers Jochen

#855836#20
Date:
2026-09-16 14:00:44 UTC
From:
To:
¡Hola!

El 2022-10-27 a las 11:26 +0200, Jochen Sprickerhof escribió:

I finally managed to reproduce the issue, I added a regression test and
solved the problem by falling back to a generic parser when the python
parser fails to parse the python files.

#855836#25
Date:
2026-09-16 14:37:45 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
decopy, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 855836@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Maximiliano Curia <maxy@debian.org> (supplier of updated decopy package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 16 Sep 2026 14:22:36 +0200
Source: decopy
Architecture: source
Version: 0.3.4-1
Distribution: unstable
Urgency: medium
Maintainer: Maximiliano Curia <maxy@debian.org>
Changed-By: Maximiliano Curia <maxy@debian.org>
Closes: 855836 962309 997814 1022330 1147953
Changes:
 decopy (0.3.4-1) unstable; urgency=medium
 .
   * New release 0.3.4
 .
   [ Sebastien Bacher ]
   * Don't recommends python3-zipfile-zstd
 .
   [ Maximiliano Curia ]
   * Detect abbreviated license statements (ASL 2.0, GPLv3) (Closes: #1147953)
   * Fall back to the generic parser on unlexable python (Closes: #855836)
   * Skip the license files in the generated output (Closes: #962309)
   * Add extra test to check unreferenced License blocks
   * Don't list the files excluded with -X (Closes: #997814)
   * Compile the -X pattern as an ordinary regex, not a verbose one
   * Warn when the -X pattern matches no files
   * Skip the always-excluded debian files in the generated output
   * Document that -X drops the excluded files from the output
   * Detect the CC-hosted GNU licence deeds
   * Detect the gnu.org and fsf.org licence pages
   * Detect the retired public-domain CC deeds
   * Detect the Art Libre licence URL
   * Accept "under the terms of" in licence statements
   * Detect the spaced CC BY-SA spelling
   * Add the metadata holder helper
   * Read the RDF metadata block of SVG files
   * Use the SVG metadata when no holder is found
   * Do not read the image Copyright tag as a holder
   * Read the author fields of image metadata (Closes: #1022330)
   * Document the image metadata support
   * Do not crash on changed paths pruned from the tree
   * Make -X repeatable
Checksums-Sha1:
 1b3f6ef35c39ff690101cbd925db5acbb08c732a 2250 decopy_0.3.4-1.dsc
 630b4d27521758b347d8bcf9637208c77e787731 3207364 decopy_0.3.4.orig.tar.gz
 bbdb1385e8069c9b83267821d3db702c595ba67a 4252 decopy_0.3.4-1.debian.tar.xz
 a35b77c4b60cc641f77d4d09a25a89b0c2b47ee5 8843 decopy_0.3.4-1_source.buildinfo
Checksums-Sha256:
 f511fb0a1e7c1ef52abab7d8b4e595b4639c671f4cabacaf7a65eecec1bb82ae 2250 decopy_0.3.4-1.dsc
 0fd4fc6f0562dbf15f336934f87ec29d174e2a177022288c48c51e6563fc08a4 3207364 decopy_0.3.4.orig.tar.gz
 dd80d932111cc81c706399e1455f16cb397a110cb2a8ed54f98f1aae1e328c85 4252 decopy_0.3.4-1.debian.tar.xz
 a4f9cd76245989ae43a0ba80ee398feb6cc16d25beb1d85338bfd6b2b16f65b6 8843 decopy_0.3.4-1_source.buildinfo
Files:
 d4ee5ea3bbb8199efd851e722fe1fa2c 2250 devel optional decopy_0.3.4-1.dsc
 623026de5a26c656e656db82ac7f0060 3207364 devel optional decopy_0.3.4.orig.tar.gz
 c8c689e96c0d8d610a1805f92cfe0b58 4252 devel optional decopy_0.3.4-1.debian.tar.xz
 306f6456a372505c40d5b1b594145ad3 8843 devel optional decopy_0.3.4-1_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE+JIdOnQEyG4RNSIVxxl2mbKbIyoFAmqqnzwACgkQxxl2mbKb
Iyr+uA//fyi/FFt+/IjBBmy6F67Z3HzCQhUaY2A+Yo/mrcbWzEszEimmb/nsk/sS
U1BH7y0y4lQVCb5sSaZnN8lY8IOjyIaq0EU7SR4VRYUwpj7OZ65kDRvtMA6KOPC0
r4b66m0NyG7AnSJuOmLJ3zEjbsk6IugOopV1zOnHBm+EKIp84GcgTUYzaxx3SQUT
it14CANONrg7QJfUphPau5yNVTV9gMJUsFRRJXiyPufihctuzbqrmoV+8aakAq1w
HE5Sg1qBajzWuf3WPzHsOyOwZE6oDuNH6g5x8kzgQqNu+qZU+8Xj+/Hz3VmeVldZ
8nRkQJ2i+Z5XKJBfG7bJsEd8mniNkqq0TwM4zj8SlTE8f4pM3bA9ZtNBPaTedDiO
l1tOYJpizRsXoy8N/Gz4C8roOZLa2xTo0+zqK+FRMI6fyPCJ0x493RBZcyJHOE/i
A+lcVqy/44R/xqiOJ/aueWyWbdNL84JUJsOK15i2sRfMyU8uwE6ossZKojVsVOto
4jU1PttQRep8V/Og//yCOVGIzRDRj2B6V1OyljhI3aWia5XrFGkmr80FMqCnnlbi
b3Np8IE2GTHTa3oirnhR5fadBf2khiPEtDSzq15TgMWcvDWUy+vKPf80J5bK9xLB
zqSnysXG5EGTfjKelYxcAbU3EjySRyNqxe7DK+ZjIqKb5Or92ls=
=3SJf
-----END PGP SIGNATURE-----