One function

make_vcard_data in heuer/segno

The author described this change as Fixed bug in vCard implementation, added more test cases, updated CHANGES. It counts as a record because the check below fails on the code as it stood at 349d34d74 and passes on 676772e7a, with nothing else changed between the two runs.

Fix saved2020-01-02
Sharing licenceBSD-3-Clause · LICENSE
Change size+7 3

What the code was meant to do, written into the code itself as a docstring

Creates a string encoding the contact information as vCard 3.0. Only a subset of available `vCard 3.0 properties <https://tools.ietf.org/html/rfc2426>` is supported. :param str name: The name. If it contains a semicolon, , the first part is treated as lastname and the second part is treated as forename. :param str displayname: Common name. :param email: E-mail address. Multiple values are allowed. :type email: str, iterable of strings, or None :param phone: Phone number. Multiple values are allowed. :type phone: str, iterable of strings, or None :param fax: Fax number. Multiple values are allowed. :type fax: str, iterable of strings, or None :param videophone: Phone number for video calls. Multiple values are allowed. :type videophone: str, iterable of strings, or None :param memo: A notice for the contact. :type memo: str or None :param nickname: Nickname. :type nickname: str or None :param birthday: Birthday. If a string is provided, it should encode the date as `YYYY-MM-DD` value. :type birthday: str, datetime.date or None :param url: Homepage. Multiple values are allowed. :type url: str, iterable of strings, or None :param pobox: P.O. box (address information). :type pobox: str or None :param street: Street address. :type street: str or None :param city: City (address information). :type city: str or None :param region: Region (address information). :type region: str or None :param zipcode: Zip code (address information). :type zipcode: str or None :param country: Country (address information). :type country: str or None :param org: Company / organization name. :type org: str or None :param lat: Latitude. :type lat: float or None :param lng: Longitude. :type lng: float or None :param source: URL where to obtain the vCard. :type source: str or None :param rev: Revision of the vCard / last modification date. :type rev: str, datetime.date or None :param title: Job Title. Multiple values are allowed. :type title: str, iterable of strings, or None :param photo_uri: Photo URI. Multiple values are allowed. :type photo_uri: str, iterable of strings, or None :rtype: str

The change

8888 birthday = birthday.strftime('%Y-%m-%d')
8989 except AttributeError:
9090 pass
91- if not _looks_like_datetime(birthday):
91+ if not isinstance(birthday, str_type) or not _looks_like_datetime(birthday):
9292 raise ValueError('"birthday" does not seem to be a valid date or date/time representation')
9393 data.append('BDAY:{0}'.format(birthday))
9494 if lat and not lng or lng and not lat:
9696 if lat and lng:
9797 data.append('GEO:{0};{1}'.format(lat, lng))
9898 if source:
99- data.append('SOURCE:{0}'.format(escape(url)))
99+ data.append('SOURCE:{0}'.format(escape(source)))
100100 if memo:
101101 data.append('NOTE:{0}'.format(escape(memo)))
102102 if rev:
103- if not _looks_like_datetime(rev):
103+ try:
104+ rev = rev.strftime('%Y-%m-%d')
105+ except AttributeError:
106+ pass
107+ if not isinstance(rev, str_type) or not _looks_like_datetime(rev):
104108 raise ValueError('"rev" does not seem to be a valid date or date/time representation')
105109 data.append('REV:{0}'.format(rev))
106110 data.append('END:VCARD')

The check that tells the two apart

failpass·tests/test_helpers.py::test_vcard_data_source_url

Check file tests/test_helpers.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it349d34d742c988f90c208f968a298525214d23f0
Broken version dated2020-01-02
Modulesegno.helpers
Units changedmake_vcard_data
Fingerprint222d6a3d3df46aae
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in heuer/segno